Catch NotImplementedError when importing module

Fixes #883
This commit is contained in:
ZyX 2014-05-27 05:43:55 +04:00
parent e3bebcc5b5
commit 7c65ee9703

View File

@ -1105,6 +1105,7 @@ class NowPlayingSegment(object):
now_playing = NowPlayingSegment()
try:
if os.path.exists('/sys/class/power_supply/'):
_linux_bat_fmt = '/sys/class/power_supply/{0}/capacity'
_linux_bat = 'BAT0'
@ -1115,7 +1116,10 @@ if os.path.exists('/sys/class/power_supply/'):
def _get_capacity(pl):
with open(_linux_bat_fmt.format(_linux_bat), 'r') as f:
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):
import re
battery_summary = run_cmd(pl, ['pmset', '-g', 'batt'])