예제 #1
0
def cli(module):
    if module == '':
        modules = all_modules
    elif module in all_modules:
        modules = [module]
    else:
        print('Module does not exist.')
        raise SystemExit(-1)

    app.initialize(env='test')

    failed = False
    final_exit_code = 0

    for module in modules:
        db_manager.execute_query_no_return(
            'DELETE FROM USER_CREDENTIALS; DELETE FROM HASHTAG;')
        db_manager.execute_query_no_return(
            open(module + '/seed.sql', 'r').read())
        exit_code = pytest.main([
            '--cov-report', 'term-missing', '--cov=' + module,
            module + '/test_actions.py'
        ])
        if exit_code != 0 and not failed:
            failed = True
            final_exit_code = exit_code

    db_manager.execute_query_no_return(
        'DELETE FROM USER_CREDENTIALS; DELETE FROM HASHTAG;')
    raise SystemExit(final_exit_code)
예제 #2
0
def main():
    opts, args = parse_opts(app.config)
    app.config.update(dict(
        SERVER_TYPE=opts.server_type,
        SERVERS=opts.servers or app.config.get('SERVERS'),
        SQLALCHEMY_DATABASE_URI=opts.database_url,
        BASIC_AUTH_USERNAME=opts.username,
        BASIC_AUTH_PASSWORD=opts.password,
        NO_AUTH=opts.no_auth
    ))

    if opts.verbose:
        app.logger.setLevel(logging.DEBUG)
    initialize()
    app.logger.info("SpiderKeeper startd on %s:%s username:%s/password:%s with %s servers:%s" % (
        opts.host, opts.port, opts.username, opts.password, opts.server_type, ','.join(app.config.get('SERVERS', []))))
        
    app.run(host=opts.host, port=opts.port, use_reloader=False, threaded=True,debug = True)
예제 #3
0
파일: server.py 프로젝트: Odellc/Flask
def initialize():
    '''
    Perform heavy-lifting initialization asynchronously.
    :return:
    '''
    can_start = app.initialize()

    if can_start:
        response = {
            'status': 'ok',
        }
    else:
        response = {'status': 'error'}

    return jsonify(response)
예제 #4
0
def initialize():
    """
    Perform heavy-lifting initialization asynchronously.
    :return:
    """
    can_start = app.initialize()

    if can_start:
        response = {
            "status": "ok",
        }
    else:
        response = {"status": "error"}

    return jsonify(response)
예제 #5
0
def initialize():
    """
    Initialize app asynchronously.
    :return: app
    """
    can_start = app.initialize()

    if can_start:
        response = {
            "status": "ok",
        }
    else:
        response = {"status": "error"}

    return jsonify(response)
예제 #6
0
파일: server.py 프로젝트: r0x0r/pywebview
def initialize():
    """
    Perform heavy-lifting initialization asynchronously.
    :return:
    """
    can_start = app.initialize()

    if can_start:
        response = {
            "status": "ok",
        }
    else:
        response = {
            "status": "error"
        }

    return jsonify(response)
예제 #7
0
def cli(module, production):
    if module == '':
        modules = all_modules
    elif module in all_modules:
        modules = [module]
    else:
        print('Module does not exist.')
        raise SystemExit(12)

    if production:
        env = 'production test'
    else:
        env = 'development test'

    if not app.initialize(env=env):
        raise SystemExit(11)

    failed = False
    final_exit_code = 0

    for module in modules:
        db_manager.execute_query_no_return(
            'DELETE FROM USER_CREDENTIALS; DELETE FROM HASHTAG;')
        response = db_manager.execute_query_no_return(
            open(module + '/seed.sql', 'r').read())
        if response is not None:
            print('Seed error:')
            print(response)
            raise SystemExit(10)
        exit_code = pytest.main([
            '--cov-report', 'term-missing', '--cov=' + module,
            module + '/test_actions.py'
        ])
        if exit_code != 0 and not failed:
            failed = True
            final_exit_code = exit_code

    db_manager.execute_query_no_return(
        'DELETE FROM USER_CREDENTIALS; DELETE FROM HASHTAG;')
    if final_exit_code == 0:
        print('All tests passed.')
    else:
        print('Some tests failed!')
    raise SystemExit(final_exit_code)
예제 #8
0
    pass


class KeySocketServer(Thread):
    def __init__(self):
        self.server = websocket.WebSocketServer("localhost", 1337, KeySocket)
        Thread.__init__(self)

    def run(self):
        self.server.listen()

    def sendKey(self, keyCode):
        for socket in self.server.connections.values():
            socket.send(keyCode)


if __name__ == "__main__":
    # Start the websocket server in a separate thread
    server = KeySocketServer()
    server.start()

    def sendKeyCommand(code, state):
        # When there's a keyup
        if state is KEY_UP:
            # Send the code to the websocket
            server.sendKey(code)
            logging.info("Sent code %s to clients." % code)

    # Launch the cocoa app
    app.initialize(sendKeyCommand)
예제 #9
0
from app import initialize


if __name__ == "__main__":
    initialize()
예제 #10
0
파일: api.py 프로젝트: rchen45/backend
from app import initialize
initialize()