From bc97f6a941f1ca87e98e9dbd2d4d5f6c1787e838 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com>
Date: Fri, 26 Oct 2018 01:45:43 +0200
Subject: [PATCH] Guard GeoClue import

- So we dont have to check on module import if GeoClue is installed
---
 gajim/common/dbus/location.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gajim/common/dbus/location.py b/gajim/common/dbus/location.py
index 1a1da8ce4e..424583dabb 100644
--- a/gajim/common/dbus/location.py
+++ b/gajim/common/dbus/location.py
@@ -14,15 +14,13 @@
 # You should have received a copy of the GNU General Public License
 # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 
-from datetime import datetime
 import logging
+from datetime import datetime
+
+from gi.repository import GLib
 
 from gajim.common import app
 
-import gi
-gi.require_version('Geoclue', '2.0')
-from gi.repository import Geoclue
-from gi.repository import GLib
 
 log = logging.getLogger('gajim.c.dbus.location')
 
@@ -102,5 +100,10 @@ class LocationListener:
 
 
 def enable():
+    if not app.is_installed('GEOCLUE'):
+        log.warning('GeoClue not installed')
+        return
+
+    from gi.repository import Geoclue
     listener = LocationListener.get()
     listener.start()
-- 
GitLab