blob: 5c7c78d4f39a076fd883547adec3ca7270d605da [file] [log] [blame]
"""Simple web server for the factory.
import subprocess
import traceback
import tornado.web
class FactoryHandler(tornado.web.RequestHandler):
"""Display information about the device, useful in manufacturing."""
def get(self): # pylint: disable=g-bad-name
script = subprocess.Popen(FACTORY_SH, stdout=subprocess.PIPE)
factory_output, _ = script.communicate(None)
except (IOError, OSError, subprocess.CalledProcessError):
print 'Unable to invoke %s' % FACTORY_SH
print traceback.print_exc()
self.write('script invocation failed')
self.set_header('Content-Type', 'text/plain')
def FactoryFactory():
"""I'm sorry. I couldn't resist. I'm sorry. Sorry, sorry, sorry."""
return tornado.web.Application([(r'/factory', FactoryHandler)])