def safe_schedule_call(method): try: method() except Exception as e: Printer.write(e) return False return True
def get_driver_status(self): try: self._serial_port_manager.send_and_receive(StatusMessage()) return True except ATErrorException: Printer.write('Received AT+ERROR') return False
def handle_async_message(cls, message): callbacks = ( call for pattern, call in cls._message_to_callback_map.iteritems() if message.find(pattern) != -1) called = False for callback in callbacks: callback(message) called = True if not called: Printer.write("Unhandled async message: " + message)
def set_temperature_settings(self, temperature): Printer.write('set_temperature_settings: ') Printer.write(temperature) try: self._current_settings.temperature.update_temperature_manual(temperature) return True except ATErrorException: Printer.write('Received AT+ERROR') return False
def compare_values(self, float_first_value, float_second_value) -> str: if self.compare_bigger(float_first_value, float_second_value): return Printer.print_bigger(Printer(), float_first_value, float_second_value) elif self.compare_equal(float_first_value, float_second_value): return Printer.print_equal(Printer(), float_first_value, float_second_value) else: return Printer.print_smaller(Printer(), float_first_value, float_second_value)
def _verbose(args): Printer.set_print(args.verbose)
def list_schedule_task(self): Printer.write('list_schedule_task') return self._scheduler.list_tasks()
def remove_schedule_task(self, task): Printer.write('remove_schedule_task: ') Printer.write(task) return safe_schedule_call(partial(self._scheduler.remove_task, task))
def update_schedule_task(self, tasks): Printer.write('update_schedule_task: ') Printer.write(tasks) return safe_schedule_call(partial(self._scheduler.update_task, tasks))
def add_schedule_task(self, task): Printer.write('add_schedule_task: ') Printer.write(task) return safe_schedule_call(partial(self._scheduler.add_task, task))
def get_temperature_history(self): Printer.write('get_temperature_history') return self._temp_history.get_list()
def get_temperature_status(self): Printer.write('get_temperature_status') temp_status = self._serial_port_manager.send_and_receive( TemperatureGetMessage()) self._current_status.update(temp_status) return temp_status
def set_manual_mode(self, manual_mode): Printer.write('set_manual_mode') self._current_settings.manual_mode.update(manual_mode) return True
def get_manual_mode(self): Printer.write('get_manual_mode') return self._current_settings.manual_mode.value
def get_temperature_settings(self): Printer.write('get_temperature_settings') return self._current_settings.temperature.value