USB设备没有langid

2022-01-18 23:54:35 发布

您现在位置:Python中文网/ 问答频道 /正文

def licence(self, Dialog):
    #try:
    self.dev = usb.core.find(find_all=True)
    #except usb.core.USBError:
    #    OSError("Permission denied, you need to add an udev rule for this device", errno=errno.EACCES)

    if self.dev is None:
        raise IOError("Device not found")
        print(747474747)
    else:
        busses = usb.busses()
        for bus in busses:
            for dev in bus.devices:
                _name = usb.util.get_string(dev.dev, 256, 1033)
                print(_name)
                print("device name=", _name)
                print("  idVendor:", dev.idVendor, hex(dev.idVendor))
                print("  idProduct:", dev.idProduct, hex(dev.idProduct))
                #try:
                printer = getUSBPrinter()(dev.idVendor, idProduct=dev.idProduct)
                printer.set(font='a', codepage='cp1251', size='normal', align='center', bold=True)
                printer.set(align='center')
                printer.text("\t\t\t" + "نام کافی شاپ " + " " + self.lineEdit.text())
                printer.lf()
                    # except Exception as ee:
                #except:
                #    print(10)
                #    continue