Mercurial > treepkg > treepkg
comparison treepkg/run.py @ 451:eacfd3744d16
capture only stdout for treepkginfo
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Fri, 13 Aug 2010 14:16:50 +0000 |
parents | 2910051b91f7 |
children |
comparison
equal
deleted
inserted
replaced
450:5c06e0a0d329 | 451:eacfd3744d16 |
---|---|
65 stderr=subprocess.STDOUT, **kw) | 65 stderr=subprocess.STDOUT, **kw) |
66 output = proc.communicate()[0] | 66 output = proc.communicate()[0] |
67 if proc.returncode != 0: | 67 if proc.returncode != 0: |
68 raise SubprocessError(command, proc.returncode, output) | 68 raise SubprocessError(command, proc.returncode, output) |
69 return output | 69 return output |
70 | |
71 def capture_stdout(command, **kw): | |
72 """Return the stdout and stderr of the command as a string | |
73 | |
74 The command should be given as a list of strings to avoid problems | |
75 with shell quoting. If the command exits with a return code other | |
76 than 0, a SubprocessError is raised. | |
77 """ | |
78 proc = subprocess.Popen(command, stdout=subprocess.PIPE, | |
79 stderr=subprocess.PIPE, **kw) | |
80 output, error = proc.communicate() | |
81 if proc.returncode != 0: | |
82 raise SubprocessError(command, proc.returncode, error) | |
83 return output |