From 70068c0f4bfcf6e385349ee601f2705ce44cb86a Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 10 Apr 2013 23:57:57 +0200 Subject: [PATCH] mpris: Only import 'indicate' if $DISPLAY is set This avoids printing of the following error message: ImportError: could not import gtk.gdk Fixes #311 --- mopidy/frontends/mpris/actor.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mopidy/frontends/mpris/actor.py b/mopidy/frontends/mpris/actor.py index 92805bd3..fae8618f 100644 --- a/mopidy/frontends/mpris/actor.py +++ b/mopidy/frontends/mpris/actor.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import logging +import os import pykka @@ -10,10 +11,14 @@ from mopidy.frontends.mpris import objects logger = logging.getLogger('mopidy.frontends.mpris') try: - import indicate -except ImportError as import_error: - indicate = None # noqa - logger.debug('Startup notification will not be sent (%s)', import_error) + indicate = None + if 'DISPLAY' in os.environ: + import indicate +except ImportError: + pass + +if indicate is None: + logger.debug('Startup notification will not be sent') class MprisFrontend(pykka.ThreadingActor, CoreListener):