Add user interface (#6)

- Add user interface
- Add L386
- Fix pysnmp for newer python versions
- Add requirements.txt
- Add printer discovery script
- Add UI script
- Fix ping opening window in pyinstaller exe
- remove scapy from requirements.txt
- improve comment formatting
- scan all local ips
- Fix power off timer write function
- Update L386 config
This commit is contained in:
Mareks
2024-07-20 14:40:38 +03:00
committed by GitHub
parent 1237c71ab8
commit befa212a4f
4 changed files with 256 additions and 2 deletions

View File

@@ -16,7 +16,17 @@ import logging
import os
import yaml
from pathlib import Path
# The pysnmp module uses functionality from importlib.util and
# importlib.machinery, which were seperated from the importlib module
# in python>=3.11
try:
import importlib.util
import importlib.machinery
except ImportError:
pass
from pysnmp.hlapi.v1arch import *
from pyasn1.type.univ import OctetString as OctetStringType
from itertools import chain
@@ -25,6 +35,39 @@ class EpsonPrinter:
"""SNMP Epson Printer Configuration."""
PRINTER_CONFIG = { # Known Epson models
"L386": {
"read_key": [16, 8],
"write_key": b"Sinabung",
"printer_head_id_h": range(122, 126),
"printer_head_id_f": [129],
"main_waste": {"oids": [24, 25, 30], "divider": 62.07},
"borderless_waste": {"oids": [26, 27, 34], "divider": 24.2},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, # Data of 1st counter
28: 0, 29: 0, # another store of 1st counter
46: 94, # Maintenance required level of 1st counter
26: 0, 27: 0, 34: 0, # Data of 2nd counter
47: 94, # Maintenance required level of 2nd counter
49: 0 # ?
},
"stats": {
"Manual cleaning counter": [147],
"Timer cleaning counter": [149],
"Power cleaning counter": [148],
"Total print pass counter": [171, 170, 169, 168],
"Total print page counter": [167, 166, 165, 164],
"Total scan counter": [471, 470, 469, 468],
"First TI received time": [173, 172],
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47],
"Power off timer": [359, 358],
},
"serial_number": range(192, 202),
"last_printer_fatal_errors": [
453, 452, 455, 454, 457, 456, 459, 458, 461, 460, 467,
499, 498, 501, 500, 503, 502, 505, 504, 507, 506
],
},
"XP-205": {
"alias": ["XP-200", "XP-207"],
"read_key": [25, 7],
@@ -1702,8 +1745,8 @@ class EpsonPrinter:
logging.error("EpsonPrinter - invalid API usage")
return None
try:
msb = self.parm["stats"]["poweroff_timer"][0]
lsb = self.parm["stats"]["poweroff_timer"][1]
msb = self.parm["stats"]["Power off timer"][0]
lsb = self.parm["stats"]["Power off timer"][1]
except KeyError:
logging.info("write_poweroff_timer: missing parameter")
return False