Skip to content

Commit

Permalink
Better exception handling around signal method patching (#479)
Browse files Browse the repository at this point in the history
* catch and handle errors overriding signal methods

* Fix reference error from #478

---------

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Oct 10, 2023
1 parent 75802f0 commit 0673c24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions neon_utils/signal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def init_signal_handlers():
mycroft.util.signal.create_signal = _create_signal
mycroft.util.signal.check_for_signal = _check_for_signal
LOG.info(f"Overrode mycroft.util.signal methods")
except ImportError:
pass
except (ImportError, AttributeError) as e:
LOG.debug(e)
except TypeError as e:
# This comes from tests overriding MessageBusClient()
LOG.error(e)
Expand Down
16 changes: 8 additions & 8 deletions neon_utils/skills/neon_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,41 +850,41 @@ def converse(message):
def translate(self, text: str, data: Optional[dict] = None):
"""
Deprecated method for translating a dialog file.
use self._resources.render_dialog(text, data) instead
use self.resources.render_dialog(text, data) instead
"""
log_deprecation("Use `resources.render_dialog`", "2.0.0")
return self._resources.render_dialog(text, data)
return self.resources.render_dialog(text, data)

# renamed in base class for naming consistency
# refactored to use new resource utils
def translate_namedvalues(self, name: str, delim: str = ','):
"""
Deprecated method for translating a name/value file.
use self._resources.load_named_value_filetext, data) instead
use self.resources.load_named_value_filetext, data) instead
"""
log_deprecation("Use `resources.load_named_value_file`", "2.0.0")
return self._resources.load_named_value_file(name, delim)
return self.resources.load_named_value_file(name, delim)

# renamed in base class for naming consistency
# refactored to use new resource utils
def translate_list(self, list_name: str, data: Optional[dict] = None):
"""
Deprecated method for translating a list.
use delf._resources.load_list_file(text, data) instead
use delf.resources.load_list_file(text, data) instead
"""
log_deprecation("Use `resources.load_list_file`", "2.0.0")
return self._resources.load_list_file(list_name, data)
return self.resources.load_list_file(list_name, data)

# renamed in base class for naming consistency
# refactored to use new resource utils
def translate_template(self, template_name: str,
data: Optional[dict] = None):
"""
Deprecated method for translating a template file
use delf._resources.template_file(text, data) instead
use self.resources.template_file(text, data) instead
"""
log_deprecation("Use `resources.template_file`", "2.0.0")
return self._resources.load_template_file(template_name, data)
return self.resources.load_template_file(template_name, data)

def init_dialog(self, root_directory: Optional[str] = None):
"""
Expand Down

0 comments on commit 0673c24

Please sign in to comment.