def _interactive_connect(): from automator import connector global device try: device = connector.auto_connect() except IndexError: devices = connector.enum_devices() if len(devices) == 0: print("当前无设备连接") raise print("检测到多台设备") for i, (name, *cdr) in enumerate(devices): print("%2d. %s" % (i+1, name)) num = 0 while True: try: num = int(input("请输入序号选择设备: ")) if not 1 <= num < len(devices)+1: raise ValueError() break except ValueError: print("输入不合法,请重新输入") name, cls, args, binding = devices[num-1] device = cls(*args)
def notify_availiable_devices(self): devices = connector.enum_devices() self.devices = devices self.notify("web:availiable-devices", [x[0] for x in devices])
from automator.connector import enum_devices if __name__ == '__main__': from pprint import pprint pprint(enum_devices())