Skip to content

Commit 8e1d381

Browse files
Guillaume De Saint MartinGuillaumeDSM
authored andcommitted
[Profiles] ignore bot version from imported profiles
1 parent 0f144c3 commit 8e1d381

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

octobot/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def _load_or_create_tentacles(config, logger):
162162
if os.path.isfile(tentacles_manager_constants.USER_REFERENCE_TENTACLE_CONFIG_FILE_PATH):
163163
config.load_profiles_if_possible_and_necessary()
164164
tentacles_setup_config = tentacles_manager_api.get_tentacles_setup_config(
165-
config.get_tentacles_config_path())
165+
config.get_tentacles_config_path()
166+
)
166167
commands.run_update_or_repair_tentacles_if_necessary(config, tentacles_setup_config)
167168
else:
168169
# when no tentacles folder has been found

octobot/commands.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,36 @@ def _check_tentacles_install_exit():
9292
sys.exit(0)
9393

9494

95-
async def update_or_repair_tentacles_if_necessary(tentacles_setup_config, config):
96-
if not tentacles_manager_api.are_tentacles_up_to_date(tentacles_setup_config, constants.VERSION):
97-
logging.get_logger(COMMANDS_LOGGER_NAME).info("OctoBot tentacles are not up to date. Updating tentacles...")
95+
def _get_first_non_imported_profile_tentacles_setup_config(config):
96+
return tentacles_manager_api.get_tentacles_setup_config(
97+
config.get_non_imported_profiles()[0].get_tentacles_config_path()
98+
)
99+
100+
101+
async def update_or_repair_tentacles_if_necessary(selected_profile_tentacles_setup_config, config):
102+
local_profile_tentacles_setup_config = selected_profile_tentacles_setup_config
103+
logger = logging.get_logger(COMMANDS_LOGGER_NAME)
104+
if config.profile.imported:
105+
if not tentacles_manager_api.are_tentacles_up_to_date(selected_profile_tentacles_setup_config,
106+
constants.VERSION):
107+
selected_profile_tentacles_version = tentacles_manager_api.get_tentacles_installation_version(
108+
selected_profile_tentacles_setup_config
109+
)
110+
logger.warning(f"Current imported profile \"{config.profile.name}\" references tentacles in a different "
111+
f"version from the current OctoBot. Referenced version: "
112+
f"{selected_profile_tentacles_version}, current OctoBot version: {constants.VERSION}. "
113+
f"This profile might not work properly.")
114+
# only update tentacles based on local (non imported) profiles tentacles installation version
115+
local_profile_tentacles_setup_config = _get_first_non_imported_profile_tentacles_setup_config(config)
116+
if not tentacles_manager_api.are_tentacles_up_to_date(local_profile_tentacles_setup_config, constants.VERSION):
117+
logger.info("OctoBot tentacles are not up to date. Updating tentacles...")
98118
_check_tentacles_install_exit()
99119
if await install_or_update_tentacles(config):
100-
logging.get_logger(COMMANDS_LOGGER_NAME).info("OctoBot tentacles are now up to date.")
120+
logger.info("OctoBot tentacles are now up to date.")
101121
elif tentacles_manager_api.load_tentacles(verbose=True):
102-
logging.get_logger(COMMANDS_LOGGER_NAME).debug("OctoBot tentacles are up to date.")
122+
logger.debug("OctoBot tentacles are up to date.")
103123
else:
104-
logging.get_logger(COMMANDS_LOGGER_NAME).info("OctoBot tentacles are damaged. Installing default tentacles ...")
124+
logger.info("OctoBot tentacles are damaged. Installing default tentacles ...")
105125
_check_tentacles_install_exit()
106126
await install_or_update_tentacles(config)
107127

0 commit comments

Comments
 (0)