diff --git a/layouter.py b/layouter.py index a502ca6..7759067 100644 --- a/layouter.py +++ b/layouter.py @@ -62,13 +62,20 @@ def get_font_path_bold(): files = glob.glob(path + "/**/DejaVuSans-Bold.ttf", recursive = True) return files[0] -def human_readable_capacity(size, decimal_places=0): +def human_readable_capacity_1024(size, decimal_places=0): for unit in ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']: if size < 1024.0 or unit == 'PiB': break size /= 1024.0 return f"{size:.{decimal_places}f} {unit}" +def human_readable_capacity_1000(size, decimal_places=0): + for unit in ['B', 'KB', 'MB', 'GB', 'TB', 'PB']: + if size < 1000.0 or unit == 'PB': + break + size /= 1000.0 + return f"{size:.{decimal_places}f} {unit}" + 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" @@ -82,7 +89,7 @@ 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(drive.capacity)),\ + 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)),\ diff --git a/output.png b/output.png index 6efa03a..96c9e1a 100644 Binary files a/output.png and b/output.png differ