]> git.ipfire.org Git - nitsi.git/blobdiff - src/nitsi/recipe.py
Allow including of recipe files
[nitsi.git] / src / nitsi / recipe.py
index f76066a96e1b2638727c1a8f2028780a058de58e..e1e2af8904a4edb721ca01c942b0cef623a6a9e0 100644 (file)
@@ -15,14 +15,15 @@ class RecipeExeption(Exception):
 
 # Should read the test, check if the syntax are valid
 # and return tuples with the ( host, command ) structure
-class recipe():
+class Recipe():
     def __init__(self, path, circle=[], machines=[]):
         self.recipe_file = path
         try:
             self.path = os.path.dirname(self.recipe_file)
+            self.path = os.path.abspath(self.path)
             self.name = os.path.basename(self.path)
         except BaseException as e:
-            logger.error("Failed to get the name of the test to this recipe")
+            logger.error("Failed to get the path to this recipe")
             raise e
 
         self.log = logger.getChild(self.name)
@@ -102,12 +103,16 @@ class recipe():
             if machine == "include":
                 path = cmd.strip()
                 path = os.path.normpath(self.path + "/" + path)
-                path = path + "/recipe"
+
+                # If we did not get a valid file we asume that we get a valid path to a test.
+                if os.path.isdir(path):
+                    path = path + "/recipe"
+
                 if path in self.circle:
                     self.log.error("Detect import loop!")
                     raise RecipeExeption("Detect import loop!")
                 self.circle.append(path)
-                recipe_to_include = recipe(path, circle=self.circle)
+                recipe_to_include = Recipe(path, circle=self.circle)
 
             if machine == "include":
                 self._recipe.extend(recipe_to_include.recipe)