예제 #1
0
파일: server.py 프로젝트: SkyPicker/Skywall
 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
예제 #2
0
파일: client.py 프로젝트: SkyPicker/Skywall
 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
예제 #3
0
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)
예제 #4
0
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')
예제 #5
0
 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))
예제 #6
0
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()
예제 #7
0
 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))
예제 #8
0
파일: server.py 프로젝트: SkyPicker/Skywall
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()
예제 #9
0
 def default(self):
     host = config.get('server.host')
     port = config.get('server.port')
     return 'http://{}:{}/'.format(host, port)
예제 #10
0
 def default(self):
     return config.get('webserver.host')
예제 #11
0
파일: client.py 프로젝트: SkyPicker/Skywall
 def send_label(self):
     label = config.get('client.label')
     self.send_action(SaveLabelServerAction(label=label))
예제 #12
0
def import_enabled_modules():
    modules = config.get('modules')
    return import_modules(modules)