Add config option to display disk units in SI rather than IEC

This commit is contained in:
liaralabs 2023-12-28 17:56:46 -08:00
parent 67958edbd9
commit d7dba656cd
2 changed files with 9 additions and 3 deletions

View file

@ -17,3 +17,4 @@ class Config:
SHAREDSERVER = False
FORMS_LOGIN = True
NETWORK_TOTALS = False
DISK_UNITS = "iec"

View file

@ -239,9 +239,14 @@ def vnstat_parse(interface, mode, query, read_unit, position=False):
def disk_usage(location):
total, used, free = shutil.disk_usage(location)
totalh = GetHumanReadableBi(total)
usedh = GetHumanReadableBi(used)
freeh = GetHumanReadableBi(free)
if swizzin.app.config['DISK_UNITS'] == "si":
totalh = GetHumanReadableB(total)
usedh = GetHumanReadableB(used)
freeh = GetHumanReadableB(free)
else:
totalh = GetHumanReadableBi(total)
usedh = GetHumanReadableBi(used)
freeh = GetHumanReadableBi(free)
usage = '{0:.2f}'.format((used / total * 100))
return totalh, usedh, freeh, usage