Remove magic numbers

This commit is contained in:
2Shirt 2022-05-21 17:38:28 -07:00
parent 7abd4c21c3
commit b4547c3555
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 7 additions and 3 deletions

View file

@ -172,6 +172,9 @@ TMUX_LAYOUT = OrderedDict({
'badblocks': {'height': 5, 'Check': True},
'I/O Benchmark': {'height': 1000, 'Check': False},
})
# VOLUME THRESHOLDS in percent
VOLUME_WARNING_THRESHOLD = 70
VOLUME_FAILURE_THRESHOLD = 85
if __name__ == '__main__':

View file

@ -7,9 +7,10 @@ import pathlib
import re
import subprocess
from wk.std import bytes_to_string, color_string
from wk.cfg.hw import VOLUME_FAILURE_THRESHOLD, VOLUME_WARNING_THRESHOLD
from wk.exe import get_json_from_command, popen_program, run_program
from wk.log import format_log_path
from wk.std import bytes_to_string, color_string
# STATIC VARIABLES
@ -64,9 +65,9 @@ def build_volume_report(device_path=None) -> list:
# Set size color
if vol['fsused']:
percent_used = (int(vol['fsused']) / int(vol['size'])) * 100
if percent_used >= 85:
if percent_used >= VOLUME_FAILURE_THRESHOLD:
size_color = 'RED'
elif percent_used >= 70:
elif percent_used >= VOLUME_WARNING_THRESHOLD:
size_color = 'YELLOW'
# Clean data