Exemple #1
0
def TestGetterGood():
    print ('Running TestGetterGood...')
    global bw2
    bw2 = BeaconWrapper(beacon, self_port + 1, 'services/' + target, {})
    bw2.beacon_setter()
    bw.beacon_getter()
    time.sleep(10)
    assert bw[target] == 'http://127.0.0.1:'+str(self_port+1), 'TestGetterGood failed'
    print('TestGetterGood passed')
Exemple #2
0
def TestGetterGood():
    print('Running TestGetterGood...')
    global bw2
    bw2 = BeaconWrapper(beacon, self_port + 1, 'services/' + target, {})
    bw2.beacon_setter()
    bw.beacon_getter()
    time.sleep(10)
    assert bw[target] == 'http://127.0.0.1:' + str(self_port +
                                                   1), 'TestGetterGood failed'
    print('TestGetterGood passed')
def api_404(msg = 'Not found'):
    return response_builder({'error': msg}, 404)

@app.errorhandler(408)
def api_408(msg = 'Timed out'):
    return response_builder({'error': msg}, 408)

@app.errorhandler(456)
def api_456(msg = 'Unrecoverable error'):
    return response_builder({'error': msg}, 456)

@app.errorhandler(200)
def api_200(data = {}):
    return response_builder(data, 200)

### Other ###
        
if __name__ == '__main__':
    host = '0.0.0.0'
    beacon, port = parse_argv(sys.argv, 'data_backend:port[,data_backend:port]')
    dbcss = sys.argv[3]
    ss = dbcss.split(',')
    app.config.update(DATA_BACKENDS = ss)
    print('Starting with settings: Beacon: {0} self: {1}:{2} data_backends: {3}'.format(beacon, host, port, ss))

    bw = BeaconWrapper(beacon, port, 'services/database')
    bw.beacon_setter()
    shards = list(map(lambda x: shard_name_fmt.format(x), app.config['DATA_BACKENDS'][:SHARDS_COUNT]))
    print(app.config['GRID_CALC_ROLE'])
    platform_dependent_on_run(app.config['GRID_CALC_ROLE'])
    app.run(host = host, port = port)