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"
|
||||
)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class DriveData:
|
||||
drive_index: int
|
||||
@ -44,6 +45,20 @@ class DriveData:
|
||||
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
|
||||
class DriveDataPrintable:
|
||||
modelfamily: str
|
||||
@ -59,13 +74,13 @@ class DriveDataPrintable:
|
||||
|
||||
@dataclasses.dataclass
|
||||
class ReHddInfo:
|
||||
link: str
|
||||
version: str
|
||||
ref: str
|
||||
ver: str
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class DriveDataJson:
|
||||
drive: DriveData
|
||||
class QrDataJson:
|
||||
drive: DriveDataJson
|
||||
rehdd: ReHddInfo
|
||||
|
||||
|
||||
@ -288,7 +303,21 @@ def draw_outline(drawable, margin, width, output_width, output_height):
|
||||
def generate_image(drive, rehdd_info, output_file):
|
||||
"""Generates an image containing drive data and a QR code."""
|
||||
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)
|
||||
except Exception as 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