def list_devices(self): if os.name == 'posix': iterator = sorted(serial_list_ports.grep('tty')) else: iterator = sorted(serial_list_ports.grep('')) for port, desc, hwid in iterator: print "%-20s" % (port,) print " desc: %s" % (desc,) print " hwid: %s" % (hwid,)
def match_device(self, search_regex): matched_ports = serial_list_ports.grep(search_regex) if matched_ports: for match_tuple in matched_ports: if match_tuple: return match_tuple[0] print "No serial port match for anything like: " + search_regex return None