summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2016-04-13 11:27:32 -0700
committerDylan Baker <dylan@pnwbakers.com>2016-05-05 15:15:07 -0700
commit11e4950c91505368ff90eb561eb5a3eec5d2502a (patch)
tree37206f6b1387c9d1e6b2222f58227ce76341e9b0
parentfe703e518510f24cc1da78eab249a152b9f66701 (diff)
python: Make mako template dirs robust
This puts the templates in a directory structure that makes them robust to both changes in python version and mako version. This fixes errors caused by downgrading mako, which isn't that common, unless you're running the unit tests with use the oldest supported mako, and may conflict with the compiled templates from the system mako. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r--framework/summary/html_.py14
-rw-r--r--generated_tests/templates/__init__.py11
2 files changed, 16 insertions, 9 deletions
diff --git a/framework/summary/html_.py b/framework/summary/html_.py
index 676fa1a8a..80bee82e0 100644
--- a/framework/summary/html_.py
+++ b/framework/summary/html_.py
@@ -25,13 +25,14 @@
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
+import errno
+import getpass
import os
import shutil
-import tempfile
-import getpass
import sys
-import errno
+import tempfile
+import mako
from mako.lookup import TemplateLookup
import six
@@ -49,8 +50,11 @@ __all__ = [
_TEMP_DIR = os.path.join(
tempfile.gettempdir(),
- "piglit-{}".format(getpass.getuser()),
- 'version-{}'.format(sys.version.split()[0]))
+ getpass.getuser(),
+ 'python-{}'.format(sys.version.split()[0]),
+ 'mako-{}'.format(mako.__version__),
+ 'summary',
+ 'html')
_TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), '../..', 'templates')
diff --git a/generated_tests/templates/__init__.py b/generated_tests/templates/__init__.py
index f974825b4..c7f32c225 100644
--- a/generated_tests/templates/__init__.py
+++ b/generated_tests/templates/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2014 Intel Corporation
+# Copyright (c) 2014-2016 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -26,15 +26,18 @@ import sys
import getpass
import tempfile
+import mako
from mako.template import Template
from mako.lookup import TemplateLookup
# Based on a similar setup in framework/summary
MAKO_TEMP_DIR = os.path.join(tempfile.gettempdir(),
- 'piglit-{0}'.format(getpass.getuser()),
- 'version-{0}'.format(sys.version.split()[0]),
- 'generators', 'templates')
+ getpass.getuser(),
+ 'piglit',
+ 'python-{}'.format(sys.version.split()[0]),
+ 'mako-{}'.format(mako.__version__),
+ 'generators')
TEMPLATE_DIR = os.path.abspath(os.path.dirname(__file__))