]> git.ipfire.org Git - nitsi.git/blobdiff - src/nitsi/test.py
Make config parsing more robust against errors
[nitsi.git] / src / nitsi / test.py
index 5682752f7cb73537644f52acb89e7ebc9607a858..8d29e3047cb57209580d62325b51b6b1376ba319 100755 (executable)
@@ -40,12 +40,21 @@ class Test():
             raise TestException("No recipe file found")
 
     def read_settings(self):
-        self.config = configparser.ConfigParser()
-        self.config.read(self.settings_file)
+        try:
+            self.config = configparser.ConfigParser()
+            self.config.read(self.settings_file)
+        except BaseException as e:
+            self.log.error("Failed to parse the config")
+            raise e
+
         self.name = self.config["DEFAULT"]["name"]
         self.description = self.config["DEFAULT"]["description"]
         self.copy_to = self.config["DEFAULT"]["copy_to"]
         self.copy_from = self.config["DEFAULT"]["copy_from"]
+        self.virtual_environ_path = self.config["VIRTUAL_ENVIRONMENT"]["path"]
+        self.virtual_environ_path = os.path.normpath(self.path + "/" + self.virtual_environ_path)
+
+        # Parse copy_from setting
         self.copy_from = self.copy_from.split(",")
 
         tmp = []
@@ -67,9 +76,7 @@ class Test():
 
         self.copy_from = tmp
 
-        self.virtual_environ_name = self.config["VIRTUAL_ENVIRONMENT"]["name"]
-        self.virtual_environ_path = self.config["VIRTUAL_ENVIRONMENT"]["path"]
-        self.virtual_environ_path = os.path.normpath(self.path + "/" + self.virtual_environ_path)
+
 
     def virtual_environ_setup(self):
         self.virtual_environ = virtual_environ.Virtual_environ(self.virtual_environ_path)