Skip to content

Commit

Permalink
fixed imports (#80)
Browse files Browse the repository at this point in the history
* fixed imports
  • Loading branch information
Red-Eyed committed Aug 6, 2020
1 parent 047c2ff commit 4833367
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
25 changes: 12 additions & 13 deletions bin/auto-cpufreq
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@

# core import
import sys
from subprocess import call
from subprocess import call, run

sys.path.append('../')
from source.core import *
import click


# ToD: replace every s.call with s.run

# cli
@click.command()
@click.option("--monitor", is_flag=True, help="Monitor and suggest CPU optimizations")
Expand All @@ -30,7 +28,7 @@ def main(monitor, live, daemon, install, log, debug):
print("\nExample usage:\nauto-cpufreq --monitor")
print("\n-----\n")

s.call(["auto-cpufreq", "--help"])
run(["auto-cpufreq", "--help"])
footer()
else:
# Important: order does matter
Expand All @@ -43,7 +41,7 @@ def main(monitor, live, daemon, install, log, debug):
sysinfo()
set_autofreq()
countdown(5)
call("clear")
run("clear")
elif os.getenv("PKG_MARKER") != "SNAP":
while True:
root_check()
Expand All @@ -52,7 +50,7 @@ def main(monitor, live, daemon, install, log, debug):
sysinfo()
set_autofreq()
countdown(5)
call("clear")
run("clear")
else:
print("\n" + "-" * 32 + " Daemon check " + "-" * 33 + "\n")
print("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install")
Expand All @@ -67,7 +65,7 @@ def main(monitor, live, daemon, install, log, debug):
sysinfo()
mon_autofreq()
countdown(5)
call("clear")
run("clear")
elif live:
while True:
root_check()
Expand All @@ -77,7 +75,7 @@ def main(monitor, live, daemon, install, log, debug):
sysinfo()
set_autofreq()
countdown(5)
call("clear")
run("clear")
elif log:
# ToDo: fail if log is missing or empty (on)
read_log()
Expand All @@ -90,8 +88,8 @@ def main(monitor, live, daemon, install, log, debug):
root_check()
running_daemon()
gov_check()
s.run("snapctl set daemon=enabled", shell=True)
s.run("snapctl start --enable auto-cpufreq", shell=True)
run("snapctl set daemon=enabled", shell=True)
run("snapctl start --enable auto-cpufreq", shell=True)
deploy_complete_msg()
else:
root_check()
Expand All @@ -102,9 +100,10 @@ def main(monitor, live, daemon, install, log, debug):
elif remove:
if os.getenv('PKG_MARKER') == "SNAP":
root_check()
s.run("snapctl set daemon=disabled", shell=True)
s.run("snapctl stop --disable auto-cpufreq", shell=True)
auto_cpufreq_log_file.unlink(missing_ok=True)
run("snapctl set daemon=disabled", shell=True)
run("snapctl stop --disable auto-cpufreq", shell=True)
if auto_cpufreq_log_file.exists():
auto_cpufreq_log_file.unlink()
remove_complete_msg()
else:
root_check()
Expand Down
3 changes: 2 additions & 1 deletion source/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def remove():
os.remove("/usr/bin/auto-cpufreq-remove")

# 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
cpufreqctl_restore()
Expand Down

0 comments on commit 4833367

Please sign in to comment.