shorten qrcode data
This commit is contained in:
parent
880ff8c6e3
commit
e06d10caee
39
layouter.py
39
layouter.py
@ -29,6 +29,7 @@ logging.basicConfig(
|
|||||||
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
|
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class DriveData:
|
class DriveData:
|
||||||
drive_index: int
|
drive_index: int
|
||||||
@ -44,6 +45,20 @@ class DriveData:
|
|||||||
shred_duration: int
|
shred_duration: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class DriveDataJson:
|
||||||
|
state: str
|
||||||
|
fam: str
|
||||||
|
name: str
|
||||||
|
cap: int
|
||||||
|
sn: str
|
||||||
|
poh: int
|
||||||
|
pc: int
|
||||||
|
err: int
|
||||||
|
time: int
|
||||||
|
dur: int
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class DriveDataPrintable:
|
class DriveDataPrintable:
|
||||||
modelfamily: str
|
modelfamily: str
|
||||||
@ -59,13 +74,13 @@ class DriveDataPrintable:
|
|||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class ReHddInfo:
|
class ReHddInfo:
|
||||||
link: str
|
ref: str
|
||||||
version: str
|
ver: str
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class DriveDataJson:
|
class QrDataJson:
|
||||||
drive: DriveData
|
drive: DriveDataJson
|
||||||
rehdd: ReHddInfo
|
rehdd: ReHddInfo
|
||||||
|
|
||||||
|
|
||||||
@ -288,7 +303,21 @@ def draw_outline(drawable, margin, width, output_width, output_height):
|
|||||||
def generate_image(drive, rehdd_info, output_file):
|
def generate_image(drive, rehdd_info, output_file):
|
||||||
"""Generates an image containing drive data and a QR code."""
|
"""Generates an image containing drive data and a QR code."""
|
||||||
try:
|
try:
|
||||||
qr_data = json.dumps(dataclasses.asdict(DriveDataJson(drive, rehdd_info)))
|
|
||||||
|
drive_json = DriveDataJson(
|
||||||
|
state=drive.drive_state,
|
||||||
|
fam=drive.modelfamily,
|
||||||
|
name=drive.modelname,
|
||||||
|
cap=drive.capacity,
|
||||||
|
sn=drive.serialnumber,
|
||||||
|
poh=drive.power_on_hours,
|
||||||
|
pc=drive.power_cycle,
|
||||||
|
err=drive.smart_error_count,
|
||||||
|
time=int(drive.shred_timestamp),
|
||||||
|
dur=drive.shred_duration,
|
||||||
|
)
|
||||||
|
|
||||||
|
qr_data = json.dumps(dataclasses.asdict(QrDataJson(drive_json, rehdd_info)))
|
||||||
printable_data = format_to_printable(drive)
|
printable_data = format_to_printable(drive)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error preparing data: {e}")
|
logging.error(f"Error preparing data: {e}")
|
||||||
|
BIN
output.png
BIN
output.png
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in New Issue
Block a user