mirror of
https://github.com/Ircama/epson_print_conf.git
synced 2024-10-18 01:00:36 -04:00
parent
2b77c8065a
commit
69a6e9bf06
2 changed files with 26 additions and 12 deletions
|
@ -2636,7 +2636,7 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
if args.read_eeprom:
|
if args.read_eeprom:
|
||||||
print_opt = True
|
print_opt = True
|
||||||
read_list = re.split(',\s*', args.read_eeprom[0])
|
read_list = re.split(r',\s*', args.read_eeprom[0])
|
||||||
for value in read_list:
|
for value in read_list:
|
||||||
try:
|
try:
|
||||||
addr = int(ast.literal_eval(value))
|
addr = int(ast.literal_eval(value))
|
||||||
|
@ -2654,7 +2654,7 @@ if __name__ == "__main__":
|
||||||
quit(1)
|
quit(1)
|
||||||
if args.write_eeprom:
|
if args.write_eeprom:
|
||||||
print_opt = True
|
print_opt = True
|
||||||
read_list = re.split(',\s*|;\s*|\|\s*', args.write_eeprom[0])
|
read_list = re.split(r',\s*|;\s*|\|\s*', args.write_eeprom[0])
|
||||||
for key_val in read_list:
|
for key_val in read_list:
|
||||||
key, val = re.split(':|=', key_val)
|
key, val = re.split(':|=', key_val)
|
||||||
try:
|
try:
|
||||||
|
|
34
ui.py
34
ui.py
|
@ -12,6 +12,7 @@ import ipaddress
|
||||||
import inspect
|
import inspect
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import socket
|
import socket
|
||||||
|
import traceback
|
||||||
|
|
||||||
import black
|
import black
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
@ -617,6 +618,17 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
pass
|
pass
|
||||||
return "break"
|
return "break"
|
||||||
|
|
||||||
|
def handle_printer_error(self, e):
|
||||||
|
self.show_status_text_view()
|
||||||
|
if isinstance(e, TimeoutError):
|
||||||
|
self.status_text.insert(
|
||||||
|
tk.END, f"[ERROR] printer is unreachable or offline."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.status_text.insert(
|
||||||
|
tk.END, f"[ERROR] {e}\n{traceback.format_exc()}"
|
||||||
|
)
|
||||||
|
|
||||||
def get_po_mins(self, cursor=True):
|
def get_po_mins(self, cursor=True):
|
||||||
if cursor:
|
if cursor:
|
||||||
self.config(cursor="watch")
|
self.config(cursor="watch")
|
||||||
|
@ -648,8 +660,12 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
tk.END, f"[INFO] Power off timer: {po_timer} minutes.\n"
|
tk.END, f"[INFO] Power off timer: {po_timer} minutes.\n"
|
||||||
)
|
)
|
||||||
self.po_timer_var.set(po_timer)
|
self.po_timer_var.set(po_timer)
|
||||||
|
except TimeoutError:
|
||||||
|
self.status_text.insert(
|
||||||
|
tk.END, f"[ERROR] printer is unreachable or offline"
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
self.handle_printer_error(e)
|
||||||
finally:
|
finally:
|
||||||
self.config(cursor="")
|
self.config(cursor="")
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
|
@ -697,7 +713,7 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
try:
|
try:
|
||||||
self.printer.write_poweroff_timer(int(po_timer))
|
self.printer.write_poweroff_timer(int(po_timer))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
self.handle_printer_error(e)
|
||||||
else:
|
else:
|
||||||
self.status_text.insert(
|
self.status_text.insert(
|
||||||
tk.END, f"[WARNING] Set Power off timer aborted.\n"
|
tk.END, f"[WARNING] Set Power off timer aborted.\n"
|
||||||
|
@ -741,7 +757,7 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
)
|
)
|
||||||
self.date_entry.set_date(date_string)
|
self.date_entry.set_date(date_string)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
self.handle_printer_error(e)
|
||||||
finally:
|
finally:
|
||||||
self.config(cursor="")
|
self.config(cursor="")
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
|
@ -786,7 +802,7 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
date_string.year, date_string.month, date_string.day
|
date_string.year, date_string.month, date_string.day
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
self.handle_printer_error(e)
|
||||||
else:
|
else:
|
||||||
self.status_text.insert(
|
self.status_text.insert(
|
||||||
tk.END,
|
tk.END,
|
||||||
|
@ -859,8 +875,7 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
# Expand all nodes
|
# Expand all nodes
|
||||||
self.expand_all(self.tree)
|
self.expand_all(self.tree)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.show_status_text_view()
|
self.handle_printer_error(e)
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
|
||||||
finally:
|
finally:
|
||||||
self.config(cursor="")
|
self.config(cursor="")
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
|
@ -917,8 +932,7 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
# Expand all nodes
|
# Expand all nodes
|
||||||
self.expand_all(self.tree)
|
self.expand_all(self.tree)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.show_status_text_view()
|
self.handle_printer_error(e)
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
|
||||||
finally:
|
finally:
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
|
|
||||||
|
@ -951,7 +965,7 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
" Perform a power cycle of the printer now.\n"
|
" Perform a power cycle of the printer now.\n"
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
self.handle_printer_error(e)
|
||||||
else:
|
else:
|
||||||
self.status_text.insert(
|
self.status_text.insert(
|
||||||
tk.END, f"[WARNING] Waste ink levels reset aborted.\n"
|
tk.END, f"[WARNING] Waste ink levels reset aborted.\n"
|
||||||
|
@ -1017,7 +1031,7 @@ class EpsonPrinterUI(tk.Tk):
|
||||||
else:
|
else:
|
||||||
self.status_text.insert(tk.END, "[WARN] No printers found.\n")
|
self.status_text.insert(tk.END, "[WARN] No printers found.\n")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.status_text.insert(tk.END, f"[ERROR] {e}\n")
|
self.handle_printer_error(e)
|
||||||
finally:
|
finally:
|
||||||
self.detect_button.config(state=tk.NORMAL) # enable button after processing
|
self.detect_button.config(state=tk.NORMAL) # enable button after processing
|
||||||
self.config(cursor="")
|
self.config(cursor="")
|
||||||
|
|
Loading…
Reference in a new issue