From 56a8849045605602e41ac2d489d6e1beac3aec3b Mon Sep 17 00:00:00 2001 From: Masoko Date: Sat, 19 Oct 2024 16:45:11 +0300 Subject: [PATCH] check_memory fails if system language is different than EN: fix (#139) --- src/rpi-cpu2mqtt.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/rpi-cpu2mqtt.py b/src/rpi-cpu2mqtt.py index 1ede097..7ca7f81 100644 --- a/src/rpi-cpu2mqtt.py +++ b/src/rpi-cpu2mqtt.py @@ -82,11 +82,9 @@ def check_swap(): def check_memory(): - full_cmd = "free | grep -i mem | awk 'NR == 1 {print $3/$2*100}'" + full_cmd = 'free -b | awk \'NR==2 {printf "%.2f\\n", $3/$2 * 100}\'' memory = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0] - if not memory: - full_cmd = "free | grep -i speicher | awk 'NR == 1 {print $3/$2*100}'" - memory = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0] + if memory: memory = round(float(memory.decode("utf-8").replace(",", "."))) else: @@ -280,15 +278,13 @@ def print_measured_values(cpu_load=0, cpu_temp=0, used_space=0, voltage=0, sys_c for device, temp in drive_temps.items(): output += f"{device.capitalize()} Temp: {temp:.2f}°C\n" - output += """\nInstallation directory: {} + output += """\n Installation directory: {} :: Release notes {}: {}""".format(script_dir, remote_version, get_release_notes(remote_version).strip()) print(output) - - def extract_text(html_string): html_string = html.unescape(html_string) text = re.sub('<[^<]+?>', '', html_string)