diff --git a/not1mm/__main__.py b/not1mm/__main__.py index caf1d8f..34e021a 100644 --- a/not1mm/__main__.py +++ b/not1mm/__main__.py @@ -2024,8 +2024,19 @@ def keyPressEvent(self, event) -> None: # pylint: disable=invalid-name Returns: ------- None + + Control + QWRTYIOPSFGHJLBNM,./;'[]//- + + + shift control + ABCDEFGHIJKLMNOPQRSTUVWXY """ modifier = event.modifiers() + # the_key = event.key() + + # print(f"Modifier is {modifier=} Key is {the_key=}") + if ( event.key() == Qt.Key.Key_Equal and modifier == Qt.KeyboardModifier.ControlModifier diff --git a/not1mm/lib/cat_interface.py b/not1mm/lib/cat_interface.py index 2888e06..a8f826a 100644 --- a/not1mm/lib/cat_interface.py +++ b/not1mm/lib/cat_interface.py @@ -81,7 +81,11 @@ def __init__(self, interface: str, host: str, port: int) -> None: } if self.interface == "flrig": - target = f"http://{host}:{port}" + if not self.__check_sane_ip(self.host): + self.online = False + return + + target = f"http://{self.host}:{self.port}" logger.debug("%s", target) self.server = xmlrpc.client.ServerProxy(target) self.online = True @@ -91,15 +95,30 @@ def __init__(self, interface: str, host: str, port: int) -> None: ConnectionRefusedError, xmlrpc.client.Fault, http.client.BadStatusLine, + socket.error, + socket.gaierror, ): self.online = False elif self.interface == "rigctld": + if not self.__check_sane_ip(self.host): + self.online = False + return self.__initialize_rigctrld() elif self.interface == "fake": self.online = True logger.debug("Using Fake Rig") return + def __check_sane_ip(self, ip: str) -> bool: + """check if IP address look normal""" + x = ip.split() + if len(x) != 4: + return False + for y in x: + if not y.isnumeric(): + return False + return True + def __initialize_rigctrld(self): try: self.rigctrlsocket = socket.socket() @@ -107,7 +126,13 @@ def __initialize_rigctrld(self): self.rigctrlsocket.connect((self.host, self.port)) logger.debug("Connected to rigctrld") self.online = True - except (ConnectionRefusedError, TimeoutError, OSError) as exception: + except ( + ConnectionRefusedError, + TimeoutError, + OSError, + socket.error, + socket.gaierror, + ) as exception: self.rigctrlsocket = None self.online = False logger.debug("%s", f"{exception}") @@ -233,6 +258,7 @@ def __getvfo_flrig(self) -> str: http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug(f"{exception=}") @@ -280,6 +306,7 @@ def __getmode_flrig(self) -> str: http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug("%s", f"{exception}") @@ -329,6 +356,7 @@ def __getbw_flrig(self): http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug("getbw_flrig: %s", f"{exception}") @@ -453,6 +481,7 @@ def __get_mode_list_flrig(self): http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug("%s", f"{exception}") @@ -502,6 +531,7 @@ def __setvfo_flrig(self, freq: str) -> bool: http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug("setvfo_flrig: %s", f"{exception}") @@ -547,6 +577,7 @@ def __setmode_flrig(self, mode: str) -> bool: http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug(f"{exception=}") @@ -590,6 +621,7 @@ def __setpower_flrig(self, power): http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug("setpower_flrig: %s", f"{exception}") @@ -648,6 +680,7 @@ def __ptt_on_flrig(self): http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug("%s", f"{exception}") @@ -686,6 +719,7 @@ def __ptt_off_flrig(self): http.client.BadStatusLine, http.client.CannotSendRequest, http.client.ResponseNotReady, + AttributeError, ) as exception: self.online = False logger.debug("%s", f"{exception}")