def __init__(self, loop): self.host = config.get('webserver.host') self.port = config.get('webserver.port') self.loop = loop self.app = None self.handler = None self.server = None
def __init__(self, loop): self.url = config.get('server.publicUrl') self.client_id = config.get('client.id') self.client_token = config.get('client.token') self.reports_frequency = config.get('client.reports.frequency') self.loop = loop self.session = None self.socket = None
def build_frontend(): host = config.get('webpack.host') port = config.get('webpack.port') modules = ','.join( ['skywall'] + [module.__name__ for module in import_enabled_modules()]) env = dict(os.environ, WEBPACK_HOST=host, WEBPACK_PORT=str(port), FRONTEND_ENTRIES=modules) subprocess.run(['node', '-e', 'require("skywall/webpack/build")'], env=env)
def get_frontend(request): devel = config.get('devel') host = config.get('webpack.host') port = config.get('webpack.port') data = dict( devel=devel, api=API_ROUTE, ) if devel: style = '' script = 'http://{host}:{port}{build}/app.js'.format(host=host, port=port, build=BUILD_ROUTE) else: style = '<link href="{build}/app.css" rel="stylesheet" />'.format( build=html.escape(BUILD_ROUTE)) script = '{build}/app.js'.format(build=BUILD_ROUTE) content = """ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta content="IE=edge" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Skywall</title> {style} </head> <body data="{data}"> <div id="app"></div> <script> (function() {{ var body = document.getElementsByTagName('body')[0]; var app = document.createElement('script'); app.type = 'text/javascript'; app.async = true; app.src = {script}; body.appendChild(app); }})() </script> </body> </html> """.format( style=style, script=html.escape(json.dumps(script), quote=False), data=html.escape(json.dumps(data)), ) return aiohttp.web.Response(text=content, content_type='text/html')
def run(self, args): for name in args.names: config.unset(name) config.save() for name in sorted(settings_registry): if _setting_matches_args(name, args.names): value = config.get(name) print('{}: {}'.format(name, value))
def connect_database(): # pylint: disable=global-statement global _session before_database_connect.emit() database = config.get('server.database') engine = create_engine(database, echo=True) _session = sessionmaker(bind=engine) Model.metadata.create_all(engine) after_database_connect.emit()
def run(self, args): affected = [] for name in settings_registry: value = getattr(args, name) if value is not None: affected.append(name) config.set(name, value) config.save() for name in affected: value = config.get(name) print('{}: {}'.format(name, value))
def run_server(): # pylint: disable=global-statement global _server loop = asyncio.get_event_loop() with contextlib.ExitStack() as stack: _server = stack.enter_context(WebsocketServer(loop)) stack.enter_context(WebServer(loop)) if config.get('devel'): stack.enter_context(WebpackServer()) try: loop.run_forever() finally: _server = None loop.close()
def default(self): host = config.get('server.host') port = config.get('server.port') return 'http://{}:{}/'.format(host, port)
def default(self): return config.get('webserver.host')
def send_label(self): label = config.get('client.label') self.send_action(SaveLabelServerAction(label=label))
def import_enabled_modules(): modules = config.get('modules') return import_modules(modules)