diff --git a/neon_utils/hana_utils.py b/neon_utils/hana_utils.py index 3ed0204f..e113c8b8 100644 --- a/neon_utils/hana_utils.py +++ b/neon_utils/hana_utils.py @@ -162,9 +162,14 @@ def request_backend(endpoint: str, request_data: dict, except ServerException as e: LOG.error(e) _get_token(server_url) - resp = requests.post(f"{server_url}/{endpoint.lstrip('/')}", - json=request_data, headers=_headers) + request_kwargs = {"url": f"{server_url}/{endpoint.lstrip('/')}", + "json": request_data, "headers": _headers} + resp = requests.post(**request_kwargs) + if resp.status_code == 502: + # This is raised occasionally on valid requests. Need to resolve in HANA + resp = requests.post(**request_kwargs) if resp.ok: return resp.json() + else: raise ServerException(f"Error response {resp.status_code}: {resp.text}") diff --git a/neon_utils/mq_utils.py b/neon_utils/mq_utils.py index 08163eb5..a598d74f 100644 --- a/neon_utils/mq_utils.py +++ b/neon_utils/mq_utils.py @@ -49,7 +49,7 @@ logging.getLogger("pika").setLevel(logging.CRITICAL) _default_mq_config = { - "server": "api.neon.ai", + "server": "mq.neonaiservices.com", "port": 5672, "users": { "mq_handler": { diff --git a/neon_utils/skills/kiosk_skill.py b/neon_utils/skills/kiosk_skill.py index ac8b9793..16247556 100644 --- a/neon_utils/skills/kiosk_skill.py +++ b/neon_utils/skills/kiosk_skill.py @@ -198,8 +198,7 @@ def stop(self): if user in self._active_users: self.end_interaction(message) - def _on_event_error(self, error, message, handler_info, - skill_data, speak_errors): + def _on_event_error(self, error, message, *args, **kwargs): """ Override error handling to speak custom exception for active sessions """ @@ -208,5 +207,4 @@ def _on_event_error(self, error, message, handler_info, LOG.exception(error) self.handle_error(message) else: - super()._on_event_error(error, message, handler_info, - skill_data, speak_errors) + super()._on_event_error(error, message, *args, **kwargs) diff --git a/neon_utils/skills/neon_fallback_skill.py b/neon_utils/skills/neon_fallback_skill.py index 516857e8..6becaed8 100644 --- a/neon_utils/skills/neon_fallback_skill.py +++ b/neon_utils/skills/neon_fallback_skill.py @@ -875,23 +875,3 @@ def init_dialog(self, root_directory: Optional[str] = None): """ log_deprecation("Use `load_dialog_files`", "2.0.0") self.load_dialog_files(root_directory) - - def add_event(self, name: str, handler: callable, - handler_info: Optional[str] = None, once: bool = False, - speak_errors: bool = True): - # TODO: Remove with ovos-workshop==0.0.13 - try: - # Patching FakeBus compat. with MessageBusClient - if hasattr(self.bus, "ee"): - emitter = self.bus.ee - else: - emitter = self.bus.emitter - if handler_info == "mycroft.skill.handler" and \ - emitter.listeners(name): - LOG.warning(f"Not re-registering intent handler {name}") - return - except Exception as e: - LOG.exception(e) - OVOSSkill.add_event(self, name, handler, handler_info, once, - speak_errors) - diff --git a/tests/neon_skill_tests.py b/tests/neon_skill_tests.py index a2c48f3b..514132ab 100644 --- a/tests/neon_skill_tests.py +++ b/tests/neon_skill_tests.py @@ -759,7 +759,7 @@ def is_valid(_): test_results["validator"] = True return False - on_fail = Mock() + on_fail = Mock(return_value="fail") def skill_response_thread(s: MycroftSkill, idx: str): resp = s.get_response(test_dialog, validator=is_valid, diff --git a/tests/net_util_tests.py b/tests/net_util_tests.py index 3f6c0048..9be1faa7 100644 --- a/tests/net_util_tests.py +++ b/tests/net_util_tests.py @@ -33,6 +33,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +TCP_TEST = "mq.neonaiservices.com" + class NetUtilTests(unittest.TestCase): @classmethod @@ -119,18 +121,18 @@ def mock_socket(*args, **kwargs): def test_check_url_connection_invalid_url(self): from neon_utils.net_utils import check_url_response - self.assertFalse(check_url_response("https://api.neon.ai")) + self.assertFalse(check_url_response(f"https://{TCP_TEST}")) def test_check_online_valid_online(self): from neon_utils.net_utils import check_online self.assertTrue(check_online()) self.assertTrue(check_online(("google.com", "github.com"))) - self.assertTrue(check_online(("api.neon.ai", "google.com"))) + self.assertTrue(check_online((TCP_TEST, "google.com"))) self.assertTrue(check_online(("", "google.com"))) def test_check_online_invalid_offline(self): from neon_utils.net_utils import check_online - self.assertFalse(check_online(("api.neon.ai",))) + self.assertFalse(check_online((TCP_TEST,))) self.assertFalse(check_online(("",))) def test_check_online_valid_offline(self): @@ -152,7 +154,7 @@ def test_check_online_invalid_params(self): def test_check_port_is_open(self): from neon_utils.net_utils import check_port_is_open - self.assertTrue(check_port_is_open("api.neon.ai", 5672)) + self.assertTrue(check_port_is_open(TCP_TEST, 5672)) self.assertFalse(check_port_is_open("www.neon.ai", 5672))