def run(self): # detect USB Switchable charger port port = DeviceCharger.detect_charger_port() if port is None: msg = 'None of the ports contains a USB Switchable charger, exiting' logger.error(msg) return # connect to the charger device using its serial interface try: self.charger = Serial(port, 9600, 8, 'N', 1, timeout=0.5) except (OSError, IOError) as e: logger.error(e) return # start charger status watcher charger_watcher = self.start_watcher(self.charger) # command handler command_handler = subscribe(DeviceCharger.COMMAND_CHANNEL, self.on_command) try: while True: time.sleep(0.1) except (SystemExit, KeyboardInterrupt): command_handler.stop() charger_watcher.stop() self.enable_charging(False)
def run(self): try: # message handler handler = subscribe(ReceiptManagerApp.COMMAND_CHANNEL, self.on_message) # main loop while True: time.sleep(0.1) except (SystemExit, KeyboardInterrupt): handler.stop()
def run(self): try: # message handler handler = subscribe( ReceiptManagerApp.COMMAND_CHANNEL, self.on_message ) # main loop while True: time.sleep(0.1) except (SystemExit, KeyboardInterrupt): handler.stop()
def run(self): # message handler handler = subscribe(CardReaderApp.COMMAND_CHANNEL, self.on_message) # detect where the magnetic reader is connected device = MSReader.detect_reader() if device is None: return self.reader = MSReader(device) # main loop try: while True: time.sleep(0.1) except (SystemExit, KeyboardInterrupt): handler.stop() self.reader.close()