From 30485235c2671d6a66df1e6de58e93c76e03c94e Mon Sep 17 00:00:00 2001 From: Vishal Date: Mon, 29 Apr 2024 02:19:04 +0530 Subject: [PATCH] Fixing up a few errors for non-internet mode --- index.json | 7 +------ plugin_manager.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/index.json b/index.json index bf97ffa..4871597 100644 --- a/index.json +++ b/index.json @@ -1,12 +1,7 @@ { "plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "1.0.18": { - "api_version": 8, - "commit_sha": "55660d4", - "released_on": "28-04-2024", - "md5sum": "7e3bca2eb19f68e9340c2d3e8622f213" - }, + "1.0.18": null, "1.0.17": { "api_version": 8, "commit_sha": "02530f0", diff --git a/plugin_manager.py b/plugin_manager.py index 9ac6305..2108448 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -104,7 +104,7 @@ REGEXP = { DISCORD_URL = "https://ballistica.net/discord" -_CACHE = {"changelog": "None"} +_CACHE = {} class MD5CheckSumFailed(Exception): @@ -1405,7 +1405,10 @@ class PluginManager: # Rather wait for the previous network call to complete. await asyncio.sleep(0.1) self._changelog_setup_in_progress = not bool(self._changelog) - full_changelog = await self.get_changelog() + try: + full_changelog = await self.get_changelog() + except Exception: + full_changelog = 'Could not get ChangeLog' pattern = rf"### {version} \(\d\d-\d\d-\d{{4}}\)\n(.*?)(?=### \d+\.\d+\.\d+|\Z)" matches = re.findall(pattern, full_changelog, re.DOTALL) if matches: @@ -1457,7 +1460,6 @@ class PluginManager: async def refresh(self): self.cleanup() await self.setup_index() - await self.setup_changelog() def set_index_global_cache(self, index): _CACHE["index"] = index @@ -1733,7 +1735,7 @@ class PluginManagerWindow(bui.Window): def __init__(self, transition: str = "in_right", origin_widget: bui.Widget = None): self.plugin_manager = PluginManager() self.category_selection_button = None - self.selected_category = None + self.selected_category = 'All' self.plugins_in_current_view = {} self.selected_alphabet_order = 'a_z' self.alphabet_order_selection_button = None @@ -1832,6 +1834,7 @@ class PluginManagerWindow(bui.Window): except urllib.error.URLError: bui.textwidget(edit=self._plugin_manager_status_text, text="Make sure you are connected\n to the Internet and try again.") + self.plugin_manager._index_setup_in_progress = False except RuntimeError: # User probably went back before a bui.Window could finish loading. pass @@ -2077,7 +2080,11 @@ class PluginManagerWindow(bui.Window): try: category_plugins = await self.plugin_manager.categories[category if category != 'Installed' else 'All'].get_plugins() except (KeyError, AttributeError): - raise CategoryDoesNotExist(f"{category} does not exist.") + no_internet_text = "Make sure you are connected\n to the Internet and try again." + if bui.textwidget(query=self._plugin_manager_status_text) != no_internet_text: + raise CategoryDoesNotExist(f"{category} does not exist.") + else: + return if search_term: plugins = list(filter( @@ -2184,6 +2191,7 @@ class PluginManagerWindow(bui.Window): with self.exception_handler(): await self.plugin_manager.refresh() + await self.plugin_manager.setup_changelog() await self.plugin_manager.setup_index() bui.textwidget(edit=self._plugin_manager_status_text, text="")