-
-
Notifications
You must be signed in to change notification settings - Fork 334
fix: display actual EPP and EPB values in stats output #894
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,19 +149,36 @@ def current_epp(is_ac_plugged: bool) -> str | None: | |
| if not Path(epp_path).exists(): | ||
| return None | ||
|
|
||
| return config.get_config().get( | ||
| "charger" if is_ac_plugged else "battery", "energy_performance_preference", fallback="balance_power" | ||
| ) | ||
| try: | ||
| with open(epp_path, "r") as f: | ||
| return f.read().strip() | ||
| except: | ||
| return None | ||
|
|
||
| @staticmethod | ||
| def current_epb(is_ac_plugged: bool) -> str | None: | ||
|
||
| epb_path = "/sys/devices/system/cpu/intel_pstate" | ||
| epb_path = "/sys/devices/system/cpu/cpu0/power/energy_perf_bias" | ||
| if not Path(epb_path).exists(): | ||
| return None | ||
|
|
||
| return config.get_config().get( | ||
| "charger" if is_ac_plugged else "battery", "energy_perf_bias", fallback="balance_power" | ||
| ) | ||
| try: | ||
| with open(epb_path, "r") as f: | ||
| value = int(f.read().strip()) | ||
| # Convert numeric value to string representation | ||
| if value == 0: | ||
| return "performance" | ||
| elif value == 4: | ||
| return "balance_performance" | ||
| elif value == 6: | ||
| return "default" | ||
| elif value == 8: | ||
| return "balance_power" | ||
| elif value == 15: | ||
| return "power" | ||
| else: | ||
| return str(value) | ||
| except: | ||
| return None | ||
|
Comment on lines
+180
to
+181
|
||
|
|
||
| @staticmethod | ||
| def cpu_usage() -> float: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bare except clause catches all exceptions including system-exiting exceptions like KeyboardInterrupt and SystemExit. Replace with a specific exception type like
except (FileNotFoundError, OSError, IOError)to handle expected file operation errors.