Merge pull request #1729 from thomwiggers/fix-divide-bat-by-zero

Prevent divide by zero battery capacity
This commit is contained in:
Nikolai Aleksandrovich Pavlov 2017-02-26 01:27:44 +03:00 committed by GitHub
commit 4c68f773aa
1 changed files with 4 additions and 1 deletions

View File

@ -72,7 +72,10 @@ def _fetch_battery_info(pl):
devtype_name,
'State'
) != 2
return (energy * 100.0 / energy_full), state
if energy_full > 0:
return (energy * 100.0 / energy_full), state
else:
return 0.0, state
return _flatten_battery
pl.debug('Not using DBUS+UPower as no batteries were found')