# HG changeset patch # User Bjoern Ricks # Date 1281709010 0 # Node ID eacfd3744d16776e002529de393f42fa4e1dd912 # Parent 5c06e0a0d329ac34e8430fd1c8896d63b61182af capture only stdout for treepkginfo diff -r 5c06e0a0d329 -r eacfd3744d16 bin/publishdebianpackages.py --- 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, diff -r 5c06e0a0d329 -r eacfd3744d16 treepkg/run.py --- 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