cut SN at start

main^2
Hendrik Schutter 2 months ago
parent 58c5c98265
commit 5bf2ab8b2e

@ -79,23 +79,28 @@ def human_readable_capacity_1000(size, decimal_places=0):
def human_readable_power_on_hours(hours, decimal_places=2):
return str(hours) + "h or " + str(int(hours/24)) + "d or " + str("{:.2f}".format(float(hours/24/365))) + "y"
def cut_string(max_lenght, data):
def cut_string(max_lenght, data, direction):
if (len(data) > max_lenght):
return data[0:(max_lenght-4)] + " ..."
if (direction == "end"):
return data[0:(max_lenght-4)] + " ..."
elif (direction == "start"):
return "... " + data[(len(data)-max_lenght+4):]
else:
return cut_string(max_lenght, data, "end")
else:
return data
def format_to_printable(drive):
return DriveDataPrintable(
cut_string(20, re.sub(r"[^a-zA-Z0-9. ]", "", drive.modelfamiliy)),\
cut_string(20, re.sub(r"[^a-zA-Z0-9. ]", "", drive.modelname)),\
cut_string(20, human_readable_capacity_1000(drive.capacity)),\
cut_string(16, re.sub(r"[^a-zA-Z0-9.-_]", "", drive.serialnumber)),\
cut_string(30, human_readable_power_on_hours(drive.power_on_hours)),\
cut_string(10, str(drive.power_cycle)),\
cut_string(10, str(drive.smart_error_count)),\
cut_string(30, datetime.datetime.utcfromtimestamp(drive.shred_timestamp).strftime('%Y-%m-%d %H:%M:%S')),\
cut_string(30, str(datetime.timedelta(seconds = drive.shred_duration))))
cut_string(20, re.sub(r"[^a-zA-Z0-9. ]", "", drive.modelfamiliy), "end"),\
cut_string(20, re.sub(r"[^a-zA-Z0-9. ]", "", drive.modelname), "end"),\
cut_string(20, human_readable_capacity_1000(drive.capacity), "end"),\
cut_string(16, re.sub(r"[^a-zA-Z0-9.-_]", "", drive.serialnumber), "start"),\
cut_string(30, human_readable_power_on_hours(drive.power_on_hours), "end"),\
cut_string(10, str(drive.power_cycle), "end"),\
cut_string(10, str(drive.smart_error_count), "end"),\
cut_string(30, datetime.datetime.utcfromtimestamp(drive.shred_timestamp).strftime('%Y-%m-%d %H:%M:%S'), "end"),\
cut_string(30, str(datetime.timedelta(seconds = drive.shred_duration)), "end"))
def draw_text(drawable, printable_data, text_x_offset):
try:
@ -171,7 +176,7 @@ def generate_image(drive, rehdd_info, output_file):
print("unable to format data: " + str(ex))
return
#print(printable_data)
#print(printable_data.serialnumber)
#create black and white (binary) image with white background
output_image = Image.new('1', (output_width, output_height), "white")
@ -196,7 +201,7 @@ def main():
modelfamiliy="Toshiba 2.5\\ HDD MK..65GSSX",\
modelname="TOSHIBA MK3265GSDX",\
capacity=343597383680,\
serialnumber="YG6742U56UDRL123",\
serialnumber="YG6742U56UDRL123456789ABCDEFGJKL",\
power_on_hours=7074,\
power_cycle=4792,\
smart_error_count=1,\

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close