[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. eda668423fa87898c59d1075118693714aa5a053
Holger Levsen
holger at layer-acht.org
Fri Dec 23 10:25:16 UTC 2011
The following commit has been merged in the master branch:
commit 5847f4571589b4eaefa8ac6e43d5af051b401197
Author: Holger Levsen <holger at layer-acht.org>
Date: Tue Sep 27 12:27:34 2011 +0200
piuparts-slave.py: Replace deprecated os.popen2 with subprocess.Popen, thanks to Scott Schaefer and Evgeni Golov for their patches. (Closes: #640646)
cherry picked (and merged) from 4ea9e7fff5f10e78cd56a0e0d1fa17c2abc1e582 and from cce7ad0a42462ba243a8c7052bf2f0dc80e133e3
diff --git a/debian/changelog b/debian/changelog
index 73298f4..3500141 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,16 +6,15 @@ piuparts (0.42) UNRELEASED; urgency=low
- apply patch by Stefano Rivera to properly install and remove
logrotate. Thanks Stefano! (Closes: #638832)
* Remove Debian.NEWS entry about source in git. (Closes: #640121)
+ * piuparts-slave.py: Replace deprecated os.popen2 with subprocess.Popen,
+ thanks to Scott Schaefer and Evgeni Golov for their patches.
+ (Closes: #640646)
[ Mika Pflüger ]
* piuparts-analyze.py: Rewrite to use python-debianbts to analyze if bugs
are filed already.
* debian/control: Add python-apt and python-debianbts to piuparts depends.
- [ Scott Schaefer ]
- * piuparts-slave.py: Replace deprecated os.popen2 with subprocess.Popen.
- (Closes: #640646)
-
-- Holger Levsen <holger at debian.org> Sun, 28 Aug 2011 09:50:12 +0200
piuparts (0.41) unstable; urgency=low
diff --git a/piuparts-slave.py b/piuparts-slave.py
index 730b29f..0d09ba7 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -28,8 +28,9 @@ import sys
import stat
import time
import logging
-import subprocess
import ConfigParser
+import shlex
+import subprocess
import piupartslib.conf
import piupartslib.packagesdb
@@ -144,13 +145,18 @@ class Slave:
user = self._master_user + "@"
else:
user = ""
- ssh_cmdline = "cd %s; %s 2> %s.$$ && rm %s.$$" % \
- (self._master_directory or ".",
- self._master_command, log_file, log_file)
- p = subprocess.Popen(["ssh", user + self._master_host, ssh_cmdline],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- self._to_master = p.stdin
- self._from_master = p.stdout
+ cmd = "ssh %s %s 'cd %s; %s 2> %s.$$ && rm %s.$$'" %
+ (self._master_host,
+ user,
+ self._master_directory or ".",
+ self._master_command,
+ log_file,
+ log_file)
+ cmd = shlex.split(cmd)
+ f = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=PIPE,
+ close_fds=True)
+ (self._to_master, self._from_master) = (f.stdin, f.stdout)
+
line = self._readline()
if line != "hello\n":
raise MasterDidNotGreet()
@@ -363,10 +369,10 @@ def test_package(config, package, packages_files):
logging.debug("Executing: %s" % command)
output.write("Executing: %s\n" % command)
- f = os.popen("{ %s; } 2>&1" % command, "r")
- for line in f:
+ f = execute_command(command)
+ for line in f.communicate()[0].splitlines():
output.write(line)
- status = f.close()
+ status = f.returncode
if status is None:
status = 0
else:
@@ -386,11 +392,11 @@ def test_package(config, package, packages_files):
logging.debug("Executing: %s" % command)
output.write("\nExecuting: %s\n" % command)
- f = os.popen("{ %s; } 2>&1" % command, "r")
- for line in f:
+ f = execute_command(command)
+ for line in f.communicate()[0].splitlines():
output.write(line)
output.flush()
- status = f.close()
+ status = f.returncode
if status is None:
status = 0
@@ -411,8 +417,8 @@ def create_chroot(config, tarball, distro):
command = "%s -ad %s -s %s.new -m %s hello" % \
(config["piuparts-cmd"], distro, tarball, config["mirror"])
logging.debug("Executing: " + command)
- f = os.popen("{ %s; } 2>&1" % command, "r")
- for line in f:
+ f = execute_command(command)
+ for line in f.communicate()[0].splitlines():
logging.debug(">> " + line.rstrip())
f.close()
if os.path.exists(tarball + ".new"):
@@ -447,9 +453,8 @@ def fetch_packages_file(config, distro):
arch = config["arch"]
if not arch:
# Try to figure it out ourselves, using dpkg
- p = subprocess.Popen(["dpkg", "--print-architecture"],
- stdout=subprocess.PIPE)
- arch = p.stdout.read().rstrip()
+ vout = execute_command("dpkg --print-architecture").communicate()[0]
+ arch = vout.strip()
packages_url = \
"%s/dists/%s/main/binary-%s/Packages.bz2" % (mirror, distro, arch)
@@ -466,6 +471,10 @@ def create_file(filename, contents):
f.write(contents)
f.close()
+def execute_command(cmd):
+ cmd = shlex.split(cmd)
+ f = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ return f
def main():
setup_logging(logging.INFO, None)
--
piuparts git repository
More information about the Piuparts-commits
mailing list