Пример #1
0
def setup_server():
    global _app
    server.options.with_library = "./library/"
    server.CONF['ALLOW_GUEST_PUSH'] = False
    server.CONF['installed'] = True
    server.CONF['user_database'] = 'sqlite:///users.db'
    _app = server.make_app()
Пример #2
0
 def test_make_app(self):
     """
     Verify make_app() creates a valid Router instance.
     """
     result = make_app()
     assert type(result) == Router
     assert callable(result)
Пример #3
0
 def test_make_app(self):
     """
     Verify make_app() creates a valid Router instance.
     """
     result = make_app()
     assert type(result) == Router
     assert callable(result)
Пример #4
0
 def get_app(self):
     """Create a server with dummy data"""
     auth = DummyAuth()
     auth.add_machine('TESTMACHINE')
     auth.add_user('TESTAUTH')
     auth.make_user_authorizer_on_machine('TESTMACHINE', 'TESTAUTH')
     auth.add_user('TESTUSER')
     auth.add_user('TESTUSERTOBEAUTH')
     auth.authorize_user('TESTMACHINE', 'TESTAUTH')
     auth.authorize_user('TESTMACHINE', 'TESTUSER')
     return server.make_app(auth)
Пример #5
0
from flask.ext.script import Manager
from server.models import db_config
import server

app = server.make_app()
manager = Manager(app, with_default_commands=False)


@manager.command
def init_db():
    db_config.init_db()

if __name__ == '__main__':
    manager.run()
Пример #6
0
import server


class ClientProxy(object):
    def __init__(self, app):
        self.app = app

    def __call__(self, environ, start_response):
        environ["wsgi.url_scheme"] = server.app.config['URL_SCHEME']
        environ["HTTP_HOST"] = server.app.config['SERVER_URL']
        return self.app(environ, start_response)

application = server.init(server.make_app())
application = server.init_web(application)
application.wsgi_app = ClientProxy(application.wsgi_app)

if __name__ == '__main__':

    application.run('0.0.0.0', 9090, use_debugger=True, use_reloader=True)
Пример #7
0
 def get_app(self):
     return server.make_app("test")
Пример #8
0
    credentials = ( environ.get("PHONE"), environ.get("PASSWORD" ) )
    port = environ.get("PORT")

if __name__==  "__main__":

    messages = dict()

    stackBuilder = YowStackBuilder()
    stack = stackBuilder\
        .pushDefaultLayers(True)\
        .push(EchoLayer)\
        .build()

    stack.setProp("messages", messages)

    app = make_app(stack, messages)

    def YowThread():
        stack.setCredentials(credentials)
        stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))   #sending the connect signal
        stack.loop() #this is the program mainloop

    def TornadoThread():
        app.listen(port)
        tornado.ioloop.IOLoop.current().start()

    WaThread = threading.Thread( target=YowThread )
    WaThread.daemon = True
    WaThread.start()

    AppThread = threading.Thread( target=TornadoThread )
 def get_app(self):
     messages = dict()
     stack = self.prepare_stack( (), messages)
     app = make_app(stack, messages)
     # stack.loop?
     return app
Пример #10
0
import server
import tornado

if __name__ == "__main__":
    app = server.make_app()
    app.listen(8080)
    tornado.ioloop.IOLoop.current().start()
Пример #11
0
import json
import os
from io import BytesIO
from tempfile import TemporaryFile, NamedTemporaryFile
from time import sleep
from zipfile import ZipFile

import cv2

from server import make_app

client = make_app().app.test_client()


def post_json(url, data):
    return client.post(url,
                       data=json.dumps(data),
                       content_type='application/json')


def run_job(url, timeout=120):
    r = client.post(url)
    assert r.status_code == 202
    jobid = r.json

    res = None
    for i in range(timeout):
        r = client.get("/jobs?jobs_type=recent_with_status")
        assert r.status_code == 200
        for status in r.json:
            if status['id'] == jobid and status['result'] not in ('running',
Пример #12
0
	def get_app(self):
		self.app = server_under_test.make_app()
		return self.app