 Chromium Code Reviews
 Chromium Code Reviews Issue 6793044:
  Fix automatic shell detection, the check was reversed  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
    
  
    Issue 6793044:
  Fix automatic shell detection, the check was reversed  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools| OLD | NEW | 
|---|---|
| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 | 
| 137 Note: Popen() can throw OSError when cwd or args[0] doesn't exist. | 137 Note: Popen() can throw OSError when cwd or args[0] doesn't exist. | 
| 138 """ | 138 """ | 
| 139 # Make sure we hack subprocess if necessary. | 139 # Make sure we hack subprocess if necessary. | 
| 140 hack_subprocess() | 140 hack_subprocess() | 
| 141 add_kill() | 141 add_kill() | 
| 142 | 142 | 
| 143 env = get_english_env(kwargs.get('env')) | 143 env = get_english_env(kwargs.get('env')) | 
| 144 if env: | 144 if env: | 
| 145 kwargs['env'] = env | 145 kwargs['env'] = env | 
| 146 | 146 if kwargs.get('shell') is None: | 
| 147 if not kwargs.get('shell') is None: | |
| 148 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the | 147 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the | 
| 149 # executable, but shell=True makes subprocess on Linux fail when it's called | 148 # executable, but shell=True makes subprocess on Linux fail when it's called | 
| 150 # with a list because it only tries to execute the first item in the list. | 149 # with a list because it only tries to execute the first item in the list. | 
| 151 kwargs['shell'] = (sys.platform=='win32') | 150 kwargs['shell'] = bool(sys.platform=='win32') | 
| 
Dirk Pranke
2011/04/05 21:18:49
don't think you need the case here.
 | |
| 152 | 151 | 
| 153 tmp_str = ' '.join(args) | 152 tmp_str = ' '.join(args) | 
| 154 if kwargs.get('cwd', None): | 153 if kwargs.get('cwd', None): | 
| 155 tmp_str += '; cwd=%s' % kwargs['cwd'] | 154 tmp_str += '; cwd=%s' % kwargs['cwd'] | 
| 156 logging.debug(tmp_str) | 155 logging.debug(tmp_str) | 
| 157 | 156 | 
| 158 # Replaces VOID with handle to /dev/null. | 157 # Replaces VOID with handle to /dev/null. | 
| 159 if kwargs.get('stdout') in (VOID, os.devnull): | 158 if kwargs.get('stdout') in (VOID, os.devnull): | 
| 160 kwargs['stdout'] = open(os.devnull, 'w') | 159 kwargs['stdout'] = open(os.devnull, 'w') | 
| 161 if kwargs.get('stderr') in (VOID, os.devnull): | 160 if kwargs.get('stderr') in (VOID, os.devnull): | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 | 246 | 
| 248 - Discards stderr. By default sets stderr=STDOUT. | 247 - Discards stderr. By default sets stderr=STDOUT. | 
| 249 - Throws if return code is not 0. | 248 - Throws if return code is not 0. | 
| 250 - Works even prior to python 2.7. | 249 - Works even prior to python 2.7. | 
| 251 """ | 250 """ | 
| 252 if kwargs.get('stdout') is None: | 251 if kwargs.get('stdout') is None: | 
| 253 kwargs['stdout'] = PIPE | 252 kwargs['stdout'] = PIPE | 
| 254 if kwargs.get('stderr') is None: | 253 if kwargs.get('stderr') is None: | 
| 255 kwargs['stderr'] = STDOUT | 254 kwargs['stderr'] = STDOUT | 
| 256 return check_call(args, **kwargs)[0] | 255 return check_call(args, **kwargs)[0] | 
| OLD | NEW |