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
experimental/szager/collated-output
maruel@chromium.org 15 years ago
parent 8469bf9309
commit a1693bef5a

@ -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):
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,
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)

Loading…
Cancel
Save