[Piuparts-commits] [piuparts] 02/12: p, p-s: refactor quote_spaces() into command2string()
Holger Levsen
holger at layer-acht.org
Mon Mar 13 12:39:52 UTC 2017
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch develop
in repository piuparts.
commit ced7072e4e02441f4e6bb43e8bfba6b3e7a2585e
Author: Andreas Beckmann <anbe at debian.org>
Date: Tue Mar 7 01:01:31 2017 +0100
p, p-s: refactor quote_spaces() into command2string()
Signed-off-by: Andreas Beckmann <anbe at debian.org>
Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
piuparts-slave.py | 13 +++++++------
piuparts.py | 7 ++++---
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/piuparts-slave.py b/piuparts-slave.py
index 1a5cef4..9ebb7d7 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -755,7 +755,7 @@ class Section:
subdir = "untestable"
if ret == 0:
- output.write("Executing: %s\n" % " ".join(quote_spaces(command)))
+ output.write("Executing: %s\n" % command2string(command))
ret, f = run_test_with_timeout(command, MAX_WAIT_TEST_RUN)
if not f or f[-1] != '\n':
f += '\n'
@@ -783,8 +783,9 @@ def log_name(package, version):
return "%s_%s.log" % (package, version)
-def quote_spaces(vlist):
- return [pipes.quote(x) for x in vlist]
+def command2string(command):
+ """Quote s.t. copy+paste from the logfile gives a runnable command in the shell."""
+ return " ".join([pipes.quote(arg) for arg in command])
def run_test_with_timeout(cmd, maxwait, kill_all=True):
@@ -826,7 +827,7 @@ def run_test_with_timeout(cmd, maxwait, kill_all=True):
except OSError:
pass
- logging.debug("Executing: %s" % " ".join(quote_spaces(cmd)))
+ logging.debug("Executing: %s" % command2string(cmd))
stdout = ""
p = subprocess.Popen(cmd, preexec_fn=os.setpgrp,
@@ -884,8 +885,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_spaces(command)) + "\n\n")
- logging.debug("Executing: " + " ".join(quote_spaces(command)))
+ output.write("Executing: " + command2string(command) + "\n\n")
+ logging.debug("Executing: " + command2string(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 4972548..2db1b4e 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -487,8 +487,9 @@ def indent_string(str):
return "\n".join([" " + line for line in str.split("\n")])
-def quote_spaces(vlist):
- return [pipes.quote(x) for x in vlist]
+def command2string(command):
+ """Quote s.t. copy+paste from the logfile gives a runnable command in the shell."""
+ return " ".join([pipes.quote(arg) for arg in command])
def unqualify(packages):
@@ -3310,7 +3311,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(quote_spaces(sys.argv)))
+ logging.info("Command line arguments: %s" % command2string(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