Example #1
0
async def manage_tentacles(worker,
                           tentacle_names,
                           tentacles_path_or_url=None,
                           aiohttp_session=None) -> int:
    errors_count = 0
    logger = logging.get_logger(__name__)
    try:
        if tentacles_path_or_url is not None:
            await util.fetch_and_extract_tentacles(
                constants.TENTACLES_INSTALL_TEMP_DIR, tentacles_path_or_url,
                aiohttp_session)
        errors_count = await worker.process(tentacle_names)
    except Exception as e:
        logger.exception(
            e, True,
            f"Exception during {worker.__class__.__name__} processing: {e}")
        # ensure error is taken into account
        if errors_count == 0:
            errors_count = 1
    finally:
        if tentacles_path_or_url is not None:
            util.cleanup_temp_dirs(constants.TENTACLES_INSTALL_TEMP_DIR)
        try:
            # reload tentacles data
            loaders.reload_tentacle_by_tentacle_class()
        except Exception as e:
            logger.exception(e, True,
                             f"Exception while reloading tentacles data: {e}")
            errors_count = 1
    return errors_count
Example #2
0
async def create_minimalist_unconnected_octobot():
    # import here to prevent later web interface import issues
    octobot_instance = octobot.OctoBot(test_config.load_test_config(dict_only=False))
    octobot_instance.initialized = True
    tentacles_config = test_utils_config.load_test_tentacles_config()
    loaders.reload_tentacle_by_tentacle_class()
    octobot_instance.task_manager.async_loop = asyncio.get_event_loop()
    octobot_instance.task_manager.create_pool_executor()
    octobot_instance.tentacles_setup_config = tentacles_config
    octobot_instance.configuration_manager.add_element(octobot_constants.TENTACLES_SETUP_CONFIG_KEY, tentacles_config)
    octobot_instance.exchange_producer = trading_producers.ExchangeProducer(None, octobot_instance, None, False)
    octobot_instance.evaluator_producer = octobot_producers.EvaluatorProducer(None, octobot_instance)
    octobot_instance.evaluator_producer.matrix_id = await evaluator_api.initialize_evaluators(octobot_instance.config, tentacles_config)
    return octobot_instance
async def _init_bot():
    # import here to prevent web interface import issues
    import octobot.octobot as octobot
    import octobot.constants as octobot_constants
    import octobot.producers as producers
    import octobot_commons.tests as test_config
    import octobot_tentacles_manager.loaders as loaders
    import octobot_evaluators.api as evaluators_api
    import tests.test_utils.config as config
    octobot = octobot.OctoBot(test_config.load_test_config(dict_only=False))
    octobot.initialized = True
    tentacles_config = config.load_test_tentacles_config()
    loaders.reload_tentacle_by_tentacle_class()
    octobot.task_manager.async_loop = asyncio.get_event_loop()
    octobot.task_manager.create_pool_executor()
    octobot.tentacles_setup_config = tentacles_config
    octobot.configuration_manager.add_element(octobot_constants.TENTACLES_SETUP_CONFIG_KEY, tentacles_config)
    octobot.exchange_producer = producers.ExchangeProducer(None, octobot, None, False)
    octobot.evaluator_producer = producers.EvaluatorProducer(None, octobot)
    octobot.evaluator_producer.matrix_id = await evaluators_api.initialize_evaluators(octobot.config, tentacles_config)
    # Do not edit config file
    octobot.community_auth.edited_config = None
    return octobot
Example #4
0
def reload_tentacle_info() -> None:
    loaders.reload_tentacle_by_tentacle_class()