Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #715, #713, #634 issues #716

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions auto_cpufreq/battery_scripts/ideapad_acpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ def ideapad_acpi_print_thresholds():
print(f"battery count = {len(batteries)}")
for bat in batteries:
try:
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_start_threshold', 'r') as f:
print(f'{bat} start threshold = {f.read()}', end="")

with open(f'{POWER_SUPPLY_DIR}{bat}/charge_stop_threshold', 'r') as f:
print(f'{bat} stop threshold = {f.read()}', end="")

except Exception: print(f"ERROR: failed to read battery {bat} thresholds")
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_start_threshold")}')
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_stop_threshold")}')
except Exception as e: print(f"ERROR: failed to read battery {bat} thresholds: ", repr(e))
10 changes: 3 additions & 7 deletions auto_cpufreq/battery_scripts/ideapad_laptop.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def ideapad_laptop_print_thresholds():
print(f"battery count = {len(batteries)}")
for bat in batteries:
try:
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_start_threshold', 'r') as f:
print(f'{bat} start threshold = {f.read()}', end="")

with open(f'{POWER_SUPPLY_DIR}{bat}/charge_stop_threshold', 'r') as f:
print(f'{bat} stop threshold = {f.read()}', end="")

except Exception as e: print(f"ERROR: failed to read {bat} thresholds: {e}")
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_start_threshold")}')
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_stop_threshold")}')
except Exception as e: print(f"ERROR: failed to read battery {bat} thresholds: ", repr(e))
10 changes: 3 additions & 7 deletions auto_cpufreq/battery_scripts/thinkpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ def thinkpad_print_thresholds():
print(f"battery count = {len(batteries)}")
for bat in batteries:
try:
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_start_threshold', 'r') as f:
print(f'{bat} start threshold = {f.read()}', end="")

with open(f'{POWER_SUPPLY_DIR}{bat}/charge_stop_threshold', 'r') as f:
print(f'{bat} stop threshold = {f.read()}', end="")

except Exception: print(f"ERROR: failed to read battery {bat} thresholds")
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_start_threshold")}')
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_stop_threshold")}')
except Exception as e: print(f"ERROR: failed to read battery {bat} thresholds: ", repr(e))
2 changes: 1 addition & 1 deletion auto_cpufreq/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import sys

def find_config_file(args_config_file: str | None) -> str:
def find_config_file(args_config_file) -> str:
"""
Find the config file to use.

Expand Down
31 changes: 7 additions & 24 deletions scripts/auto-cpufreq-venv-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,15 @@

set -eu

# get script name
PROGNAME=$(basename "${0}")

# bailout function
err_exit()
{
echo "${PROGNAME}: ${1:-wrong invocation. try --help for help.}" 1>&2
exit 1
err_exit() {
echo "$(basename $0): ${1:-wrong invocation. try --help for help.}" 1>&2
exit 1
}

# invocation handling
#

# load python virtual environment
venv_dir=/opt/auto-cpufreq/venv
. "$venv_dir/bin/activate"
opt_path=/opt/auto-cpufreq
venv_bin_dir=$opt_path/venv/bin
. "$venv_bin_dir/activate"

# run python code with venv loaded
if [[ "$#" -ne 1 ]]; then
PYTHONPATH=/opt/auto-cpufreq \
/opt/auto-cpufreq/venv/bin/python \
/opt/auto-cpufreq/venv/bin/auto-cpufreq
else
param="$1"
PYTHONPATH=/opt/auto-cpufreq \
/opt/auto-cpufreq/venv/bin/python \
/opt/auto-cpufreq/venv/bin/auto-cpufreq \
"${param}"
fi
PYTHONPATH=$opt_path $venv_bin_dir/python $venv_bin_dir/auto-cpufreq "$@"