[Piuparts-commits] [piuparts] 06/20: improve quoting of spaces

Holger Levsen holger at moszumanska.debian.org
Sat Nov 23 20:23:34 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 d87768ea228eb0ca4c46a757176e195a640f296a
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sat Nov 9 18:34:07 2013 +0100

    improve quoting of spaces
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 piuparts-slave.py | 10 +++++-----
 piuparts.py       |  7 +++++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/piuparts-slave.py b/piuparts-slave.py
index 9bd7cea..59b0d33 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -727,7 +727,7 @@ class Section:
             subdir = "untestable"
 
         if ret == 0:
-            output.write("Executing: %s\n" % " ".join(quote(command)))
+            output.write("Executing: %s\n" % " ".join(quote_spaces(command)))
             ret, f = run_test_with_timeout(command, MAX_WAIT_TEST_RUN)
             if not f or f[-1] != '\n':
                 f += '\n'
@@ -755,7 +755,7 @@ def log_name(package, version):
     return "%s_%s.log" % (package, version)
 
 
-def quote(vlist):
+def quote_spaces(vlist):
     return ["'%s'" % x if ' ' in x else x for x in vlist]
 
 
@@ -798,7 +798,7 @@ def run_test_with_timeout(cmd, maxwait, kill_all=True):
                 except OSError:
                     pass
 
-    logging.debug("Executing: %s" % " ".join(quote(cmd)))
+    logging.debug("Executing: %s" % " ".join(quote_spaces(cmd)))
 
     stdout = ""
     p = subprocess.Popen(cmd, preexec_fn=os.setpgrp,
@@ -856,8 +856,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(quote(command)) + "\n\n")
-            logging.debug("Executing: " + " ".join(quote(command)))
+            output.write("Executing: " + " ".join(quote_spaces(command)) + "\n\n")
+            logging.debug("Executing: " + " ".join(quote_spaces(command)))
             p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
             for line in p.stdout:
                 output.write(line)
diff --git a/piuparts.py b/piuparts.py
index 7b489ec..d7e6a2e 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -434,6 +434,10 @@ def indent_string(str):
     return "\n".join(["  " + line for line in str.split("\n")])
 
 
+def quote_spaces(vlist):
+    return ["'%s'" % x if ' ' in x else x for x in vlist]
+
+
 class Alarm(Exception):
     pass
 
@@ -457,7 +461,6 @@ def run(command, ignore_errors=False, timeout=0):
         p.wait()
 
     assert type(command) == type([])
-    command = [x for x in command if x] # Delete any empty argument
     logging.debug("Starting command: %s" % command)
     env = os.environ.copy()
     env["LC_ALL"] = "C"
@@ -3059,7 +3062,7 @@ def main():
     logging.info("The FAQ also explains how to contact us in case you think piuparts is wrong.")
     logging.info("-" * 78)
     logging.info("piuparts version %s starting up." % VERSION)
-    logging.info("Command line arguments: '%s'" % "' '".join(sys.argv))
+    logging.info("Command line arguments: %s" % " ".join(quote_spaces(sys.argv)))
     logging.info("Running on: %s %s %s %s %s" % os.uname())
 
     # Make sure debconf does not ask questions and stop everything.

-- 
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