def __init__(self, history_path=None): # Disable tornado's logging. # TODO(Kenadia): Enable these logs if verbosity flag is at least -vvv. # I think this will require changing how StoreRepsInModule works. # Currently, if we call logs.ARG_PARSER.parse_known_args() multiple # times, we multiply the number of v's that we get. tornado_logger = logging.getLogger('tornado') tornado_logger.propagate = False if not tornado_logger.handlers: tornado_logger.addHandler(logging.NullHandler()) # Override tornado's json encoding to handle our Attachments. def _json_encode(value): return TestRecordEncoder().encode(value) sockjs.tornado.proto.json_encode = _json_encode # Bind port early so that the correct port number can be used in the routes. sockets, port = web_gui_server.bind_port(int(conf.station_server_port)) # Set up the station watcher. station_watcher = StationWatcher(StationPubSub.publish_update) station_watcher.start() # Set up the SockJS endpoints. dashboard_class = DashboardPubSub.for_port(port) dash_router = sockjs.tornado.SockJSRouter(dashboard_class, '/sub/dashboard') station_router = sockjs.tornado.SockJSRouter(StationPubSub, '/sub/station') routes = dash_router.urls + station_router.urls # Set up the other endpoints. routes.extend(( (r'/tests/(?P<test_uid>[\w\d:]+)/phases', PhasesHandler), (r'/tests/(?P<test_uid>[\w\d:]+)/plugs/(?P<plug_name>.+)', PlugsHandler), (r'/tests/(?P<test_uid>[\w\d:]+)/phases/(?P<phase_descriptor_id>\d+)/' 'attachments/(?P<attachment_name>.+)', AttachmentsHandler), )) # Optionally enable history from disk. if history_path is not None: routes.extend(( (r'/history', HistoryListHandler, { 'history_path': history_path }), (r'/history/(?P<file_name>[^/]+)', HistoryItemHandler, { 'history_path': history_path }), (r'/history/(?P<file_name>[^/]+)/attachments/(?P<attachment_name>.+)', HistoryAttachmentsHandler, { 'history_path': history_path }), )) super(StationServer, self).__init__(routes, port, sockets=sockets) self.station_multicast = StationMulticast(port)
def __init__(self, history_path=None): # Disable tornado's logging. # TODO(Kenadia): Enable these logs if verbosity flag is at least -vvv. # I think this will require changing how StoreRepsInModule works. # Currently, if we call logs.ARG_PARSER.parse_known_args() multiple # times, we multiply the number of v's that we get. tornado_logger = logging.getLogger('tornado') tornado_logger.propagate = False if not tornado_logger.handlers: tornado_logger.addHandler(logging.NullHandler()) # Bind port early so that the correct port number can be used in the routes. sockets, port = web_gui_server.bind_port(int(conf.station_server_port)) # Set up the station watcher. station_watcher = StationWatcher(StationPubSub.publish_update) station_watcher.start() # Set up the SockJS endpoints. dashboard_class = DashboardPubSub.for_port(port) dash_router = sockjs.tornado.SockJSRouter(dashboard_class, '/sub/dashboard') station_router = sockjs.tornado.SockJSRouter(StationPubSub, '/sub/station') routes = dash_router.urls + station_router.urls # Set up the other endpoints. routes.extend(( (r'/tests/(?P<test_uid>[\w\d:]+)/phases', PhasesHandler), (r'/tests/(?P<test_uid>[\w\d:]+)/plugs/(?P<plug_name>.+)', PlugsHandler), (r'/tests/(?P<test_uid>[\w\d:]+)/phases/(?P<phase_descriptor_id>\d+)/' 'attachments/(?P<attachment_name>.+)', AttachmentsHandler), )) # Optionally enable history from disk. if history_path is not None: routes.extend(( (r'/history', HistoryListHandler, {'history_path': history_path}), (r'/history/(?P<file_name>[^/]+)', HistoryItemHandler, {'history_path': history_path}), (r'/history/(?P<file_name>[^/]+)/attachments/(?P<attachment_name>.+)', HistoryAttachmentsHandler, {'history_path': history_path}), )) super(StationServer, self).__init__(routes, port, sockets=sockets) self.station_multicast = StationMulticast(port)