Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:gui spam #133

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ovos_bus_client/apis/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def set_bus(self, bus=None):
self._bus = bus or get_mycroft_bus()
self.setup_default_handlers()

@property
def gui_disabled(self) -> bool:
return Configuration().get("gui", {}).get("disable_gui", False)

@property
def bus(self):
"""
Expand Down Expand Up @@ -276,6 +280,8 @@ def gui_set(self, message: Message):
self.on_gui_changed_callback()

def _sync_data(self):
if self.gui_disabled:
return
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved
if not self.bus:
raise RuntimeError("bus not set, did you call self.bind() ?")
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved
data = self.__session_data.copy()
Expand Down Expand Up @@ -322,6 +328,8 @@ def clear(self):
self.__session_data = {}
self._pages = []
self.current_page_idx = -1
if self.gui_disabled:
return
if not self.bus:
raise RuntimeError("bus not set, did you call self.bind() ?")
self.bus.emit(Message("gui.clear.namespace",
Expand All @@ -337,6 +345,8 @@ def send_event(self, event_name: str,
params: json serializable object containing any parameters that
should be sent along with the request.
"""
if self.gui_disabled:
return
params = params or {}
if not self.bus:
raise RuntimeError("bus not set, did you call self.bind() ?")
Expand Down Expand Up @@ -442,6 +452,8 @@ def show_pages(self, page_names: List[str], index: int = 0,
self._pages = page_names
self.current_page_idx = index

if self.gui_disabled:
return
# First sync any data...
data = self.__session_data.copy()
data.update({'__from': self.skill_id})
Expand Down Expand Up @@ -470,6 +482,8 @@ def remove_pages(self, page_names: List[str]):
Request to remove a list of pages from the GUI.
@param page_names: list of page resources requested
"""
if self.gui_disabled:
return
if not self.bus:
raise RuntimeError("bus not set, did you call self.bind() ?")
if isinstance(page_names, str):
Expand All @@ -489,6 +503,8 @@ def remove_all_pages(self, except_pages=None):
Request to remove all pages from the GUI.
@param except_pages: list of optional page resources to keep
"""
if self.gui_disabled:
return
if not self.bus:
raise RuntimeError("bus not set, did you call self.bind() ?")
self.bus.emit(Message("gui.page.delete.all",
Expand Down
Loading