Skip to content

Commit

Permalink
sensors_battery() only return None if percentage is undetermined (#1838)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristocratos authored Sep 30, 2020
1 parent ac551d1 commit 7935f91
Showing 1 changed file with 2 additions and 3 deletions.
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

0 comments on commit 7935f91

Please sign in to comment.