Merge branch 'fix-883' into develop

This commit is contained in:
ZyX 2014-05-27 05:44:08 +04:00
commit 7ac2717083

View File

@ -1105,6 +1105,7 @@ class NowPlayingSegment(object):
now_playing = NowPlayingSegment() now_playing = NowPlayingSegment()
try:
if os.path.exists('/sys/class/power_supply/'): if os.path.exists('/sys/class/power_supply/'):
_linux_bat_fmt = '/sys/class/power_supply/{0}/capacity' _linux_bat_fmt = '/sys/class/power_supply/{0}/capacity'
_linux_bat = 'BAT0' _linux_bat = 'BAT0'
@ -1115,7 +1116,10 @@ if os.path.exists('/sys/class/power_supply/'):
def _get_capacity(pl): def _get_capacity(pl):
with open(_linux_bat_fmt.format(_linux_bat), 'r') as f: with open(_linux_bat_fmt.format(_linux_bat), 'r') as f:
return int(float(f.readline().split()[0])) return int(float(f.readline().split()[0]))
elif os.path.exists('/usr/bin/pmset'): else:
raise NotImplementedError
except NotImplementedError:
if os.path.exists('/usr/bin/pmset'):
def _get_capacity(pl): def _get_capacity(pl):
import re import re
battery_summary = run_cmd(pl, ['pmset', '-g', 'batt']) battery_summary = run_cmd(pl, ['pmset', '-g', 'batt'])