Commit a1693bef authored by maruel@chromium.org's avatar maruel@chromium.org

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
parent 8469bf93
...@@ -38,26 +38,22 @@ class CheckCallError(OSError): ...@@ -38,26 +38,22 @@ class CheckCallError(OSError):
self.stderr = stderr self.stderr = stderr
def Popen(*args, **kwargs): def Popen(args, **kwargs):
"""Calls subprocess.Popen() with hacks to work around certain behaviors. """Calls subprocess.Popen() with hacks to work around certain behaviors.
Ensure English outpout for svn and make it work reliably on Windows. 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: if not 'env' in kwargs:
copied = True
kwargs = kwargs.copy()
# It's easier to parse the stdout if it is always in English. # It's easier to parse the stdout if it is always in English.
kwargs['env'] = os.environ.copy() kwargs['env'] = os.environ.copy()
kwargs['env']['LANGUAGE'] = 'en' kwargs['env']['LANGUAGE'] = 'en'
if not 'shell' in kwargs: 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 # *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 # 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. # with a list because it only tries to execute the first item in the list.
kwargs['shell'] = (sys.platform=='win32') kwargs['shell'] = (sys.platform=='win32')
return subprocess.Popen(*args, **kwargs) return subprocess.Popen(args, **kwargs)
def CheckCall(command, cwd=None, print_error=True): def CheckCall(command, cwd=None, print_error=True):
...@@ -66,7 +62,6 @@ def CheckCall(command, cwd=None, print_error=True): ...@@ -66,7 +62,6 @@ def CheckCall(command, cwd=None, print_error=True):
Works on python 2.4 Works on python 2.4
""" """
logging.debug('%s, cwd=%s' % (str(command), str(cwd)))
try: try:
stderr = None stderr = None
if not print_error: if not print_error:
...@@ -296,7 +291,6 @@ def CheckCallAndFilter(args, stdout=None, filter_fn=None, ...@@ -296,7 +291,6 @@ def CheckCallAndFilter(args, stdout=None, filter_fn=None,
stdout = stdout or sys.stdout stdout = stdout or sys.stdout
filter_fn = filter_fn or (lambda x: None) filter_fn = filter_fn or (lambda x: None)
assert not 'stderr' in kwargs assert not 'stderr' in kwargs
logging.debug(args)
kid = Popen(args, bufsize=0, kid = Popen(args, bufsize=0,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
**kwargs) **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment