Add Checkbox connection type (SATA/NVME) to label #22
57
layouter.py
57
layouter.py
@ -49,7 +49,7 @@ class DriveData:
|
|||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class DriveDataJson:
|
class DriveDataJson:
|
||||||
state: str
|
state: str
|
||||||
connection_type: str
|
contype: str
|
||||||
fam: str
|
fam: str
|
||||||
name: str
|
name: str
|
||||||
cap: int
|
cap: int
|
||||||
@ -153,17 +153,19 @@ def format_to_printable(drive):
|
|||||||
cut_string(30, str(datetime.timedelta(seconds=drive.shred_duration)), "end"),
|
cut_string(30, str(datetime.timedelta(seconds=drive.shred_duration)), "end"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def draw_text(drawable, printable_data, font_regular, font_bold, font_bold_bigger):
|
def draw_text(drawable, printable_data, font_regular, font_bold, font_bold_bigger):
|
||||||
"""Draws formatted text with Cycles and Errors on one row."""
|
"""Draws formatted text with Cycles and Errors on one row."""
|
||||||
|
y_start = 4
|
||||||
line_height = 26
|
line_height = 26
|
||||||
label_x = TEXT_X_OFFSET
|
label_x = TEXT_X_OFFSET
|
||||||
value_offset = 115
|
value_offset = 115
|
||||||
right_field_spacing = 200 # Horizontal gap between Cycles and Errors
|
right_field_spacing = 200 # Horizontal gap between Cycles and Errors
|
||||||
x_capacity = 520
|
x_capacity = 520
|
||||||
y_capacity = 142
|
y_capacity = 142
|
||||||
y_start = 4
|
x_connection_type = 600
|
||||||
|
y_connection_type = y_start
|
||||||
|
y_spacing_connection_type = 25
|
||||||
|
|
||||||
|
|
||||||
# Serial Number
|
# Serial Number
|
||||||
drawable.text((label_x, y_start), "Serial:", fill=0, font=font_bold)
|
drawable.text((label_x, y_start), "Serial:", fill=0, font=font_bold)
|
||||||
@ -250,6 +252,49 @@ def draw_text(drawable, printable_data, font_regular, font_bold, font_bold_bigge
|
|||||||
font=font_bold_bigger,
|
font=font_bold_bigger,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (printable_data.connectiontype == "sata"):
|
||||||
|
drawable.text(
|
||||||
|
(x_connection_type, y_connection_type),
|
||||||
|
"⬤ SATA",
|
||||||
|
fill=0,
|
||||||
|
font=font_regular,
|
||||||
|
)
|
||||||
|
|
||||||
|
drawable.text(
|
||||||
|
(x_connection_type, y_connection_type+y_spacing_connection_type),
|
||||||
|
"◯ NVME",
|
||||||
|
fill=0,
|
||||||
|
font=font_regular,
|
||||||
|
)
|
||||||
|
elif (printable_data.connectiontype == "nvme"):
|
||||||
|
drawable.text(
|
||||||
|
(x_connection_type, y_connection_type),
|
||||||
|
"◯ SATA",
|
||||||
|
fill=0,
|
||||||
|
font=font_regular,
|
||||||
|
)
|
||||||
|
|
||||||
|
drawable.text(
|
||||||
|
(x_connection_type, y_connection_type+y_spacing_connection_type),
|
||||||
|
"⬤ NVME",
|
||||||
|
fill=0,
|
||||||
|
font=font_regular,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
drawable.text(
|
||||||
|
(x_connection_type, y_connection_type),
|
||||||
|
"◯ SATA",
|
||||||
|
fill=0,
|
||||||
|
font=font_regular,
|
||||||
|
)
|
||||||
|
|
||||||
|
drawable.text(
|
||||||
|
(x_connection_type, y_connection_type+y_spacing_connection_type),
|
||||||
|
"◯ NVME",
|
||||||
|
fill=0,
|
||||||
|
font=font_regular,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def draw_qr_code(image, data):
|
def draw_qr_code(image, data):
|
||||||
"""
|
"""
|
||||||
@ -274,7 +319,6 @@ def draw_qr_code(image, data):
|
|||||||
region = (5, 5, 5 + QR_CODE_SIZE, 5 + QR_CODE_SIZE)
|
region = (5, 5, 5 + QR_CODE_SIZE, 5 + QR_CODE_SIZE)
|
||||||
image.paste(qr_img, box=region)
|
image.paste(qr_img, box=region)
|
||||||
|
|
||||||
|
|
||||||
def draw_outline(drawable, margin, width, output_width, output_height):
|
def draw_outline(drawable, margin, width, output_width, output_height):
|
||||||
"""
|
"""
|
||||||
Draws a rectangular outline on the drawable canvas.
|
Draws a rectangular outline on the drawable canvas.
|
||||||
@ -303,14 +347,13 @@ def draw_outline(drawable, margin, width, output_width, output_height):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
drawable.line(line, fill=0, width=width)
|
drawable.line(line, fill=0, width=width)
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
drive_json = DriveDataJson(
|
drive_json = DriveDataJson(
|
||||||
state=drive.drive_state,
|
state=drive.drive_state,
|
||||||
connection_type=drive.drive_connection_type,
|
contype=drive.drive_connection_type,
|
||||||
fam=drive.modelfamily,
|
fam=drive.modelfamily,
|
||||||
name=drive.modelname,
|
name=drive.modelname,
|
||||||
cap=drive.capacity,
|
cap=drive.capacity,
|
||||||
|
|||||||
BIN
output.png
BIN
output.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.6 KiB |
Reference in New Issue
Block a user