From c41c27c86e86cae33f74b9b8f090d41554cc4649 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 17 Aug 2010 15:41:50 +0000 Subject: [PATCH] Force LANGUAGE=en to fix svn output parsing TEST=Run with LANGUAGE=fr_CA, gclient still works. Review URL: http://codereview.chromium.org/3192001 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@56354 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_utils.py | 9 +++++++-- tests/gclient_utils_test.py | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gclient_utils.py b/gclient_utils.py index 19a39a69d..1efa036f6 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -49,10 +49,13 @@ def CheckCall(command, cwd=None, print_error=True): stderr = None if not print_error: stderr = subprocess.PIPE + env = os.environ.copy() + env['LANGUAGE'] = 'en' process = subprocess.Popen(command, cwd=cwd, shell=sys.platform.startswith('win'), stdout=subprocess.PIPE, - stderr=stderr) + stderr=stderr, + env=env) std_out, std_err = process.communicate() except OSError, e: raise CheckCallError(command, cwd, e.errno, None) @@ -272,13 +275,15 @@ def SubprocessCallAndFilter(command, if print_messages: print('\n________ running \'%s\' in \'%s\'' % (' '.join(command), in_directory)) + env = os.environ.copy() + env['LANGUAGE'] = 'en' # *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. kid = subprocess.Popen(command, bufsize=0, cwd=in_directory, shell=(sys.platform == 'win32'), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, env=env) # Do a flush of sys.stdout before we begin reading from the subprocess's # stdout. diff --git a/tests/gclient_utils_test.py b/tests/gclient_utils_test.py index 6bcfd1305..01b222107 100755 --- a/tests/gclient_utils_test.py +++ b/tests/gclient_utils_test.py @@ -40,9 +40,12 @@ class CheckCallTestCase(GclientUtilBase): command = ['boo', 'foo', 'bar'] process = self.mox.CreateMockAnything() process.returncode = 0 + env = gclient_utils.os.environ.copy() + env['LANGUAGE'] = 'en' gclient_utils.subprocess.Popen( command, cwd=None, stderr=None, + env=env, stdout=gclient_utils.subprocess.PIPE, shell=gclient_utils.sys.platform.startswith('win')).AndReturn(process) process.communicate().AndReturn(['bleh', 'foo']) @@ -53,9 +56,12 @@ class CheckCallTestCase(GclientUtilBase): command = ['boo', 'foo', 'bar'] process = self.mox.CreateMockAnything() process.returncode = 42 + env = gclient_utils.os.environ.copy() + env['LANGUAGE'] = 'en' gclient_utils.subprocess.Popen( command, cwd=None, stderr=None, + env=env, stdout=gclient_utils.subprocess.PIPE, shell=gclient_utils.sys.platform.startswith('win')).AndReturn(process) process.communicate().AndReturn(['bleh', 'foo']) @@ -78,6 +84,8 @@ class SubprocessCallAndFilterTestCase(GclientUtilBase): fail_status = None pattern = 'a(.*)b' test_string = 'ahah\naccb\nallo\naddb\n' + env = gclient_utils.os.environ.copy() + env['LANGUAGE'] = 'en' class Mock(object): stdout = StringIO.StringIO(test_string) def wait(self): @@ -89,6 +97,7 @@ class SubprocessCallAndFilterTestCase(GclientUtilBase): gclient_utils.subprocess.Popen( command, bufsize=0, cwd=in_directory, shell=(gclient_utils.sys.platform == 'win32'), + env=env, stdout=gclient_utils.subprocess.PIPE, stderr=gclient_utils.subprocess.STDOUT).AndReturn(kid) self.mox.ReplayAll()