changeset 658a55b36ce5 in /home/hg/repos/gajim-plugins

author: lovetox <[email protected]>
branches: 
details:gajim-plugins?cmd=changeset;node=658a55b36ce5
description: Further improve import error handling

diffstat:

 omemo/__init__.py |  21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diffs (51 lines):

diff -r 866cf8a00b63 -r 658a55b36ce5 omemo/__init__.py
--- a/omemo/__init__.py Wed Sep 07 00:22:20 2016 +0200
+++ b/omemo/__init__.py Wed Sep 14 22:43:10 2016 +0200
@@ -58,36 +58,37 @@
 log = logging.getLogger('gajim.plugin_system.omemo')
 
 try:
-    from .omemo.state import OmemoState
-except Exception as e:
-    log.error(e)
-    ERROR_MSG = 'Error: ' + str(e)
-
-try:
-    import google.protobuf
+    prototest = __import__('google.protobuf')
 except Exception as e:
     log.error(e)
     ERROR_MSG = PROTOBUF_MISSING
 
 try:
-    import axolotl
+    axolotltest = __import__('axolotl')
 except Exception as e:
     log.error(e)
     ERROR_MSG = AXOLOTL_MISSING
 
+if not ERROR_MSG:
+    try:
+        from .omemo.state import OmemoState
+    except Exception as e:
+        log.error(e)
+        ERROR_MSG = 'Error: ' + str(e)
+
 GAJIM_VER = gajim.config.get('version')
 
 if os.name != 'nt':
     try:
         SETUPTOOLS_MISSING = False
-        from pkg_resources import parse_version
+        pkg = __import__('pkg_resources')
     except Exception as e:
         log.error(e)
         SETUPTOOLS_MISSING = True
         ERROR_MSG = 'You are missing the Setuptools package.'
 
     if not SETUPTOOLS_MISSING:
-        if parse_version(GAJIM_VER) < parse_version('0.16.5'):
+        if pkg.parse_version(GAJIM_VER) < pkg.parse_version('0.16.5'):
             ERROR_MSG = GAJIM_VERSION
 
 # pylint: disable=no-init
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to