mirror of
https://github.com/swizzin/swizzin_dashboard.git
synced 2024-09-20 06:46:08 +08:00
Add config option to display disk units in SI rather than IEC
This commit is contained in:
parent
67958edbd9
commit
d7dba656cd
|
@ -17,3 +17,4 @@ class Config:
|
|||
SHAREDSERVER = False
|
||||
FORMS_LOGIN = True
|
||||
NETWORK_TOTALS = False
|
||||
DISK_UNITS = "iec"
|
||||
|
|
11
core/util.py
11
core/util.py
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue