]> git.ipfire.org Git - nitsi.git/commitdiff
Fix check if we get correct files for settings and recipe
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 23 Jun 2018 07:49:45 +0000 (09:49 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 23 Jun 2018 07:49:45 +0000 (09:49 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
src/nitsi/test.py

index 19c8c405e72bed17cd9807563068f28103c1a624..9cc1188c2b1bdb09144af37055b0eecb1758104e 100755 (executable)
@@ -69,13 +69,20 @@ class Test():
             else:
                 self.settings_file = settings_file
 
-        if not os.path.isfile(self.settings_file):
-            logger.error("No such file: {}".format(self.settings_file))
-            raise TestException("No settings file found")
+        # We can also go on without a settings file
+        if self.settings_file:
+            if not os.path.isfile(self.settings_file):
+                logger.error("No such file: {}".format(self.settings_file))
+                raise TestException("No settings file found")
+
+        # os.path.isfile fails if self.recipe_file is None so we need to catch exceptions here
+        try:
+            if not (self.recipe_file or os.path.isfile(self.recipe_file)):
+                logger.error("No such file: {}".format(self.recipe_file))
+                raise TestException("No recipe file found")
+        except BaseException:
+            pass
 
-        if not os.path.isfile(self.recipe_file):
-            logger.error("No such file: {}".format(self.recipe_file))
-            raise TestException("No recipe file found")
 
         # Init logging
         if dir: