def write_byte(self, register_address: int, byte_value: int): if byte_value > 0xFF: PTLogger.warning( "Possible unintended overflow writing value to register " + hex(register_address) ) self._bus.write_byte_data( self._device_address, register_address, byte_value)
def write_byte(self, register_address: int, byte_value: int): if byte_value > 0xFF: PTLogger.warning( "Possible unintended overflow writing value to register " + hex(register_address) ) self.write_n_bytes(register_address, [byte_value & 0xFF])
def send_notification(title: str, text: str, icon_name: str = "", timeout: int = 0, app_name: str = "", notification_id: int = -1, actions_manager: NotificationActionManager = None, urgency_level: NotificationUrgencyLevel = None, capture_notification_id: bool = True) -> str: # TODO: check that `pt-notify-send` is available, as it's not a hard dependency of the package cmd = "/usr/bin/pt-notify-send " cmd += "--print-id " cmd += "--expire-time=" + str(timeout) + " " if icon_name: cmd += "--icon=" + icon_name + " " if notification_id >= 0: cmd += "--replace=" + str(notification_id) + " " if actions_manager is not None: for action in actions_manager.actions: cmd += "--action=\"" + action.call_to_action_text + \ ":" + action.command_str + "\" " if actions_manager.default_action is not None: cmd += "--default-action=" + actions_manager.default_action.command_str + " " if actions_manager.close_action is not None: cmd += "--close-action=" + actions_manager.close_action.command_str + " " if app_name: cmd += "--app-name=" + app_name + " " if urgency_level is not None: cmd += "--urgency=" + urgency_level.name + " " cmd += " \"" + title + "\" " cmd += "\"" + text + "\"" PTLogger.info("pt-notify-send command: {}".format(cmd)) try: resp_stdout = run_command(cmd, 2000, capture_output=capture_notification_id) except Exception as e: PTLogger.warning("Failed to show message: {}".format(e)) raise return resp_stdout