Skip to content

Commit

Permalink
Fix local system resource resolution (#20)
Browse files Browse the repository at this point in the history
* Add logging to troubleshoot resource resolution

* Add logging to troubleshoot missing GUI display

* Fix typo in local system GUI page resolution with unit test
  • Loading branch information
NeonDaniel authored Jul 19, 2023
1 parent d65cf2a commit 0aba666
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions ovos_gui/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def send_gui_pages(self, pages: List[GuiPage], namespace: str,
"data": [{"url": page.get_uri(framework, server_url)}
for page in pages]
}
LOG.debug(f"Showing pages: {message['data']}")
self.send(message)

def send(self, data: dict):
Expand Down
7 changes: 6 additions & 1 deletion ovos_gui/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ def _add_pages(self, new_pages: List[GuiPage]):
# Find position of new page in self.pages
position = self.pages.index(new_pages[0])
for client in GUIWebsocketHandler.clients:
client.send_gui_pages(new_pages, self.skill_id, position)
try:
LOG.debug(f"Updating {client.framework} client")
client.send_gui_pages(new_pages, self.skill_id, position)
except Exception as e:
LOG.exception(f"Error updating {client.framework} client: {e}")

def _activate_page(self, page: GuiPage):
"""
Expand Down Expand Up @@ -507,6 +511,7 @@ def handle_gui_pages_available(self, message: Message):
LOG.debug("No GUI file server running")
return

LOG.debug(f"Requesting resources for {self._connected_frameworks}")
for framework in self._connected_frameworks:
skill_id = message.data.get("skill_id")
self.core_bus.emit(message.reply("gui.request_page_upload",
Expand Down
3 changes: 2 additions & 1 deletion ovos_gui/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def get_uri(self, framework: str = "qt5", server_url: str = None) -> str:
if isfile(file_path):
return file_path
# Check system resources
file_path = join(dirname(__file__), "res", "gui", framework)
file_path = join(dirname(__file__), "res", "gui", framework,
res_filename)
if isfile(file_path):
return file_path
raise FileNotFoundError(f"Unable to resolve resource file for "
Expand Down
6 changes: 6 additions & 0 deletions test/unittests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def test_gui_page_from_local_path(self):
qt6 = qt6_page.get_uri("qt6")
self.assertTrue(isfile(qt6))

# System page
system_page = GuiPage(None, "SYSTEM_ImageFrame", False, 30,
"SYSTEM_ImageFrame", namespace, res_dirs)
qt5 = system_page.get_uri("qt5")
self.assertTrue(isfile(qt5))

# Legacy GUI File organization
res_dirs = {"qt5": join(dirname(__file__), "mock_data", "gui", "qt5"),
"qt6": join(dirname(__file__), "mock_data", "gui", "qt6")}
Expand Down

0 comments on commit 0aba666

Please sign in to comment.