From 105e23b187600066706bd22a2478862d6d6e9e2c Mon Sep 17 00:00:00 2001 From: Juergen Weigert Date: Tue, 26 Dec 2023 03:01:51 +0100 Subject: [PATCH] move args.hid check into main(). It has nothing to do in write() --- lednamebadge.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lednamebadge.py b/lednamebadge.py index 69a6c82..f65c71e 100755 --- a/lednamebadge.py +++ b/lednamebadge.py @@ -559,8 +559,6 @@ or LedNameBadge.pyhidapi.hid_write(dev, sendbuf) LedNameBadge.pyhidapi.hid_close(dev) 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) if dev is None: print("No led tag with vendorID 0x0416 and productID 0x5020 found.") @@ -662,6 +660,10 @@ def main(): for msg_bitmap in msg_bitmaps: 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)