diff options
-rwxr-xr-x | fprintd_tk.py | 37 | ||||
-rw-r--r-- | fprintd_tk_lib.py | 4 |
2 files changed, 36 insertions, 5 deletions
diff --git a/fprintd_tk.py b/fprintd_tk.py index a2cfd99..9af4513 100755 --- a/fprintd_tk.py +++ b/fprintd_tk.py @@ -6,7 +6,7 @@ # References: # stackrpms_tk.py # Improve: -# flash the newly enrolled finger, and/or the failed verify on a finger. +# if user can control other users' fingerprints, then show a drop-down of users? import tkinter as tk, os, tkinter.simpledialog, sys, threading, time import tkstackrpms as stk @@ -48,6 +48,7 @@ class App(tk.Frame): menu.add_cascade(label="Help",menu=menu_help,underline=0) self.master.config(menu=menu) self.grid() # use this instead of pack() + self.background_color = self.master.cget("bg") # statusbar variable self.statustext = tk.StringVar() @@ -63,6 +64,7 @@ class App(tk.Frame): self.frm_actions = tk.Frame(self.master) self.frm_actions.grid(row=0,column=0) self.action = tk.IntVar(value=1) + self.last_fingerbutton_used = tk.StringVar() stk.Radiobutton(self.frm_actions,value=1,text="enroll",variable=self.action,underline=0).grid(row=0,column=0) stk.Radiobutton(self.frm_actions,value=2,text="verify",variable=self.action,underline=0).grid(row=1,column=0) @@ -99,7 +101,6 @@ class App(tk.Frame): def load_data_into_form(self): time.sleep(0.05) - # WORKHERE: if the fprintd-list fails because the device is open, we will want to keep the old enrolled_fingers list. maybe check if statustext contains "failed to open" or whatever the message is. if it does, do not update the self.enrolled_fingers? try: self.old_enrolled_fingers = self.enrolled_fingers except: @@ -110,6 +111,7 @@ class App(tk.Frame): self.enrolled_fingers = temp1 else: print(f"DEBUG (load_data_into_form): having to skip empty response from get_enrolled_fingers") + self.func_update_status("Unable to update enrolled fingers.") print(f"DEBUG (load_data_into_form): got enrolled fingers {self.enrolled_fingers}") for i in self.fingers: if str(i.cget('text')) in self.enrolled_fingers: @@ -137,6 +139,7 @@ class App(tk.Frame): except ValueError: action_str = "OFF" if action_str in available_actions: + self.last_fingerbutton_used.set(finger) try: t1 = threading.Thread(target=lib.fprintd_action, args=(action_str, finger, self.func_update_status)) t1.start() @@ -151,8 +154,36 @@ class App(tk.Frame): def func_update_status(self, msg): msg = msg.strip() - print(f"DEBUG (func_update_status: msg {msg}",file=sys.stderr) + print(f"DEBUG (func_update_status): msg {msg}",file=sys.stderr) self.statustext.set(msg) + try: + this_finger = [i for i in self.fingers if i.cget("text") == self.last_fingerbutton_used.get()][0] + except Exception as e: + this_finger = None + print(f"DEBUG (func_update_status): while evaluating last-used finger, got {e}") + # flash these red + failure_messages = [ + "enroll-duplicate", + "verify-no-match" + ] + # flash these green + success_messages = [ + "verify-match", + "enroll-completed" + ] + flashed = False + for i in failure_messages: + if i in msg: + flashed = True + if this_finger: + stk.flash_entry(this_finger,["red",self.background_color]*3,300) + break + if not flashed: + for i in success_messages: + if i in msg: + if this_finger: + stk.flash_entry(this_finger,["green",self.background_color]*3,300) + break self.load_data_into_form() def func_delete(self): diff --git a/fprintd_tk_lib.py b/fprintd_tk_lib.py index bd8b145..137a606 100644 --- a/fprintd_tk_lib.py +++ b/fprintd_tk_lib.py @@ -13,7 +13,8 @@ fre = re.compile ("^.* - #[0-9]+: ([^ ]+)$") prevent_success_messages = [ "no-match", "failed to claim", - "not enrolled for user" + "not enrolled for user", + "enroll-duplicate" ] def get_enrolled_fingers(user = None): @@ -35,7 +36,6 @@ def get_enrolled_fingers(user = None): #print(f"Got {fre.match(line).groups()[0]}") enrolled_fingers.append(fre.match(line).groups()[0].strip()) elif re.match("^.*No devices available.*", line): - # WORKHERE: we should rerun the program in a second or two return [] else: #print(f"Not-matching: {line}",end="") |