From 40e9a765eebc5c5754188338b8eb34059a054ebb Mon Sep 17 00:00:00 2001 From: Loys Ollivier Date: Wed, 6 Dec 2017 14:56:13 +0100 Subject: utils/agljobtemplate.py: Raise an error if jinja version is incorrect The jinja2 template calls needs a jinja version >= 2.9. Otherwise fails to create a correct output yaml file. Check for the jinja version at runtime. More precisely, check for a specific function that was added in 2.9 and raise an error if it does not exist. Change-Id: Ifd627a25dcfabdd639c53e1b29b891db8bff50c4 Signed-off-by: Loys Ollivier --- utils/agljobtemplate.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'utils') diff --git a/utils/agljobtemplate.py b/utils/agljobtemplate.py index 381f7f4..90bad13 100644 --- a/utils/agljobtemplate.py +++ b/utils/agljobtemplate.py @@ -48,6 +48,10 @@ class Agljobtemplate(object): RFS_TYPE = ['nbd', 'ramdisk'] def __init__(self, path=DEFAULT_PATH): + try: + from jinja2 import select_autoescape + except ImportError: + raise ImportError, "Please make sure your version of jinja2 is >= 2.9" self._template_path = os.path.normpath(path) if not (os.path.isdir(self._template_path) and os.access(self._template_path, os.F_OK)): raise OSError, "Cannot access {}".format(self._template_path) -- cgit 1.2.3-korg