diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-01-27 01:33:15 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-01-27 01:33:15 +0100 |
commit | bfc5e528574e14485d61ddad7e9a57850b9fb93e (patch) | |
tree | bfbc897ca69439d97caa58f81f76d1ada6ea24e7 /psutil/_psbsd.py | |
parent | 90b261aef4c94e364596f07711565ea250f3a10e (diff) | |
download | psutil-bfc5e528574e14485d61ddad7e9a57850b9fb93e.tar.gz |
#955: freebsd / battery: implement power_plugged field
Diffstat (limited to 'psutil/_psbsd.py')
-rw-r--r-- | psutil/_psbsd.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index 20f9cbcb..ea16fc61 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -401,12 +401,15 @@ def net_connections(kind): def sensors_battery(): - percent, minsleft = cext.sensors_battery() - if minsleft == -1: + percent, minsleft, power_plugged = cext.sensors_battery() + power_plugged = power_plugged == 1 + if power_plugged: secsleft = _common.POWER_TIME_UNLIMITED + elif minsleft == -1: + secsleft = _common.POWER_TIME_UNKNOWN else: secsleft = minsleft * 60 - return _common.sbattery(percent, secsleft) + return _common.sbattery(percent, secsleft, power_plugged) # ===================================================================== |