[Piglit] [PATCH] summary.py: Make mako temporary directory user unique

Dylan Baker baker.dylan.c at gmail.com
Thu Oct 30 14:59:34 PDT 2014


Currently when a user runs piglit mako temp files are put in the OS
appropriate location. On Linux, this is /tmp/piglit. The problem is that
these files are owned by that user and unusable by a second user. This
works out fine for most use cases, but not for the case of a shared
piglit slave with multiple users.

This patch fixes the issue by creating a piglit-$(username) folder to
put the mako files in. For most users this will be transparent and have
no effect on them.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/summary.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/framework/summary.py b/framework/summary.py
index 3de934b..f4fd80d 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -29,6 +29,7 @@ import collections
 import tempfile
 import datetime
 import re
+import getpass
 from mako.template import Template
 
 # a local variable status exists, prevent accidental overloading by renaming
@@ -275,7 +276,9 @@ class Summary:
     uses methods to generate various kinds of output. The reference
     implementation is HTML output through mako, aptly named generateHTML().
     """
-    TEMP_DIR = path.join(tempfile.gettempdir(), "piglit/html-summary")
+    TEMP_DIR = path.join(tempfile.gettempdir(),
+                         "piglit-{}".format(getpass.getuser()),
+                         "html-summary")
     TEMPLATE_DIR = path.abspath(
         path.join(path.dirname(__file__), '..', 'templates'))
 
@@ -437,7 +440,6 @@ class Summary:
         heavy lifting, this method just passes it a bunch of dicts and lists
         of dicts, which mako turns into pretty HTML.
         """
-
         # Copy static files
         shutil.copy(path.join(self.TEMPLATE_DIR, "index.css"),
                     path.join(destination, "index.css"))
-- 
2.1.2



More information about the Piglit mailing list