Replace tempfile by mktemp in QA code
authorThomas Thrainer <thomasth@google.com>
Tue, 25 Jun 2013 15:26:13 +0000 (17:26 +0200)
committerThomas Thrainer <thomasth@google.com>
Wed, 26 Jun 2013 12:34:11 +0000 (14:34 +0200)
The tempfile command only exists in Debian. In order to run the VCluster
QA also on Fedora, replace its use by mktemp.

Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

qa/qa_utils.py

index 7ec0d49..bcef97f 100644 (file)
@@ -370,7 +370,8 @@ def UploadFile(node, src):
   # Make sure nobody else has access to it while preserving local permissions
   mode = os.stat(src).st_mode & 0700
 
-  cmd = ('tmp=$(tempfile --mode %o --prefix gnt) && '
+  cmd = ('tmp=$(mktemp --tmpdir gnt.XXXXXX) && '
+         'chmod %o "${tmp}" && '
          '[[ -f "${tmp}" ]] && '
          'cat > "${tmp}" && '
          'echo "${tmp}"') % mode
@@ -397,7 +398,8 @@ def UploadData(node, data, mode=0600, filename=None):
   if filename:
     tmp = "tmp=%s" % utils.ShellQuote(filename)
   else:
-    tmp = "tmp=$(tempfile --mode %o --prefix gnt)" % mode
+    tmp = ('tmp=$(mktemp --tmpdir gnt.XXXXXX) && '
+           'chmod %o "${tmp}"') % mode
   cmd = ("%s && "
          "[[ -f \"${tmp}\" ]] && "
          "cat > \"${tmp}\" && "
@@ -422,7 +424,7 @@ def BackupFile(node, path):
   """
   vpath = MakeNodePath(node, path)
 
-  cmd = ("tmp=$(tempfile --prefix .gnt --directory=$(dirname %s)) && "
+  cmd = ("tmp=$(mktemp .gnt.XXXXXX --tmpdir=$(dirname %s)) && "
          "[[ -f \"$tmp\" ]] && "
          "cp %s $tmp && "
          "echo $tmp") % (utils.ShellQuote(vpath), utils.ShellQuote(vpath))