[Piuparts-commits] [piuparts] 09/17: p-s: quote arguments containing spaces

Holger Levsen holger at alioth.debian.org
Wed Nov 6 09:45:53 UTC 2013


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 0e1ba5c69a286be707b8bf5fa73425eb9dd3d3cf
Author: Andreas Beckmann <anbe at debian.org>
Date:   Tue Nov 5 21:28:01 2013 +0100

    p-s: quote arguments containing spaces
    
    for easy copy&paste manual rerun from logfile
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 piuparts-slave.py |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/piuparts-slave.py b/piuparts-slave.py
index 8f7498f..92f1fca 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -708,7 +708,7 @@ class Section:
             subdir = "untestable"
 
         if ret == 0:
-            output.write("Executing: %s\n" % " ".join(command))
+            output.write("Executing: %s\n" % " ".join(quote(command)))
             ret, f = run_test_with_timeout(command, MAX_WAIT_TEST_RUN)
             if not f or f[-1] != '\n':
                 f += '\n'
@@ -736,6 +736,10 @@ def log_name(package, version):
     return "%s_%s.log" % (package, version)
 
 
+def quote(vlist):
+    return ["'%s'" % x if ' ' in x else x for x in vlist]
+
+
 def run_test_with_timeout(cmd, maxwait, kill_all=True):
 
     def terminate_subprocess(p, kill_all):
@@ -775,7 +779,7 @@ def run_test_with_timeout(cmd, maxwait, kill_all=True):
                 except OSError:
                     pass
 
-    logging.debug("Executing: %s" % " ".join(cmd))
+    logging.debug("Executing: %s" % " ".join(quote(cmd)))
 
     stdout = ""
     p = subprocess.Popen(cmd, preexec_fn=os.setpgrp,
@@ -833,8 +837,8 @@ def create_chroot(config, tarball, distro):
             logging.info("Creating new tarball %s" % tarball)
             output.write(time.strftime("Start: %Y-%m-%d %H:%M:%S %Z\n\n",
                                        time.gmtime()))
-            output.write("Executing: " + " ".join(command) + "\n\n")
-            logging.debug("Executing: " + " ".join(command))
+            output.write("Executing: " + " ".join(quote(command)) + "\n\n")
+            logging.debug("Executing: " + " ".join(quote(command)))
             p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
             for line in p.stdout:
                 output.write(line)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list