Merge branch 'no-sys.stderr' into develop
This commit is contained in:
commit
079a750d71
|
@ -890,13 +890,13 @@ class NowPlayingSegment(object):
|
||||||
return format.format(**stats)
|
return format.format(**stats)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _run_cmd(cmd):
|
def _run_cmd(pl, cmd):
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
try:
|
try:
|
||||||
p = Popen(cmd, stdout=PIPE)
|
p = Popen(cmd, stdout=PIPE)
|
||||||
stdout, err = p.communicate()
|
stdout, err = p.communicate()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
sys.stderr.write('Could not execute command ({0}): {1}\n'.format(e, cmd))
|
pl.exception('Could not execute command ({0}): {1}'.format(e, cmd))
|
||||||
return None
|
return None
|
||||||
return stdout.strip()
|
return stdout.strip()
|
||||||
|
|
||||||
|
@ -934,7 +934,7 @@ class NowPlayingSegment(object):
|
||||||
method takes anything in ignore_levels and brings the key inside that
|
method takes anything in ignore_levels and brings the key inside that
|
||||||
to the first level of the dictionary.
|
to the first level of the dictionary.
|
||||||
'''
|
'''
|
||||||
now_playing_str = self._run_cmd(['cmus-remote', '-Q'])
|
now_playing_str = self._run_cmd(pl, ['cmus-remote', '-Q'])
|
||||||
if not now_playing_str:
|
if not now_playing_str:
|
||||||
return
|
return
|
||||||
ignore_levels = ('tag', 'set',)
|
ignore_levels = ('tag', 'set',)
|
||||||
|
@ -973,7 +973,7 @@ class NowPlayingSegment(object):
|
||||||
'total': self._convert_seconds(now_playing.get('time', 0)),
|
'total': self._convert_seconds(now_playing.get('time', 0)),
|
||||||
}
|
}
|
||||||
except ImportError:
|
except ImportError:
|
||||||
now_playing = self._run_cmd(['mpc', 'current', '-f', '%album%\n%artist%\n%title%\n%time%', '-h', str(host), '-p', str(port)])
|
now_playing = self._run_cmd(pl, ['mpc', 'current', '-f', '%album%\n%artist%\n%title%\n%time%', '-h', str(host), '-p', str(port)])
|
||||||
if not now_playing:
|
if not now_playing:
|
||||||
return
|
return
|
||||||
now_playing = now_playing.split('\n')
|
now_playing = now_playing.split('\n')
|
||||||
|
@ -988,7 +988,7 @@ class NowPlayingSegment(object):
|
||||||
try:
|
try:
|
||||||
import dbus
|
import dbus
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sys.stderr.write('Could not add Spotify segment: Requires python-dbus.\n')
|
pl.exception('Could not add Spotify segment: requires python-dbus.')
|
||||||
return
|
return
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
DBUS_IFACE_PROPERTIES = 'org.freedesktop.DBus.Properties'
|
DBUS_IFACE_PROPERTIES = 'org.freedesktop.DBus.Properties'
|
||||||
|
@ -1068,7 +1068,7 @@ class NowPlayingSegment(object):
|
||||||
player_spotify = player_spotify_dbus # NOQA
|
player_spotify = player_spotify_dbus # NOQA
|
||||||
|
|
||||||
def player_rhythmbox(self, pl):
|
def player_rhythmbox(self, pl):
|
||||||
now_playing = self._run_cmd(['rhythmbox-client', '--no-start', '--no-present', '--print-playing-format', '%at\n%aa\n%tt\n%te\n%td'])
|
now_playing = self._run_cmd(pl, ['rhythmbox-client', '--no-start', '--no-present', '--print-playing-format', '%at\n%aa\n%tt\n%te\n%td'])
|
||||||
if not now_playing:
|
if not now_playing:
|
||||||
return
|
return
|
||||||
now_playing = now_playing.split('\n')
|
now_playing = now_playing.split('\n')
|
||||||
|
|
Loading…
Reference in New Issue