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

sensors_battery() only return None if percentage is undetermined #1838

Merged
merged 2 commits into from
Sep 30, 2020
Merged
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
5 changes: 2 additions & 3 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,9 +1361,6 @@ def multi_cat(*paths):
root + "/charge_full")
time_to_empty = multi_cat(root + "/time_to_empty_now")

if (energy_now is None or power_now is None) and time_to_empty is None:
return None

# Percent. If we have energy_full the percentage will be more
# accurate compared to reading /capacity file (float vs. int).
if energy_full is not None and energy_now is not None:
Expand Down Expand Up @@ -1407,6 +1404,8 @@ def multi_cat(*paths):
secsleft = int(time_to_empty * 60)
if secsleft < 0:
secsleft = _common.POWER_TIME_UNKNOWN
else:
secsleft = _common.POWER_TIME_UNKNOWN

return _common.sbattery(percent, secsleft, power_plugged)

Expand Down