Remove kwargs copy, it is not necessary. Remove ordered argument support from popen to simplify it.
Move logging call to the base function.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3300008
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@58523 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index 66514f1..7558b42 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -38,26 +38,22 @@
self.stderr = stderr
-def Popen(*args, **kwargs):
+def Popen(args, **kwargs):
"""Calls subprocess.Popen() with hacks to work around certain behaviors.
Ensure English outpout for svn and make it work reliably on Windows.
"""
- copied = False
+ logging.debug(u'%s, cwd=%s' % (u' '.join(args), kwargs.get('cwd', '')))
if not 'env' in kwargs:
- copied = True
- kwargs = kwargs.copy()
# It's easier to parse the stdout if it is always in English.
kwargs['env'] = os.environ.copy()
kwargs['env']['LANGUAGE'] = 'en'
if not 'shell' in kwargs:
- if not copied:
- kwargs = kwargs.copy()
# *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the
# executable, but shell=True makes subprocess on Linux fail when it's called
# with a list because it only tries to execute the first item in the list.
kwargs['shell'] = (sys.platform=='win32')
- return subprocess.Popen(*args, **kwargs)
+ return subprocess.Popen(args, **kwargs)
def CheckCall(command, cwd=None, print_error=True):
@@ -66,7 +62,6 @@
Works on python 2.4
"""
- logging.debug('%s, cwd=%s' % (str(command), str(cwd)))
try:
stderr = None
if not print_error:
@@ -296,7 +291,6 @@
stdout = stdout or sys.stdout
filter_fn = filter_fn or (lambda x: None)
assert not 'stderr' in kwargs
- logging.debug(args)
kid = Popen(args, bufsize=0,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
**kwargs)