From 8a06de40cdb357f49e32525d9a3e3bfe2077ae1a Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Sun, 26 Jan 2020 17:45:11 +0100 Subject: [PATCH] minor code improvements/clean-up --- .gitignore | 1 + bin/auto-cpufreq | 7 +------ source/core.py | 11 +++-------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index b6e4761..fa94bb5 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +files.txt # PyInstaller # Usually these files are written by a python script from a template diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq index 1a0f12a..fbdda36 100755 --- a/bin/auto-cpufreq +++ b/bin/auto-cpufreq @@ -25,12 +25,7 @@ def main(monitor, live, daemon, install, log): print("\nExample usage:\nauto-cpufreq --monitor") print("\n-----\n") - # ToDo: add option what to run depending on the env - if os.getenv('PKG_MARKER') == "SNAP": - s.call(["auto-cpufreq", "--help"]) - else: - s.call(["python3", "auto-cpufreq", "--help"]) - #s.call([tool_run, " --help"]) + s.call(["auto-cpufreq", "--help"]) footer(79) else: if daemon: diff --git a/source/core.py b/source/core.py index ca53a84..fba7b89 100644 --- a/source/core.py +++ b/source/core.py @@ -21,7 +21,6 @@ import signal p = psutil pl = platform s = subprocess -tool_run = sys.argv[0] cpus = os.cpu_count() # get turbo boost state @@ -73,14 +72,9 @@ def deploy(): except: print("\nERROR:\nWas unable to turn off bluetooth on boot") - #print("\n* Deploy auto-cpufreq as system wide accessible binary") - #os.system("cp auto-cpufreq /usr/bin/auto-cpufreq") - # create log file create_file(auto_cpufreq_log_file) - # sudo python3 setup.py install --record files.txt - print("\n* Deploy auto-cpufreq install script") os.system("cp /usr/local/share/auto-cpufreq/scripts/auto-cpufreq-install.sh /usr/bin/auto-cpufreq-install") @@ -135,7 +129,8 @@ def gov_check(): def root_check(): if not os.geteuid() == 0: print("\n" + "-" * 33 + " Root check " + "-" * 34 + "\n") - sys.exit("ERROR:\n\nMust be run root for this functionality to work, i.e: \nsudo " + tool_run + "\n") + print("ERROR:\n\nMust be run root for this functionality to work, i.e: \nsudo auto-cpufreq") + footer(79) exit(1) # refresh countdown @@ -384,7 +379,7 @@ def read_log(): s.call(["tail", "-n 50", "-f", auto_cpufreq_log_file]) else: print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n") - print("ERROR: auto-cpufreq log is missing.\n\nMake sure to run: \"python3 auto-cpufreq.py --install\" first") + print("ERROR: auto-cpufreq log is missing.\n\nMake sure to run: \"auto-cpufreq --install\" first") footer(79) def running_check():