Ejemplo n.º 1
0
def main():
    try:
        WebInterface(robot)

        wsgi_app = WSGIContainer(app)

        application = Application([(r'/movement', MovementHandler, {'robot': robot}), (r'/log', LogHandler),
                                   (r'.*', FallbackHandler, {'fallback': wsgi_app})])

        Log.instance().add_info_message('info')
        Log.instance().add_check_message('check')
        Log.instance().add_warning_message('warning')
        Log.instance().add_error_message('error')

        print "starting HTTP server"
        http_server = HTTPServer(application)
        http_server.listen(8080)
        IOLoop.instance().start()

    except (KeyboardInterrupt, SystemExit):
        print "exit"
        robot.stop()
        Log.instance().add_warning_message('Closing the application')
        time.sleep(2)
Ejemplo n.º 2
0
 def update(self):
     if self.opened:
         msg = Log.instance().get_messages(self)
         if msg is not None:
             self.write_message(json.dumps(msg))
Ejemplo n.º 3
0
 def on_message(self, message):
     Log.instance().add_check_message('WS log: message received %s' % message)
     self.update()
Ejemplo n.º 4
0
 def on_close(self):
     self.opened = False
     Log.instance().remove_observer(self)
     Log.instance().add_warning_message('WS log: connection closed')
Ejemplo n.º 5
0
 def open(self):
     self.opened = True
     Log.instance().add_info_message('WS log: new connection')
     Log.instance().register_observer(self)
     self.update()