[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. cce7ad0a42462ba243a8c7052bf2f0dc80e133e3

Holger Levsen holger at layer-acht.org
Mon Sep 26 19:23:51 UTC 2011


The following commit has been merged in the develop branch:
commit cce7ad0a42462ba243a8c7052bf2f0dc80e133e3
Author: Holger Levsen <holger at layer-acht.org>
Date:   Mon Sep 26 21:22:56 2011 +0200

    piuparts-slave.py: Replace deprecated os.popen2 with subprocess.Popen. (Closes: 640646)

diff --git a/debian/changelog b/debian/changelog
index 47e8408..af8d4ea 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,10 @@ piuparts (0.42) UNRELEASED; urgency=low
   * piuparts.py: apply patch by Stefano Rivera to properly install and remove
     logrotate. Thanks Stefano! (Closes: #638832)
 
+  [ 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 771f595..730b29f 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -28,6 +28,7 @@ import sys
 import stat
 import time
 import logging
+import subprocess
 import ConfigParser
 
 import piupartslib.conf
@@ -140,18 +141,16 @@ class Slave:
     def connect_to_master(self, log_file):
         logging.info("Connecting to %s" % self._master_host)
         if self._master_user:
-            user = "-l " + self._master_user
+            user = self._master_user + "@"
         else:
             user = ""
-        (self._to_master, self._from_master) = \
-            os.popen2("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))
-
+        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
         line = self._readline()
         if line != "hello\n":
             raise MasterDidNotGreet()
@@ -448,8 +447,9 @@ def fetch_packages_file(config, distro):
     arch = config["arch"]
     if not arch:
         # Try to figure it out ourselves, using dpkg
-        vin, vout = os.popen2("dpkg --print-architecture")
-        arch = vout.read().rstrip()
+        p = subprocess.Popen(["dpkg", "--print-architecture"], 
+                             stdout=subprocess.PIPE)
+        arch = p.stdout.read().rstrip()
     packages_url = \
         "%s/dists/%s/main/binary-%s/Packages.bz2" % (mirror, distro, arch)
 

-- 
piuparts git repository



More information about the Piuparts-commits mailing list