move args.hid check into main(). It has nothing to do in write()

rebase020124
Juergen Weigert 11 months ago
parent 5f5340fb29
commit 105e23b187
  1. 6
      lednamebadge.py

@ -559,8 +559,6 @@ or
LedNameBadge.pyhidapi.hid_write(dev, sendbuf) LedNameBadge.pyhidapi.hid_write(dev, sendbuf)
LedNameBadge.pyhidapi.hid_close(dev) LedNameBadge.pyhidapi.hid_close(dev)
else: else:
if args.hid != "0":
sys.exit("HID API access is needed but not initialized. Fix your setup")
dev = LedNameBadge.usb.core.find(idVendor=0x0416, idProduct=0x5020) dev = LedNameBadge.usb.core.find(idVendor=0x0416, idProduct=0x5020)
if dev is None: if dev is None:
print("No led tag with vendorID 0x0416 and productID 0x5020 found.") print("No led tag with vendorID 0x0416 and productID 0x5020 found.")
@ -662,6 +660,10 @@ def main():
for msg_bitmap in msg_bitmaps: for msg_bitmap in msg_bitmaps:
buf.extend(msg_bitmap[0]) buf.extend(msg_bitmap[0])
if not LedNameBadge._have_pyhidapi:
if args.hid != "0":
sys.exit("HID API access is needed but not initialized. Fix your setup")
LedNameBadge.write(buf) LedNameBadge.write(buf)

Loading…
Cancel
Save