Skip to content

Commit

Permalink
[Community] fix cloud tentacles
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Jul 5, 2024
1 parent 5287d6a commit 3bb5d2c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
14 changes: 8 additions & 6 deletions octobot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ async def update_or_repair_tentacles_if_necessary(community_auth, selected_profi
elif force_refresh_tentacles_setup_config:
community_tentacles_packages.refresh_tentacles_setup_config()

# await install_or_update_tentacles(config, additional_tentacles_package_urls) #TMPPP
if local_profile_tentacles_setup_config is None or \
not tentacles_manager_api.are_tentacles_up_to_date(local_profile_tentacles_setup_config, constants.VERSION):
logger.info("OctoBot tentacles are not up to date. Updating tentacles...")
Expand Down Expand Up @@ -175,11 +174,14 @@ async def install_all_tentacles(
async with aiohttp_util.ssl_fallback_aiohttp_client_session(
commons_constants.KNOWN_POTENTIALLY_SSL_FAILED_REQUIRED_URL
) as aiohttp_session:
base_urls = [tentacles_url] + (
constants.ADDITIONAL_TENTACLES_PACKAGE_URL.split(constants.URL_SEPARATOR)
if constants.ADDITIONAL_TENTACLES_PACKAGE_URL else []
)
for url in (base_urls if not only_additional else []) + (additional_tentacles_package_urls or []):
base_urls = [tentacles_url] + community_tentacles_packages.get_env_variable_tentacles_urls()
# avoid duplicates
additional_urls = [
url
for url in (additional_tentacles_package_urls or [])
if url not in base_urls
]
for url in (base_urls if not only_additional else []) + additional_urls:
if url is None:
continue
hide_url = url in additional_tentacles_package_urls
Expand Down
3 changes: 2 additions & 1 deletion octobot/community/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,9 @@ async def _init_community_data(self, fetch_private_data):
self.update_supports(),
self.init_public_data(),
]
if fetch_private_data:
if constants.IS_CLOUD_ENV or fetch_private_data:
coros.append(self.update_selected_bot())
if fetch_private_data:
coros.append(self.fetch_private_data())
if not self.user_account.is_hosting_enabled():
coros.append(self.update_is_hosting_enabled(True))
Expand Down
13 changes: 12 additions & 1 deletion octobot/community/tentacles_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def get_to_install_and_remove_tentacles(
adapt_url_to_bot_version(package_url)
for package_url in community_auth.get_saved_package_urls()
] if community_auth.is_logged_in() else []
to_keep_tentacles = set(
additional_tentacles_package_urls + [
adapt_url_to_bot_version(package_url)
for package_url in get_env_variable_tentacles_urls()
] + get_env_variable_tentacles_urls()
)
was_connected_with_remote_packages = community_auth.was_connected_with_remote_packages()

# do not remove tentacles:
Expand All @@ -72,7 +78,7 @@ def get_to_install_and_remove_tentacles(
to_remove_urls = [
package_url
for package_url in installed_community_package_urls
if package_url not in additional_tentacles_package_urls
if package_url not in to_keep_tentacles
] if can_remove_tentacles else []
if to_remove_urls:
tentacles_manager_api.reload_tentacle_info()
Expand All @@ -98,6 +104,11 @@ def get_to_install_and_remove_tentacles(
return list(set(to_install_urls)), list(set(to_remove_tentacles)), force_refresh_tentacles_setup_config


def get_env_variable_tentacles_urls() -> list[str]:
return constants.ADDITIONAL_TENTACLES_PACKAGE_URL.split(constants.URL_SEPARATOR) \
if constants.ADDITIONAL_TENTACLES_PACKAGE_URL else []


def is_community_tentacle_url(url: str) -> bool:
return constants.COMMUNITY_EXTENSIONS_PACKAGES_IDENTIFIER in url

Expand Down

0 comments on commit 3bb5d2c

Please sign in to comment.