commit:     3acb0ce6d38d02915f142f2ec69c9c24fb1ec99c
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 24 14:22:28 2014 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Mon Nov 24 14:22:28 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=3acb0ce6

[g_sorcery/g_sorcery.py] check backend initialization

---
 g_sorcery/g_sorcery.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index 76ecf82..b41adfb 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -4,9 +4,9 @@
 """
     g_sorcery.py
     ~~~~~~~~~~~~
-    
+
     the main module
-    
+
     :copyright: (c) 2013 by Jauhien Piatlicki
     :license: GPL-2, see LICENSE for more details.
 """
@@ -46,6 +46,10 @@ def main():
         return -1
     backend = get_backend(config['package'])
 
+    if not backend:
+        logger.error("backend initialization failed, exiting")
+        return -1
+
     config_file = None
     for path in '.', '~', '/etc/g-sorcery':
         config_file = os.path.join(path, "g-sorcery.cfg")
@@ -57,7 +61,7 @@ def main():
     if not config_file:
         logger.error('no global config file\n')
         return -1
-    
+
     global_config = configparser.ConfigParser()
     global_config.read(config_file)
 
@@ -74,7 +78,7 @@ def get_backend(package):
     except ImportError as error:
         logger.error("error importing backend: " + str(error))
         return None
-    
+
     return module
 
 

Reply via email to