Skip to content

Commit

Permalink
Manage case when stats["snmp_info"]["Power Off Timer"] does not inclu…
Browse files Browse the repository at this point in the history
…de digits

- Solves File "ui.py", line 2541, in detect_configuration IndexError: list index out of range
- Removes [INFO] Found data: {}.
- improve messages

ref #39
  • Loading branch information
Ircama committed Nov 10, 2024
1 parent 7346b59 commit 2d478e4
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,10 @@ def run_detection():
f"[INFO] Models with same access keys: {rwk_kist}\n"
)

if DETECTED in self.printer.PRINTER_CONFIG:
if (
DETECTED in self.printer.PRINTER_CONFIG
and self.printer.PRINTER_CONFIG[DETECTED]
):
self.status_text.insert(
tk.END,
f'[INFO] Found data: '
Expand Down Expand Up @@ -2371,7 +2374,8 @@ def run_detection():
)
if response:
self.status_text.insert(
tk.END, f"[INFO] Starting the operation, please wait...\n"
tk.END,
f"[INFO] Starting the access key detection, please wait for many minutes...\n"
)
self.config(cursor="watch")
self.update()
Expand Down Expand Up @@ -2469,7 +2473,7 @@ def detect_sequence(eeprom, sequence):
return False
self.status_text.insert(
tk.END,
f"[INFO] Reading EEPROM values, please wait...\n"
f"[INFO] Reading EEPROM values, please wait for some minutes...\n"
)
self.update()
try:
Expand Down Expand Up @@ -2538,14 +2542,18 @@ def detect_sequence(eeprom, sequence):
c += 1

if "Power Off Timer" in stats["snmp_info"] and stats["snmp_info"]["Power Off Timer"]:
po_mins = int(re.findall(r'\d+', stats["snmp_info"]["Power Off Timer"])[0])
msb = po_mins // 256
lsb = po_mins % 256
result = detect_sequence(eeprom, (lsb, msb))
c = 0
for i in result:
conf_data["po_time[%s]" % c] = [i + 1, i]
c += 1
matches = re.findall(r'\d+', stats["snmp_info"]["Power Off Timer"])
if matches:
po_mins = int(matches[0])
msb = po_mins // 256
lsb = po_mins % 256
result = detect_sequence(eeprom, (lsb, msb))
c = 0
for i in result:
conf_data["po_time[%s]" % c] = [i + 1, i]
c += 1
else:
conf_data["po_time"] = None
else:
conf_data["po_time"] = None

Expand Down

0 comments on commit 2d478e4

Please sign in to comment.