From f25e2b06c220c5328a7bb886f1623bfa0364b512 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:40:17 +0000 Subject: [PATCH 1/3] fix: gui extensions homescreen init (#281) * fix: gui extensions homescreen init was passing an extra kwarg improve optional import handling and typing * docstr --- ovos_plugin_manager/templates/gui.py | 45 ++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/ovos_plugin_manager/templates/gui.py b/ovos_plugin_manager/templates/gui.py index e3c020cc..943b86c4 100644 --- a/ovos_plugin_manager/templates/gui.py +++ b/ovos_plugin_manager/templates/gui.py @@ -1,8 +1,26 @@ +from typing import Optional, Dict, Any + from ovos_bus_client import Message from ovos_bus_client import MessageBusClient from ovos_bus_client.apis.gui import GUIInterface -from ovos_utils.log import LOG from ovos_config import Configuration +from ovos_utils.log import LOG + +try: + from ovos_gui.homescreen import HomescreenManager +except ImportError as _exc: + + class HomescreenManager: + """Fallback class when ovos-gui is not installed. + + Raises the original ImportError when instantiated to + provide clear error messaging while still allowing type hints to work. + """ + + def __init__(self, *args, **kwargs): + LOG.error("you seem to be running GUIExtensions without ovos-gui installed...") + # raise the original ImportError + raise _exc class GUIExtension: @@ -20,39 +38,40 @@ class GUIExtension: permanent (bool): disable unloading of GUI skills on gui client disconnections """ - def __init__(self, config, bus=None, gui=None, - preload_gui=False, permanent=False): + def __init__(self, config: Dict[str, Any], + bus: Optional[MessageBusClient] = None, + gui: Optional[GUIInterface] = None, + preload_gui: bool = False, + permanent: bool = False): if not bus: bus = MessageBusClient() bus.run_in_thread() bus.connected_event.wait() - self.bus = bus - self.gui = gui or GUIInterface("ovos.shell", bus=self.bus, - config=Configuration().get("gui", {})) + self.bus: MessageBusClient = bus + self.gui: GUIInterface = gui or GUIInterface("ovos.shell", bus=self.bus, + config=Configuration().get("gui", {})) self.preload_gui = preload_gui self.permanent = permanent self.config = config + self.homescreen_manager: Optional[HomescreenManager] = None self.register_bus_events() def register_bus_events(self): self.bus.on("mycroft.gui.screen.close", self.handle_remove_namespace) - def bind_homescreen(self, homescreen=None): + def bind_homescreen(self, homescreen: Optional[HomescreenManager] = None): if self.config.get("homescreen_supported", False): if not homescreen: - # raise exception as usual if this fails - from ovos_gui.homescreen import HomescreenManager - homescreen = HomescreenManager(self.bus, self.gui) + LOG.debug("Loading HomescreenManager") + homescreen = HomescreenManager(self.bus) homescreen.daemon = True homescreen.start() - self.homescreen_manager = homescreen else: LOG.info("Homescreen support not configured") - def handle_remove_namespace(self, message): - LOG.info("Got Clear Namespace Event In Skill") + def handle_remove_namespace(self, message: Message): get_skill_namespace = message.data.get("skill_id", "") if get_skill_namespace: self.bus.emit(Message("gui.clear.namespace", From 2703c0e95a37c6d55b749f142036806193595329 Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Tue, 5 Nov 2024 00:40:30 +0000 Subject: [PATCH 2/3] Increment Version to 0.5.5a1 --- ovos_plugin_manager/version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ovos_plugin_manager/version.py b/ovos_plugin_manager/version.py index ee505794..4fd60e01 100644 --- a/ovos_plugin_manager/version.py +++ b/ovos_plugin_manager/version.py @@ -1,6 +1,6 @@ # START_VERSION_BLOCK VERSION_MAJOR = 0 VERSION_MINOR = 5 -VERSION_BUILD = 4 -VERSION_ALPHA = 0 +VERSION_BUILD = 5 +VERSION_ALPHA = 1 # END_VERSION_BLOCK From 4aa037ac7f3deecbaf0299966da29661fb9838df Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Tue, 5 Nov 2024 00:40:59 +0000 Subject: [PATCH 3/3] Update Changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ec0c044..faa944f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,12 @@ # Changelog -## [0.5.4a1](https://github.com/OpenVoiceOS/ovos-plugin-manager/tree/0.5.4a1) (2024-10-24) +## [0.5.5a1](https://github.com/OpenVoiceOS/ovos-plugin-manager/tree/0.5.5a1) (2024-11-05) -[Full Changelog](https://github.com/OpenVoiceOS/ovos-plugin-manager/compare/0.5.3...0.5.4a1) +[Full Changelog](https://github.com/OpenVoiceOS/ovos-plugin-manager/compare/0.5.4...0.5.5a1) **Merged pull requests:** -- fix:missing import [\#279](https://github.com/OpenVoiceOS/ovos-plugin-manager/pull/279) ([JarbasAl](https://github.com/JarbasAl)) +- fix: gui extensions homescreen init [\#281](https://github.com/OpenVoiceOS/ovos-plugin-manager/pull/281) ([JarbasAl](https://github.com/JarbasAl))