changeset 451:eacfd3744d16

capture only stdout for treepkginfo
author Bjoern Ricks <bricks@intevation.de>
date Fri, 13 Aug 2010 14:16:50 +0000
parents 5c06e0a0d329
children 333232953771
files bin/publishdebianpackages.py treepkg/run.py
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/bin/publishdebianpackages.py	Wed Aug 11 07:45:26 2010 +0000
+++ b/bin/publishdebianpackages.py	Fri Aug 13 14:16:50 2010 +0000
@@ -18,7 +18,7 @@
 
 import treepkgcmd
 from treepkg.readconfig import read_config_section, convert_bool
-from treepkg.run import call, capture_output
+from treepkg.run import call, capture_stdout
 from treepkg.cmdexpand import cmdexpand
 from treepkg.publish import copy_arch_to_publishdir, prefix_for_remote_command,\
                             get_binary_arch
@@ -76,7 +76,7 @@
 def get_treepkg_info(variables):
     runremote = prefix_for_remote_command(variables["build_user"],
                                           variables["build_host"])
-    xml = capture_output(cmdexpand("@runremote $build_listpackages"
+    xml = capture_stdout(cmdexpand("@runremote $build_listpackages"
                                    " --newest=$num_newest"
                                    " --only-successful",
                                    runremote=runremote,
--- a/treepkg/run.py	Wed Aug 11 07:45:26 2010 +0000
+++ b/treepkg/run.py	Fri Aug 13 14:16:50 2010 +0000
@@ -67,3 +67,17 @@
     if proc.returncode != 0:
         raise SubprocessError(command, proc.returncode, output)
     return output
+
+def capture_stdout(command, **kw):
+    """Return the stdout and stderr of the command as a string
+
+    The command should be given as a list of strings to avoid problems
+    with shell quoting.  If the command exits with a return code other
+    than 0, a SubprocessError is raised.
+    """
+    proc = subprocess.Popen(command, stdout=subprocess.PIPE,
+                            stderr=subprocess.PIPE, **kw)
+    output, error = proc.communicate()
+    if proc.returncode != 0:
+        raise SubprocessError(command, proc.returncode, error)
+    return output
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)