mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 15:43:06 +02:00
Split diet_guard/_gatelock.py, wake_alarm/_alarm.py, and the usage_report.py/_usage_report_parsing.py pair into focused sub-modules so every Python file is <= 500 lines, satisfying test_file_length.py. Install python-kasa into .venv (declared in requirements but missing after the 3.13->3.14 venv upgrade), fixing 8 failing smart_plug tests and restoring 100% coverage. Also includes prior in-progress work from the working tree: the wake_alarm Progress/View/Hardware field-grouping refactor, brother_printer query module + tests, diet_guard foodbank/state/cli updates, new shared coerce/logging_setup helpers, morning_routine orchestrator tweaks, dwm window-manager config, gaming scripts, and misc maintenance/digital-wellbeing script updates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
108 lines
2.3 KiB
Python
108 lines
2.3 KiB
Python
"""Data classes for Brother printer status information."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
@dataclass
|
|
class CUPSJob:
|
|
"""A single CUPS print job."""
|
|
|
|
job_id: str
|
|
user: str
|
|
size: str
|
|
date: str
|
|
|
|
|
|
@dataclass
|
|
class CUPSQueueStatus:
|
|
"""Status of the CUPS print queue for a printer."""
|
|
|
|
printer_name: str = ""
|
|
enabled: bool = True
|
|
reason: str = ""
|
|
jobs: list[CUPSJob] = field(default_factory=list)
|
|
has_backend_errors: bool = False
|
|
last_backend_error: str = ""
|
|
|
|
|
|
@dataclass
|
|
class PageCountEstimate:
|
|
"""Estimated consumable life based on CUPS page count."""
|
|
|
|
total_pages: int = 0
|
|
toner_pages: int = 0
|
|
drum_pages: int = 0
|
|
toner_pct_remaining: int = 100
|
|
drum_pct_remaining: int = 100
|
|
toner_exhausted: bool = False
|
|
toner_low: bool = False
|
|
drum_near_end: bool = False
|
|
|
|
|
|
@dataclass
|
|
class USBPortStatus:
|
|
"""IEEE 1284 USB printer port status bits."""
|
|
|
|
paper_empty: bool = False
|
|
online: bool = True
|
|
error: bool = False
|
|
raw_byte: int = 0
|
|
|
|
|
|
@dataclass
|
|
class USBResult:
|
|
"""Result from a USB PJL query."""
|
|
|
|
connection: str = "usb"
|
|
device: str = ""
|
|
product: str = "Brother Laser Printer"
|
|
serial: str = ""
|
|
status_code: str = ""
|
|
display: str = ""
|
|
online: str = ""
|
|
economode: str = ""
|
|
error: str = ""
|
|
port_status: USBPortStatus | None = None
|
|
|
|
|
|
@dataclass
|
|
class SupplyReadings:
|
|
"""Parallel SNMP supply tables (descriptions, capacities, current levels).
|
|
|
|
The three lists are always populated and indexed together, so they travel
|
|
as one object rather than three loose fields on NetworkResult.
|
|
"""
|
|
|
|
descriptions: list[str] = field(default_factory=list)
|
|
max_values: list[str] = field(default_factory=list)
|
|
levels: list[str] = field(default_factory=list)
|
|
|
|
|
|
@dataclass
|
|
class NetworkResult:
|
|
"""Result from an SNMP network query."""
|
|
|
|
connection: str = "network"
|
|
ip: str = ""
|
|
product: str = "Unknown"
|
|
serial: str = ""
|
|
printer_status: str = ""
|
|
device_status: str = ""
|
|
display: str = ""
|
|
page_count: str = ""
|
|
supplies: SupplyReadings = field(default_factory=SupplyReadings)
|
|
error: str = ""
|
|
|
|
|
|
@dataclass
|
|
class SupplyStatus:
|
|
"""Processed supply level info for display."""
|
|
|
|
color: str
|
|
bar_text: str
|
|
status_text: str
|
|
warning: str
|
|
needs_replacement: bool
|