Skip to content

Commit a15e594

Browse files
committed
Add check for performance governor in available governors
1 parent 8ff85e9 commit a15e594

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

auto_cpufreq/core.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,14 @@ def deploy_daemon():
371371

372372

373373
def deploy_daemon_performance():
374-
print("\n" + "-" * 21 + " Deploying auto-cpufreq as a daemon " + "-" * 22 + "\n")
375-
376-
# ToDo:
377-
# add check that performance exists otherwise exit
374+
print("\n" + "-" * 21 + " Deploying auto-cpufreq as a daemon (performance) " + "-" * 22 + "\n")
375+
376+
# check that performance is in scaling_available_governors
377+
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors") as available_governors:
378+
if "performance" not in available_governors.read():
379+
print("\"perfomance\" governor is unavailable on this system, run:\n"
380+
"sudo sudo auto-cpufreq --install\n\n"
381+
"to install auto-cpufreq using default \"balanced\" governor.\n")
378382

379383
# deploy cpufreqctl script func call
380384
cpufreqctl()

bin/auto-cpufreq

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,9 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor
177177
elif install_performance:
178178
if os.getenv("PKG_MARKER") == "SNAP":
179179
root_check()
180-
print("This option is only available on non Snap installs"
181-
"Please refer to: power_helper.py script for more info\n")
180+
print("This option is only available on non Snap installs\n"
181+
"Please refer to auto-cpufreq power_helper.py script for more info\n")
182182
else:
183-
print("in performance")
184183
root_check()
185184
running_daemon()
186185
gov_check()
@@ -198,7 +197,6 @@ def main(config, daemon, debug, install, install_performance, live, log, monitor
198197
run("snapctl start --enable auto-cpufreq", shell=True)
199198
deploy_complete_msg()
200199
else:
201-
print("in install")
202200
root_check()
203201
running_daemon()
204202
gov_check()

0 commit comments

Comments
 (0)