def app(): ln.server.app.config['TESTING'] = True ln.server.storage_backend = get_backend({'backend': 'memory'}) # Prepopulate with some data b = ln.server.storage_backend int_config = dict(name='int', type='int32', reduction='sum', interpolation='zero', description='Integer counter', unit='', metadata='') b.create_series(**int_config) start = datetime(2013, 8, 26, 0, 0, 0) b.add_data('int', start + timedelta(hours=1), 1) b.add_data('int', start + timedelta(hours=2, minutes=29, seconds=59), 3) b.add_data('int', start + timedelta(hours=2, minutes=30), 10) b.add_data('int', start + timedelta(hours=3), 20) b.add_data('int', start + timedelta(hours=3, minutes=10), 1) b.add_data('int', start + timedelta(hours=5), 2) b.add_data('int', start + timedelta(hours=6), 6) return ln.server.app.test_client()
def start(config, options): '''Start the web server. :param config: Configuration definition :param options: argparse.Namespace with command line options: profile - run application in profiler mode ''' global storage_backend print('Natural Log', __version__) storage = config['storage'] print('Opening "%s" storage backend...' % storage['backend']) storage_backend = backend.get_backend(storage) app.config['url_base'] = 'url_base' print('Base URL is', config['url_base']) if options.profile: from werkzeug.contrib.profiler import ProfilerMiddleware app.config['PROFILE'] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[50]) app.run(host=config['host'], port=config['port'], threaded=True, debug=True)
def app(): ln.server.app.config['TESTING'] = True ln.server.storage_backend = get_backend({'backend': 'memory'}) # Prepopulate with some data b = ln.server.storage_backend int_config = dict( name='int', type='int32', reduction='sum', interpolation='zero', description='Integer counter', unit='', metadata='' ) b.create_series(**int_config) start = datetime(2013, 8, 26, 0, 0, 0) b.add_data('int', start + timedelta(hours=1), 1) b.add_data('int', start + timedelta(hours=2, minutes=29, seconds=59), 3) b.add_data('int', start + timedelta(hours=2, minutes=30), 10) b.add_data('int', start + timedelta(hours=3), 20) b.add_data('int', start + timedelta(hours=3, minutes=10), 1) b.add_data('int', start + timedelta(hours=5), 2) b.add_data('int', start + timedelta(hours=6), 6) return ln.server.app.test_client()
def export_command(config, options): '''Export database to JSON file.''' print('Natural Log', ln.__version__) storage = config['storage'] print('Opening "%s" storage backend...' % storage['backend']) storage_backend = backend.get_backend(storage) with open(options.output) as output: export_json(storage_backend, output)
def app(request): ln.server.app.config['TESTING'] = True ln.server.app.config['url_base'] = '' ln.server.storage_backend = get_backend({'backend': 'memory'}) b = ln.server.storage_backend int_config = dict( name='int', type='int32', reduction='sum', interpolation='linear', description='Integer counter', unit='', metadata='' ) b.create_series(**int_config) float_config = dict( name='float', type='float32', reduction='mean', interpolation='linear', description='Float counter', unit='', metadata='' ) b.create_series(**float_config) array_config = dict( name='array', type='float32[4]', reduction='mean', interpolation='linear', description='Array', unit='', metadata='' ) b.create_series(**array_config) blob_config = dict( name='blob', type='blob:text/plain', reduction='closest', interpolation='none', description='BLOB', unit='', metadata='' ) b.create_series(**blob_config) return ln.server.app.test_client()
def app(request): ln.server.app.config['TESTING'] = True ln.server.app.config['url_base'] = '' ln.server.storage_backend = get_backend({'backend': 'memory'}) b = ln.server.storage_backend int_config = dict(name='int', type='int32', reduction='sum', interpolation='linear', description='Integer counter', unit='', metadata='') b.create_series(**int_config) float_config = dict(name='float', type='float32', reduction='mean', interpolation='linear', description='Float counter', unit='', metadata='') b.create_series(**float_config) array_config = dict(name='array', type='float32[4]', reduction='mean', interpolation='linear', description='Array', unit='', metadata='') b.create_series(**array_config) blob_config = dict(name='blob', type='blob:text/plain', reduction='closest', interpolation='none', description='BLOB', unit='', metadata='') b.create_series(**blob_config) return ln.server.app.test_client()
def app(): ln.server.app.config['TESTING'] = True ln.server.storage_backend = get_backend({'backend': 'memory'}) return ln.server.app.test_client()