def _scanDevices(self): self.scanning = True while self.scanning: devices = Device.list() scannedDevices = {} if len(devices) > 0: for i, dev in enumerate(devices): try: info = self._registerDevice(dev) scannedDevices[info['serial_number']] = { 'vendorId': info['vendor_id'], 'productId': info['product_id'], 'name': info['product_name'], 'manufacturer': info['manufacturer'], 'device': dev } except ValueError as err: if 'langid' in err.message: print("Can't get device info. Origin Error: %s" % err) self._unregisterDevices({ k: self.devices[k] for k in set(self.devices) - set(scannedDevices) }) GLib.idle_add(self._toggleTray) time.sleep(1)
def do_connect(self, dev_no): """Connect Polar device. Run 'list' to see available devices. Usage: connect <device_no> """ try: dev_no = int(dev_no) except ValueError: print '[!] You need to specify the device number. Run \'list\' to see available devices.' print return try: devs = Device.list() dev = devs[dev_no] serial = Device.get_info(dev)['serial_number'] self.prompt = LoopholeCli.__PROMPT.format(serial) self.device = Device(dev) self.device.open() print '[+] Device connected.' print except IndexError: print '[!] Device not found or failed to open it. Run \'list\' to see available devices.' print
def do_list(self, _): """List available Polar devices. Usage: list """ devs = Device.list() if len(devs) > 0: for i, dev in enumerate(devs): try: info = Device.get_info(dev) except ValueError as err: print "Device no: %i" % i print "Device info:" print dev print "-" * 79 if 'langid' in err.message: raise ValueError( ("Can't get device info. Origin Error: %s\n" "Maybe this is a permission issue.\n" "Please read section 'permission' in README ;)") % err) raise # raise origin error print '{} - {} ({})'.format(i, info['product_name'], info['serial_number']) else: print '[!] No Polar devices found!' print
def do_list(self, _): """List available Polar devices. """ devs = Device.list() if len(devs) > 0: for i, dev in enumerate(devs): print '{} - {} ({})'.format(i, dev.product_name, dev.serial_number) else: print '[!] No Polar devices found!' print
def do_list(self, _): """List available Polar devices. """ devs = Device.list() if len(devs) > 0: for i, dev in enumerate(devs): info = Device.get_info(dev) print '{} - {} ({})'.format(i, info['product_name'], info['serial_number']) else: print '[!] No Polar devices found!' print
def do_list(self, _): """List available Polar devices. Usage: list """ devs = Device.list() if len(devs) > 0: for i, dev in enumerate(devs): info = Device.get_info(dev) print '{} - {} ({})'.format(i, info['product_name'], info['serial_number']) else: print '[!] No Polar devices found!' print
def do_connect(self, dev_no): """Connect Polar device. Run 'list' to see available devices. """ try: dev_no = int(dev_no) devs = Device.list() dev = devs[dev_no] self.prompt = LoopholeCli.__PROMPT.format(dev.serial_number) self.device = Device(dev) print '[+] Device connected.' print except IndexError: print '[!] Device not found. Run \'list\' to see available devices.' print