Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: subprocess2.py

Issue 8539015: Add most of testing improvements without the tee-specific tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/subprocess2_test.py » ('j') | tests/subprocess2_test.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding=utf8 1 # coding=utf8
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Collection of subprocess wrapper functions. 5 """Collection of subprocess wrapper functions.
6 6
7 In theory you shouldn't need anything else in subprocess, or this module failed. 7 In theory you shouldn't need anything else in subprocess, or this module failed.
8 """ 8 """
9 9
10 from __future__ import with_statement 10 from __future__ import with_statement
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 while proc.returncode is None: 239 while proc.returncode is None:
240 proc.poll() 240 proc.poll()
241 if timeout and (time.time() - start) > timeout: 241 if timeout and (time.time() - start) > timeout:
242 proc.kill() 242 proc.kill()
243 proc.wait() 243 proc.wait()
244 # It's -9 on linux and 1 on Windows. Standardize to TIMED_OUT. 244 # It's -9 on linux and 1 on Windows. Standardize to TIMED_OUT.
245 proc.returncode = TIMED_OUT 245 proc.returncode = TIMED_OUT
246 time.sleep(0.001) 246 time.sleep(0.001)
247 # Now that the process died, reset the cursor and read the file. 247 # Now that the process died, reset the cursor and read the file.
248 buff.seek(0) 248 buff.seek(0)
249 out = [buff.read(), None] 249 out = (buff.read(), None)
250 return out, proc.returncode 250 return out, proc.returncode
251 251
252 252
253 def call(args, **kwargs): 253 def call(args, **kwargs):
254 """Emulates subprocess.call(). 254 """Emulates subprocess.call().
255 255
256 Automatically convert stdout=PIPE or stderr=PIPE to VOID. 256 Automatically convert stdout=PIPE or stderr=PIPE to VOID.
257 In no case they can be returned since no code path raises 257 In no case they can be returned since no code path raises
258 subprocess2.CalledProcessError. 258 subprocess2.CalledProcessError.
259 """ 259 """
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 Captures stdout of a process call and returns stdout only. 302 Captures stdout of a process call and returns stdout only.
303 303
304 - Throws if return code is not 0. 304 - Throws if return code is not 0.
305 - Works even prior to python 2.7. 305 - Works even prior to python 2.7.
306 - Blocks stdin by default if not specified since no output will be visible. 306 - Blocks stdin by default if not specified since no output will be visible.
307 - As per doc, "The stdout argument is not allowed as it is used internally." 307 - As per doc, "The stdout argument is not allowed as it is used internally."
308 """ 308 """
309 kwargs.setdefault('stdin', VOID) 309 kwargs.setdefault('stdin', VOID)
310 return check_call_out(args, stdout=PIPE, **kwargs)[0] 310 return check_call_out(args, stdout=PIPE, **kwargs)[0]
OLDNEW
« no previous file with comments | « no previous file | tests/subprocess2_test.py » ('j') | tests/subprocess2_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698