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

Side by Side Diff: subprocess2.py

Issue 7858001: Update docstrings w.r.t. subprocess2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 3 months 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 | « gclient_utils.py ('k') | no next file » | no next file with comments »
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 env = env.copy() 125 env = env.copy()
126 def fix_lang(name): 126 def fix_lang(name):
127 if not is_english(name): 127 if not is_english(name):
128 env[name] = 'en_US.UTF-8' 128 env[name] = 'en_US.UTF-8'
129 fix_lang('LANG') 129 fix_lang('LANG')
130 fix_lang('LANGUAGE') 130 fix_lang('LANGUAGE')
131 return env 131 return env
132 132
133 133
134 def Popen(args, **kwargs): 134 def Popen(args, **kwargs):
135 """Wraps subprocess.Popen(). 135 """Wraps subprocess.Popen() with various workarounds.
136 136
137 Returns a subprocess.Popen object. 137 Returns a subprocess.Popen object.
138 138
139 - Forces English output since it's easier to parse the stdout if it is always 139 - Forces English output since it's easier to parse the stdout if it is always
140 in English. 140 in English.
141 - Sets shell=True on windows by default. You can override this by forcing 141 - Sets shell=True on windows by default. You can override this by forcing
142 shell parameter to a value. 142 shell parameter to a value.
143 - Adds support for VOID to not buffer when not needed. 143 - Adds support for VOID to not buffer when not needed.
144 144
145 Note: Popen() can throw OSError when cwd or args[0] doesn't exist. 145 Note: Popen() can throw OSError when cwd or args[0] doesn't exist. Translate
146 exceptions generated by cygwin when it fails trying to emulate fork().
146 """ 147 """
147 # Make sure we hack subprocess if necessary. 148 # Make sure we hack subprocess if necessary.
148 hack_subprocess() 149 hack_subprocess()
149 add_kill() 150 add_kill()
150 151
151 env = get_english_env(kwargs.get('env')) 152 env = get_english_env(kwargs.get('env'))
152 if env: 153 if env:
153 kwargs['env'] = env 154 kwargs['env'] = env
154 if kwargs.get('shell') is None: 155 if kwargs.get('shell') is None:
155 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the 156 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 - Works even prior to python 2.7. 303 - Works even prior to python 2.7.
303 - Blocks stdin by default since no output will be visible. 304 - Blocks stdin by default since no output will be visible.
304 """ 305 """
305 if kwargs.get('stdin') is None: 306 if kwargs.get('stdin') is None:
306 kwargs['stdin'] = VOID 307 kwargs['stdin'] = VOID
307 if kwargs.get('stdout') is None: 308 if kwargs.get('stdout') is None:
308 kwargs['stdout'] = PIPE 309 kwargs['stdout'] = PIPE
309 if kwargs.get('stderr') is None: 310 if kwargs.get('stderr') is None:
310 kwargs['stderr'] = STDOUT 311 kwargs['stderr'] = STDOUT
311 return check_call_out(args, **kwargs)[0] 312 return check_call_out(args, **kwargs)[0]
OLDNEW
« no previous file with comments | « gclient_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698