mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
Hide plugins with no compatible API
This commit is contained in:
parent
6c5c26105d
commit
06a21d2c78
1 changed files with 21 additions and 2 deletions
|
|
@ -52,6 +52,10 @@ class CategoryDoesNotExistError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NoCompatibleVersionError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def send_network_request(request):
|
def send_network_request(request):
|
||||||
return urllib.request.urlopen(request)
|
return urllib.request.urlopen(request)
|
||||||
|
|
||||||
|
|
@ -594,6 +598,10 @@ class Plugin:
|
||||||
CURRENT_TAG if self.latest_version.number == number else None
|
CURRENT_TAG if self.latest_version.number == number else None
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
if self._latest_compatible_version is None:
|
||||||
|
raise NoCompatibleVersionError(
|
||||||
|
f"{self.name} has no version compatible with API {ba.app.api_version}."
|
||||||
|
)
|
||||||
return self._latest_compatible_version
|
return self._latest_compatible_version
|
||||||
|
|
||||||
def get_local(self):
|
def get_local(self):
|
||||||
|
|
@ -614,7 +622,12 @@ class Plugin:
|
||||||
ba.screenmessage(f"{self.name} uninstalled", color=(0, 1, 0))
|
ba.screenmessage(f"{self.name} uninstalled", color=(0, 1, 0))
|
||||||
|
|
||||||
def has_update(self):
|
def has_update(self):
|
||||||
return self.get_local().version != self.latest_compatible_version.number
|
try:
|
||||||
|
latest_compatible_version = self.latest_compatible_version
|
||||||
|
except NoCompatibleVersionError:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return self.get_local().version != latest_compatible_version.number
|
||||||
|
|
||||||
async def update(self):
|
async def update(self):
|
||||||
if await self.latest_compatible_version.install(suppress_screenmessage=True):
|
if await self.latest_compatible_version.install(suppress_screenmessage=True):
|
||||||
|
|
@ -1467,12 +1480,18 @@ class PluginManagerWindow(ba.Window):
|
||||||
await asyncio.gather(*plugin_names_to_draw)
|
await asyncio.gather(*plugin_names_to_draw)
|
||||||
|
|
||||||
async def draw_plugin_name(self, plugin):
|
async def draw_plugin_name(self, plugin):
|
||||||
|
try:
|
||||||
|
latest_compatible_version = plugin.latest_compatible_version
|
||||||
|
except NoCompatibleVersionError:
|
||||||
|
# We currently don't show plugins that have no compatible versions.
|
||||||
|
return
|
||||||
|
|
||||||
if plugin.is_installed:
|
if plugin.is_installed:
|
||||||
local_plugin = plugin.get_local()
|
local_plugin = plugin.get_local()
|
||||||
if await local_plugin.is_enabled():
|
if await local_plugin.is_enabled():
|
||||||
if not local_plugin.is_installed_via_plugin_manager:
|
if not local_plugin.is_installed_via_plugin_manager:
|
||||||
color = (0.8, 0.2, 0.2)
|
color = (0.8, 0.2, 0.2)
|
||||||
elif local_plugin.version == plugin.latest_compatible_version.number:
|
elif local_plugin.version == latest_compatible_version.number:
|
||||||
color = (0, 1, 0)
|
color = (0, 1, 0)
|
||||||
else:
|
else:
|
||||||
color = (1, 0.6, 0)
|
color = (1, 0.6, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue