parent
8f5c1d7c00
commit
6b8be7afe7
|
@ -6,15 +6,13 @@
|
||||||
|
|
||||||
# core import
|
# core import
|
||||||
import sys
|
import sys
|
||||||
from subprocess import call
|
from subprocess import call, run
|
||||||
|
|
||||||
sys.path.append('../')
|
sys.path.append('../')
|
||||||
from source.core import *
|
from source.core import *
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
|
||||||
# ToD: replace every s.call with s.run
|
|
||||||
|
|
||||||
# cli
|
# cli
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--monitor", is_flag=True, help="Monitor and suggest CPU optimizations")
|
@click.option("--monitor", is_flag=True, help="Monitor and suggest CPU optimizations")
|
||||||
|
@ -30,7 +28,7 @@ def main(monitor, live, daemon, install, log, debug):
|
||||||
print("\nExample usage:\nauto-cpufreq --monitor")
|
print("\nExample usage:\nauto-cpufreq --monitor")
|
||||||
print("\n-----\n")
|
print("\n-----\n")
|
||||||
|
|
||||||
s.call(["auto-cpufreq", "--help"])
|
run(["auto-cpufreq", "--help"])
|
||||||
footer()
|
footer()
|
||||||
else:
|
else:
|
||||||
# Important: order does matter
|
# Important: order does matter
|
||||||
|
@ -43,7 +41,7 @@ def main(monitor, live, daemon, install, log, debug):
|
||||||
sysinfo()
|
sysinfo()
|
||||||
set_autofreq()
|
set_autofreq()
|
||||||
countdown(5)
|
countdown(5)
|
||||||
call("clear")
|
run("clear")
|
||||||
elif os.getenv("PKG_MARKER") != "SNAP":
|
elif os.getenv("PKG_MARKER") != "SNAP":
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
|
@ -52,7 +50,7 @@ def main(monitor, live, daemon, install, log, debug):
|
||||||
sysinfo()
|
sysinfo()
|
||||||
set_autofreq()
|
set_autofreq()
|
||||||
countdown(5)
|
countdown(5)
|
||||||
call("clear")
|
run("clear")
|
||||||
else:
|
else:
|
||||||
print("\n" + "-" * 32 + " Daemon check " + "-" * 33 + "\n")
|
print("\n" + "-" * 32 + " Daemon check " + "-" * 33 + "\n")
|
||||||
print("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install")
|
print("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install")
|
||||||
|
@ -67,7 +65,7 @@ def main(monitor, live, daemon, install, log, debug):
|
||||||
sysinfo()
|
sysinfo()
|
||||||
mon_autofreq()
|
mon_autofreq()
|
||||||
countdown(5)
|
countdown(5)
|
||||||
call("clear")
|
run("clear")
|
||||||
elif live:
|
elif live:
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
|
@ -77,7 +75,7 @@ def main(monitor, live, daemon, install, log, debug):
|
||||||
sysinfo()
|
sysinfo()
|
||||||
set_autofreq()
|
set_autofreq()
|
||||||
countdown(5)
|
countdown(5)
|
||||||
call("clear")
|
run("clear")
|
||||||
elif log:
|
elif log:
|
||||||
# ToDo: fail if log is missing or empty (on)
|
# ToDo: fail if log is missing or empty (on)
|
||||||
read_log()
|
read_log()
|
||||||
|
@ -90,8 +88,8 @@ def main(monitor, live, daemon, install, log, debug):
|
||||||
root_check()
|
root_check()
|
||||||
running_daemon()
|
running_daemon()
|
||||||
gov_check()
|
gov_check()
|
||||||
s.run("snapctl set daemon=enabled", shell=True)
|
run("snapctl set daemon=enabled", shell=True)
|
||||||
s.run("snapctl start --enable auto-cpufreq", shell=True)
|
run("snapctl start --enable auto-cpufreq", shell=True)
|
||||||
deploy_complete_msg()
|
deploy_complete_msg()
|
||||||
else:
|
else:
|
||||||
root_check()
|
root_check()
|
||||||
|
@ -102,9 +100,10 @@ def main(monitor, live, daemon, install, log, debug):
|
||||||
elif remove:
|
elif remove:
|
||||||
if os.getenv('PKG_MARKER') == "SNAP":
|
if os.getenv('PKG_MARKER') == "SNAP":
|
||||||
root_check()
|
root_check()
|
||||||
s.run("snapctl set daemon=disabled", shell=True)
|
run("snapctl set daemon=disabled", shell=True)
|
||||||
s.run("snapctl stop --disable auto-cpufreq", shell=True)
|
run("snapctl stop --disable auto-cpufreq", shell=True)
|
||||||
auto_cpufreq_log_file.unlink(missing_ok=True)
|
if auto_cpufreq_log_file.exists():
|
||||||
|
auto_cpufreq_log_file.unlink()
|
||||||
remove_complete_msg()
|
remove_complete_msg()
|
||||||
else:
|
else:
|
||||||
root_check()
|
root_check()
|
||||||
|
|
|
@ -244,7 +244,8 @@ def remove():
|
||||||
os.remove("/usr/bin/auto-cpufreq-remove")
|
os.remove("/usr/bin/auto-cpufreq-remove")
|
||||||
|
|
||||||
# delete log file
|
# delete log file
|
||||||
auto_cpufreq_log_file.unlink(missing_ok=True)
|
if auto_cpufreq_log_file.exists():
|
||||||
|
auto_cpufreq_log_file.unlink()
|
||||||
|
|
||||||
# restore original cpufrectl script
|
# restore original cpufrectl script
|
||||||
cpufreqctl_restore()
|
cpufreqctl_restore()
|
||||||
|
|
Loading…
Reference in New Issue