implemented --debug option (#70)
* implemented --debug option - Added --debug option that shows sys info - Added inxi as dependency - Implemented get_sys_info() that returns inxi output with injected governnor information - Fixed bug: delete_file was called but this was deleted in prev PR - Updated issue template
This commit is contained in:
parent
c56c656193
commit
e02f7a6881
|
@ -6,15 +6,6 @@ Paste here error output
|
||||||
|
|
||||||
### System information:
|
### System information:
|
||||||
```text
|
```text
|
||||||
Paste here output of inxi -Fz
|
Paste here output of the auto-cpufreq --debug
|
||||||
```
|
|
||||||
---
|
|
||||||
|
|
||||||
How to install inxi:
|
|
||||||
```shell script
|
|
||||||
sudo apt install inxi # [On Debian/Ubuntu/Linux Mint]
|
|
||||||
sudo yum install inxi # [On CentOs/RHEL/Fedora]
|
|
||||||
sudo dnf install inxi # [On Fedora 22+]
|
|
||||||
sudo pacman -S inxi # [On Arch]
|
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
|
|
@ -52,7 +52,7 @@ then
|
||||||
echo -e "\nDetected Debian based distribution"
|
echo -e "\nDetected Debian based distribution"
|
||||||
separator
|
separator
|
||||||
echo -e "\nSetting up Python environment\n"
|
echo -e "\nSetting up Python environment\n"
|
||||||
apt install python3-dev python3-pip -y
|
apt install python3-dev python3-pip inxi -y
|
||||||
separator
|
separator
|
||||||
echo -e "\nInstalling necessary Python packages\n"
|
echo -e "\nInstalling necessary Python packages\n"
|
||||||
pip_pkg_install
|
pip_pkg_install
|
||||||
|
@ -71,9 +71,9 @@ then
|
||||||
# CentOS exception
|
# CentOS exception
|
||||||
if [ -f /etc/centos-release ];
|
if [ -f /etc/centos-release ];
|
||||||
then
|
then
|
||||||
yum install platform-python-devel
|
yum install platform-python-devel inxi
|
||||||
else
|
else
|
||||||
yum install python-devel
|
yum install python-devel inxi
|
||||||
fi
|
fi
|
||||||
echo -e "\nInstalling necessary Python packages\n"
|
echo -e "\nInstalling necessary Python packages\n"
|
||||||
pip_pkg_install
|
pip_pkg_install
|
||||||
|
@ -88,7 +88,7 @@ else
|
||||||
separator
|
separator
|
||||||
echo -e "\nDidn't detect Debian or RedHat based distro.\n"
|
echo -e "\nDidn't detect Debian or RedHat based distro.\n"
|
||||||
echo -e "To complete installation, you need to:"
|
echo -e "To complete installation, you need to:"
|
||||||
echo -e "Install: python3 and pip3\n"
|
echo -e "Install: python3, pip3 and inxi\n"
|
||||||
echo -e "Install necessary Python packages:"
|
echo -e "Install necessary Python packages:"
|
||||||
echo -e "pip3 install psutil click distro power"
|
echo -e "pip3 install psutil click distro power"
|
||||||
echo -e "\nRun following sequence of lines:"
|
echo -e "\nRun following sequence of lines:"
|
||||||
|
|
|
@ -22,8 +22,8 @@ import click
|
||||||
@click.option("--install/--remove", default=True, help="Install/remove daemon for automatic CPU optimizations")
|
@click.option("--install/--remove", default=True, help="Install/remove daemon for automatic CPU optimizations")
|
||||||
@click.option("--log", is_flag=True, help="View live CPU optimization log made by daemon")
|
@click.option("--log", is_flag=True, help="View live CPU optimization log made by daemon")
|
||||||
@click.option("--daemon", is_flag=True, hidden=True)
|
@click.option("--daemon", is_flag=True, hidden=True)
|
||||||
def main(monitor, live, daemon, install, log):
|
@click.option("--debug", is_flag=True, help="Show debug info (include when submitting bugs)")
|
||||||
# print --help by default if no argument is provided when auto-cpufreq is run
|
def main(monitor, live, daemon, install, log, debug):
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
print("\n" + "-" * 32 + " auto-cpufreq " + "-" * 33 + "\n")
|
print("\n" + "-" * 32 + " auto-cpufreq " + "-" * 33 + "\n")
|
||||||
print("Automatic CPU speed & power optimizer for Linux")
|
print("Automatic CPU speed & power optimizer for Linux")
|
||||||
|
@ -31,8 +31,9 @@ def main(monitor, live, daemon, install, log):
|
||||||
print("\n-----\n")
|
print("\n-----\n")
|
||||||
|
|
||||||
s.call(["auto-cpufreq", "--help"])
|
s.call(["auto-cpufreq", "--help"])
|
||||||
footer(79)
|
footer()
|
||||||
else:
|
else:
|
||||||
|
# Important: order does matter
|
||||||
if daemon:
|
if daemon:
|
||||||
if os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled":
|
if os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled":
|
||||||
while True:
|
while True:
|
||||||
|
@ -55,7 +56,7 @@ def main(monitor, live, daemon, install, log):
|
||||||
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")
|
||||||
footer(79)
|
footer()
|
||||||
exit(1)
|
exit(1)
|
||||||
elif monitor:
|
elif monitor:
|
||||||
while True:
|
while True:
|
||||||
|
@ -80,6 +81,10 @@ def main(monitor, live, daemon, install, log):
|
||||||
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()
|
||||||
|
elif debug:
|
||||||
|
footer()
|
||||||
|
print(get_sys_info())
|
||||||
|
footer()
|
||||||
elif install:
|
elif install:
|
||||||
if os.getenv('PKG_MARKER') == "SNAP":
|
if os.getenv('PKG_MARKER') == "SNAP":
|
||||||
root_check()
|
root_check()
|
||||||
|
@ -99,7 +104,7 @@ def main(monitor, live, daemon, install, log):
|
||||||
root_check()
|
root_check()
|
||||||
s.run("snapctl set daemon=disabled", shell=True)
|
s.run("snapctl set daemon=disabled", shell=True)
|
||||||
s.run("snapctl stop --disable auto-cpufreq", shell=True)
|
s.run("snapctl stop --disable auto-cpufreq", shell=True)
|
||||||
delete_file(auto_cpufreq_log_file)
|
auto_cpufreq_log_file.unlink(missing_ok=True)
|
||||||
remove_complete_msg()
|
remove_complete_msg()
|
||||||
else:
|
else:
|
||||||
root_check()
|
root_check()
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import platform as pl
|
import platform as pl
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess as s
|
import subprocess as s
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from subprocess import getoutput
|
||||||
|
|
||||||
import psutil as p
|
import psutil as p
|
||||||
|
|
||||||
|
@ -53,6 +55,24 @@ def turbo(value: bool = None):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def get_sys_info():
|
||||||
|
"""
|
||||||
|
Return sys info of inxi command with injected governors information
|
||||||
|
"""
|
||||||
|
govs = " ".join(get_avail_gov())
|
||||||
|
govs = f"Governors: {govs}"
|
||||||
|
if shutil.which("inxi") is not None:
|
||||||
|
sys_info = getoutput("inxi -Fz")
|
||||||
|
p = re.compile(pattern=r".*(CPU:\s+).+", flags=re.MULTILINE)
|
||||||
|
indent = " " * len(p.search(sys_info).group(1))
|
||||||
|
sys_info = p.sub(f"CPU:{indent[4:]}{govs}", sys_info)
|
||||||
|
else:
|
||||||
|
sys_info = ("Warning: inxi is not installed.\n"
|
||||||
|
f"{govs}")
|
||||||
|
|
||||||
|
return sys_info
|
||||||
|
|
||||||
|
|
||||||
def charging():
|
def charging():
|
||||||
"""
|
"""
|
||||||
get charge state: is battery charging or discharging
|
get charge state: is battery charging or discharging
|
||||||
|
|
Loading…
Reference in New Issue