def run_events_monitor(): setup_logging() logger.info('EventsMonitor: preparing') required_env_vars = ['EVENTS_RPC', 'CONFIG_FILE'] for envvar in required_env_vars: if not os.getenv(envvar): raise AssertionError( f'env var {envvar} is missing, make sure to set the following ' f'environment variables before starting the events monitor: {required_env_vars}' ) network_rpc = os.environ.get('EVENTS_RPC', 'http:127.0.0.1:8545') config_file = os.getenv('CONFIG_FILE', 'config.ini') logger.info( f'EventsMonitor: starting with the following values: rpc={network_rpc}' ) ConfigProvider.set_config(Config(config_file)) from ocean_lib.ocean.util import get_web3_connection_provider Web3Provider.init_web3(provider=get_web3_connection_provider(network_rpc)) ContractHandler.set_artifacts_path(get_artifacts_path()) if get_network_name().lower() == 'rinkeby': from web3.middleware import geth_poa_middleware Web3Provider.get_web3().middleware_stack.inject(geth_poa_middleware, layer=0) monitor = EventsMonitor(Web3Provider.get_web3(), config_file) monitor.start_events_monitor() logger.info(f'EventsMonitor: started') while True: time.sleep(5)
def run_events_monitor(): setup_logging() logger.info("EventsMonitor: preparing") required_env_vars = ["EVENTS_RPC", "AQUARIUS_CONFIG_FILE"] for envvar in required_env_vars: if not os.getenv(envvar): raise AssertionError( f"env var {envvar} is missing, make sure to set the following " f"environment variables before starting the events monitor: {required_env_vars}" ) config_file = os.getenv("AQUARIUS_CONFIG_FILE", "config.ini") monitor = EventsMonitor(setup_web3(config_file, logger), config_file) monitor.start_events_monitor() logger.info("EventsMonitor: started") if os.getenv("EVENTS_HTTP", None): logger.info("Events HTTP probing started on port 5001..") httpd = socketserver.TCPServer(("", 5001), Handler) httpd.serve_forever() else: while True: time.sleep(5)
def test_setup_logging(monkeypatch): with patch("logging.config.dictConfig") as mock: mock.side_effect = Exception("Boom!") setup_logging() monkeypatch.setenv("LOG_LEVEL", "DEBUG") setup_logging() setup_logging("some_madeup_path")
list_errors, get_request_data) from aquarius.events.metadata_updater import MetadataUpdater from aquarius.events.util import get_artifacts_path, get_network_name from aquarius.log import setup_logging from aquarius.myapp import app ConfigProvider.set_config(OceanConfig(app.config['CONFIG_FILE'])) Web3Provider.init_web3( provider=get_web3_connection_provider(os.environ.get('EVENTS_RPC', ''))) ContractHandler.set_artifacts_path(get_artifacts_path()) if get_network_name().lower() == 'rinkeby': from web3.middleware import geth_poa_middleware Web3Provider.get_web3().middleware_stack.inject(geth_poa_middleware, layer=0) setup_logging() assets = Blueprint('assets', __name__) # Prepare OceanDB dao = Dao(config_file=app.config['CONFIG_FILE']) logger = logging.getLogger('aquarius') @assets.route('', methods=['GET']) def get_assets_ids(): """Get all asset IDs. --- tags: - ddo responses: 200: