]> git.ipfire.org Git - people/jschlag/nitsi.git/commitdiff
Improve file checking
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sun, 9 Sep 2018 10:31:41 +0000 (12:31 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Sun, 9 Sep 2018 10:31:41 +0000 (12:31 +0200)
The loglevel is now customizable due to the fact that not all missing
files are an error.
Also some debug messages were added.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
src/nitsi/test.py

index 33f27f3e2c19c8ec48001d20fcd598c26301b417..196b2fbb398aa57b97172459fbdd968b148c0715 100755 (executable)
@@ -53,7 +53,7 @@ class Test():
 
 
         # We can also go on without a settings file
-        self.settings_file = self.check_file(self.settings_file)
+        self.settings_file = self.check_file(self.settings_file, log_level=logging.WARNING)
 
         self.recipe_file = self.check_file(self.recipe_file)
         if not self.recipe_file:
@@ -77,11 +77,12 @@ class Test():
     # Checks the file:
     # is the path valid ?
     # returns an absolut path, when the file is valid, None when not
-    def check_file(self, file):
+    def check_file(self, file, log_level=logging.ERROR):
         if file:
+            logger.debug("File to check is: {}".format(file))
             if not os.path.isfile(file):
-                err_msg = "No such file: {}".format(self.recipe_file)
-                logger.error(err_msg)
+                err_msg = "No such file: {}".format(file)
+                logger.log(log_level,err_msg)
                 return None
             if not os.path.isabs(file):
                file = os.path.abspath(file)