aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-09-23 23:44:04 -0400
committerB. Stack <bgstack15@gmail.com>2024-09-23 23:44:04 -0400
commit446842b991fd02718907b57bd5bf4d5369b0c00e (patch)
tree00b22e2a14ff0ba4f5295c3baf460495d5979c68
parentprogress for day (diff)
downloadfprintd-tk-446842b991fd02718907b57bd5bf4d5369b0c00e.tar.gz
fprintd-tk-446842b991fd02718907b57bd5bf4d5369b0c00e.tar.bz2
fprintd-tk-446842b991fd02718907b57bd5bf4d5369b0c00e.zip
initial protection against empty response from get_enrolled_fingers
-rwxr-xr-xfprintd_tk.py11
-rw-r--r--fprintd_tk_lib.py4
2 files changed, 13 insertions, 2 deletions
diff --git a/fprintd_tk.py b/fprintd_tk.py
index 3e815a6..a2cfd99 100755
--- a/fprintd_tk.py
+++ b/fprintd_tk.py
@@ -100,7 +100,16 @@ 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?
- self.enrolled_fingers = lib.get_enrolled_fingers()
+ try:
+ self.old_enrolled_fingers = self.enrolled_fingers
+ except:
+ # will happen if self.enrolled_fingers is not present
+ self.old_enrolled_fingers = []
+ temp1 = lib.get_enrolled_fingers()
+ if temp1:
+ self.enrolled_fingers = temp1
+ else:
+ print(f"DEBUG (load_data_into_form): having to skip empty response from get_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:
diff --git a/fprintd_tk_lib.py b/fprintd_tk_lib.py
index f4947ec..bd8b145 100644
--- a/fprintd_tk_lib.py
+++ b/fprintd_tk_lib.py
@@ -34,12 +34,14 @@ def get_enrolled_fingers(user = None):
if fre.match(line):
#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="")
pass
return enrolled_fingers
-# WORKHERE: count duplicate lines as before, and also save last line, so we can prepend "succeeded"?
def fprintd_action(action, finger, status_function = None, user = None):
if user is None:
user = _user
bgstack15