diff options
author | aristocratos <gnmjpl@gmail.com> | 2020-09-30 23:41:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-30 23:41:01 +0200 |
commit | 7935f91173c813defe45666480e59c6a141cab43 (patch) | |
tree | b5c3420f99989f006096cac40c8f8889f261efe0 | |
parent | ac551d1fd9e1837a5ab5c34b0425e1f17d8c1009 (diff) | |
download | psutil-7935f91173c813defe45666480e59c6a141cab43.tar.gz |
sensors_battery() only return None if percentage is undetermined (#1838)
-rw-r--r-- | psutil/_pslinux.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 4a96c906..4dc3a0ab 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1361,9 +1361,6 @@ def sensors_battery(): 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: @@ -1407,6 +1404,8 @@ def sensors_battery(): 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) |