From 44c6b37db42fe345919bbe04ef2a1616a79597a2 Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Sun, 13 Sep 2020 20:13:34 +0200 Subject: [PATCH] fixed display_load function not being executed each iteration --- bin/auto-cpufreq | 3 ++- source/core.py | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq index bdc58b2..ff07afd 100755 --- a/bin/auto-cpufreq +++ b/bin/auto-cpufreq @@ -92,7 +92,8 @@ def main(monitor, live, daemon, install, log, debug): if os.getenv('PKG_MARKER') == "SNAP": print("Snap package: yes") else: - app_version() + # temp disabled (Issue: #111) + # app_version() print("Snap package: no") print("") python_info() diff --git a/source/core.py b/source/core.py index 879b065..602227f 100644 --- a/source/core.py +++ b/source/core.py @@ -171,9 +171,7 @@ def footer(l=79): def daemon_not_found(): print("\n" + "-" * 32 + " Daemon check " + "-" * 33 + "\n") - print("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install") - footer() - sys.exit() + sys.exit("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install") def deploy_complete_msg(): print("\n" + "-" * 17 + " auto-cpufreq daemon installed and running " + "-" * 17 + "\n") @@ -284,6 +282,12 @@ def countdown(s): # get cpu usage + system load for (last minute) def display_load(): + + # get system/CPU load + load1m, _, _ = os.getloadavg() + # get CPU utilization as a percentage + cpuload = psutil.cpu_percent(interval=1) + print("\nTotal CPU usage:", cpuload, "%") print("Total system load:", load1m, "\n") @@ -510,13 +514,13 @@ def sysinfo(): # print("\nCPU fan speed:", current_fans, "RPM") +def no_log_msg(): + print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n") + print("ERROR: auto-cpufreq log is missing.\n\nMake sure to run: \"auto-cpufreq --install\" first") + # read log func def read_log(): - def no_log_msg(): - print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n") - print("ERROR: auto-cpufreq log is missing.\n\nMake sure to run: \"auto-cpufreq --install\" first") - # read log (snap) if os.getenv("PKG_MARKER") == "SNAP": if os.path.isfile(auto_cpufreq_log_file_snap): @@ -529,7 +533,6 @@ def read_log(): else: no_log_msg() footer() - sys.exit() # check if program (argument) is running