def run(): Conf.init_argparse() mode = '/'.join(Conf.get('mode')) if mode == 'server': run_server() elif mode == 'sync': run_sync() elif mode == 'status': print(DbState.status()) else: raise Exception("unknown run mode %s" % mode)
def run(): """Run the proper routine as indicated by hive --mode argument.""" conf = Conf.init_argparse() Db.set_shared_instance(conf.db()) mode = conf.mode() if mode == 'server': from hive.server.serve import run_server run_server(conf=conf) elif mode == 'sync': from hive.indexer.sync import Sync Sync(conf=conf).run() elif mode == 'status': from hive.db.db_state import DbState print(DbState.status()) #elif mode == 'sync-profile': # from hive.indexer.sync import Sync # from hive.utils.profiler import Profiler # with Profiler(): # Sync(conf=conf).run() else: raise Exception("unknown run mode %s" % mode)
def run(): """Run the proper routine as indicated by hive --mode argument.""" Conf.init_argparse() mode = Conf.run_mode() if mode == 'server': run_server() elif mode == 'sync': Sync.run() elif mode == 'status': print(DbState.status()) else: raise Exception("unknown run mode %s" % mode)
def run(): """Run the service specified in the `--mode` argument.""" conf = Conf.init_argparse() Db.set_shared_instance(conf.db()) mode = conf.mode() if conf.get('test_profile'): from hive.utils.profiler import Profiler with Profiler(): launch_mode(mode, conf) else: launch_mode(mode, conf)
def run(): """Run the proper routine as indicated by hive --mode argument.""" conf = Conf.init_argparse() Db.set_shared_instance(conf.db()) mode = '/'.join(conf.get('mode')) if mode == 'server': from hive.server.serve import run_server run_server(conf=conf) elif mode == 'sync': from hive.indexer.sync import Sync Sync(conf=conf).run() elif mode == 'status': from hive.db.db_state import DbState print(DbState.status()) else: raise Exception("unknown run mode %s" % mode)
return web.json_response( status=status, data=dict(state=state, result=result, status='OK' if status == 200 else 'WARN', sync_service=is_syncer, source_commit=os.environ.get('SOURCE_COMMIT'), schema_hash=os.environ.get('SCHEMA_HASH'), docker_tag=os.environ.get('DOCKER_TAG'), timestamp=datetime.utcnow().isoformat())) async def jsonrpc_handler(request): """Handles all hive jsonrpc API requests.""" request = await request.text() response = await methods.dispatch(request) return web.json_response(response, status=200, headers={'Access-Control-Allow-Origin': '*'}) app.router.add_get('/.well-known/healthcheck.json', health) app.router.add_get('/head_age', head_age) app.router.add_get('/health', health) app.router.add_post('/', jsonrpc_handler) web.run_app(app, port=app['config']['args'].http_server_port) if __name__ == '__main__': Conf.init_argparse() run_server()
import datetime import pytest from hive.steem.client import SteemClient from hive.utils.normalize import parse_time from hive.conf import Conf Conf.init_argparse(ignore_unknown=True) def test_instance(): assert isinstance(SteemClient.instance(), SteemClient) def test_get_accounts(): client = SteemClient.instance() accounts = client.get_accounts(['steemit', 'test-safari']) assert len(accounts) == 2 assert accounts[0]['name'] == 'steemit' def test_get_content_batch(): client = SteemClient.instance() tuples = [('test-safari', 'may-spam'), ('test-safari', 'june-spam')] posts = client.get_content_batch(tuples) assert len(posts) == 2 assert posts[0]['author'] == 'test-safari' assert posts[1]['author'] == 'test-safari' def test_get_block():