From 5202807269e35d9af6def036c8029b1e1a90cce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Silkeb=C3=A6kken?= Date: Fri, 15 Feb 2013 12:45:52 +0100 Subject: [PATCH] Make Spotify segment more error-proof --- powerline/segments/common.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/powerline/segments/common.py b/powerline/segments/common.py index 792e6886..a4795c42 100644 --- a/powerline/segments/common.py +++ b/powerline/segments/common.py @@ -599,14 +599,16 @@ class NowPlayingSegment(object): status = iface.Get(DBUS_IFACE_PLAYER, 'PlaybackStatus') except dbus.exceptions.DBusException: return + if not info: + return state = self._convert_state(status) return { 'state': state, 'state_symbol': self.STATE_SYMBOLS.get(state), - 'album': info['xesam:album'], - 'artist': info['xesam:artist'][0], - 'title': info['xesam:title'], - 'total': self._convert_seconds(info['mpris:length'] / 1e6), + 'album': info.get('xesam:album'), + 'artist': info.get('xesam:artist')[0], + 'title': info.get('xesam:title'), + 'total': self._convert_seconds(info.get('mpris:length') / 1e6), } def player_rhythmbox(self):