##// END OF EJS Templates
new util that also passes back the returncode
Paul Ivanov -
Show More
@@ -139,13 +139,31 b' def getoutputerror(cmd):'
139 stdout : str
139 stdout : str
140 stderr : str
140 stderr : str
141 """
141 """
142 return get_output_error_code(cmd)[:2]
142
143
143 out_err = process_handler(cmd, lambda p: p.communicate())
144 def get_output_error_code(cmd):
145 """Return (standard output, standard error, return code) of executing cmd
146 in a shell.
147
148 Accepts the same arguments as os.system().
149
150 Parameters
151 ----------
152 cmd : str
153 A command to be executed in the system shell.
154
155 Returns
156 -------
157 stdout : str
158 stderr : str
159 returncode: int
160 """
161
162 out_err, p = process_handler(cmd, lambda p: (p.communicate(), p))
144 if out_err is None:
163 if out_err is None:
145 return '', ''
164 return '', '', p.returncode
146 out, err = out_err
165 out, err = out_err
147 return py3compat.bytes_to_str(out), py3compat.bytes_to_str(err)
166 return py3compat.bytes_to_str(out), py3compat.bytes_to_str(err), p.returncode
148
149
167
150 def arg_split(s, posix=False, strict=True):
168 def arg_split(s, posix=False, strict=True):
151 """Split a command line's arguments in a shell-like manner.
169 """Split a command line's arguments in a shell-like manner.
@@ -27,7 +27,7 b' else:'
27 from ._process_posix import _find_cmd, system, getoutput, arg_split
27 from ._process_posix import _find_cmd, system, getoutput, arg_split
28
28
29
29
30 from ._process_common import getoutputerror
30 from ._process_common import getoutputerror, get_output_error_code
31
31
32 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
33 # Code
33 # Code
General Comments 0
You need to be logged in to leave comments. Login now