From 7e751d45c87488979468a54a6b574f56a7a11612 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 6 Mar 2018 10:37:43 +1000 Subject: [PATCH] base: if gi.repository fails to import, warn We need python 3.6 but old Ubuntus only have 3.5. 3.6 can be installed (and thus we get past the 3.6 sys.version check), but the gi.repository backports are in various states of disarray (see #103 and #104). And Python (and in particular gi) makes it hard for users to distinguish between "the dependencies are a mess" and "this is a bug in tuhi". So let's catch any error during gi.repository import and print a warning to the user, in the hope of getting less bugs caused by Ubuntu frankenpythons. Still won't fix issues like #104, but I'm not sure how to test for those errors. Related to #103 --- tuhi/base.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tuhi/base.py b/tuhi/base.py index acb7054..afea93f 100644 --- a/tuhi/base.py +++ b/tuhi/base.py @@ -16,7 +16,16 @@ import enum import logging import sys import time -from gi.repository import GObject, GLib +try: + from gi.repository import GObject, GLib +except Exception as e: + print(f'************ Importing gi.repository failed **********') + print(f'* This is an issue with the gi module, not with tuhi *') + print(f'******************************************************') + print(f'The full exception is below:') + print(f'') + raise e + from tuhi.dbusserver import TuhiDBusServer from tuhi.ble import BlueZDeviceManager