Fixing up a few errors for non-internet mode

This commit is contained in:
Vishal 2024-04-29 02:19:04 +05:30 committed by GitHub
parent c0a35b0803
commit 30485235c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 11 deletions

View file

@ -1,12 +1,7 @@
{ {
"plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py",
"versions": { "versions": {
"1.0.18": { "1.0.18": null,
"api_version": 8,
"commit_sha": "55660d4",
"released_on": "28-04-2024",
"md5sum": "7e3bca2eb19f68e9340c2d3e8622f213"
},
"1.0.17": { "1.0.17": {
"api_version": 8, "api_version": 8,
"commit_sha": "02530f0", "commit_sha": "02530f0",

View file

@ -104,7 +104,7 @@ REGEXP = {
DISCORD_URL = "https://ballistica.net/discord" DISCORD_URL = "https://ballistica.net/discord"
_CACHE = {"changelog": "None"} _CACHE = {}
class MD5CheckSumFailed(Exception): class MD5CheckSumFailed(Exception):
@ -1405,7 +1405,10 @@ class PluginManager:
# Rather wait for the previous network call to complete. # Rather wait for the previous network call to complete.
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
self._changelog_setup_in_progress = not bool(self._changelog) self._changelog_setup_in_progress = not bool(self._changelog)
try:
full_changelog = await self.get_changelog() 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)" pattern = rf"### {version} \(\d\d-\d\d-\d{{4}}\)\n(.*?)(?=### \d+\.\d+\.\d+|\Z)"
matches = re.findall(pattern, full_changelog, re.DOTALL) matches = re.findall(pattern, full_changelog, re.DOTALL)
if matches: if matches:
@ -1457,7 +1460,6 @@ class PluginManager:
async def refresh(self): async def refresh(self):
self.cleanup() self.cleanup()
await self.setup_index() await self.setup_index()
await self.setup_changelog()
def set_index_global_cache(self, index): def set_index_global_cache(self, index):
_CACHE["index"] = index _CACHE["index"] = index
@ -1733,7 +1735,7 @@ class PluginManagerWindow(bui.Window):
def __init__(self, transition: str = "in_right", origin_widget: bui.Widget = None): def __init__(self, transition: str = "in_right", origin_widget: bui.Widget = None):
self.plugin_manager = PluginManager() self.plugin_manager = PluginManager()
self.category_selection_button = None self.category_selection_button = None
self.selected_category = None self.selected_category = 'All'
self.plugins_in_current_view = {} self.plugins_in_current_view = {}
self.selected_alphabet_order = 'a_z' self.selected_alphabet_order = 'a_z'
self.alphabet_order_selection_button = None self.alphabet_order_selection_button = None
@ -1832,6 +1834,7 @@ class PluginManagerWindow(bui.Window):
except urllib.error.URLError: except urllib.error.URLError:
bui.textwidget(edit=self._plugin_manager_status_text, bui.textwidget(edit=self._plugin_manager_status_text,
text="Make sure you are connected\n to the Internet and try again.") text="Make sure you are connected\n to the Internet and try again.")
self.plugin_manager._index_setup_in_progress = False
except RuntimeError: except RuntimeError:
# User probably went back before a bui.Window could finish loading. # User probably went back before a bui.Window could finish loading.
pass pass
@ -2077,7 +2080,11 @@ class PluginManagerWindow(bui.Window):
try: try:
category_plugins = await self.plugin_manager.categories[category if category != 'Installed' else 'All'].get_plugins() category_plugins = await self.plugin_manager.categories[category if category != 'Installed' else 'All'].get_plugins()
except (KeyError, AttributeError): except (KeyError, AttributeError):
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.") raise CategoryDoesNotExist(f"{category} does not exist.")
else:
return
if search_term: if search_term:
plugins = list(filter( plugins = list(filter(
@ -2184,6 +2191,7 @@ class PluginManagerWindow(bui.Window):
with self.exception_handler(): with self.exception_handler():
await self.plugin_manager.refresh() await self.plugin_manager.refresh()
await self.plugin_manager.setup_changelog()
await self.plugin_manager.setup_index() await self.plugin_manager.setup_index()
bui.textwidget(edit=self._plugin_manager_status_text, bui.textwidget(edit=self._plugin_manager_status_text,
text="") text="")