Commit 57daaf41 authored by Robert Ma's avatar Robert Ma Committed by Commit Bot

Reland "[blinkpy] Always suppress stderr of git-cl"

This is a reland of 964fde12,
which was reverted at 043d9f87
because of a bug.

This reland fixes the bug by setting optional params correctly
in git_cl.py.

Original change's description:
> [blinkpy] Always suppress stderr of git-cl
>
> * stderr is now always ignored for git-cl (i.e. the optional argument is
>   removed from GitCL.run as no one uses it).
> * Instead of only excluding stderr from the return value, we now throws
>   away stderr completely by redirecting it to DEVNULL so that the logs
>   don't get polluted.
>
> Some drive-by pylint fixes are applied.
>
> Bug: 953499
> Change-Id: I5668576e1cc3dfe2a83a7cafc12a09f4a0029358
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1628606
> Auto-Submit: Robert Ma <robertma@chromium.org>
> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
> Commit-Queue: Robert Ma <robertma@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#663599}

Bug: 953499
Change-Id: Idccc65e089ee67f744411752800f41fd63a93d92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1631765Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663882}
parent ade94af7
......@@ -52,14 +52,11 @@ class GitCL(object):
self._cwd = cwd
self._git_executable_name = Git.find_executable_name(host.executive, host.platform)
def run(self, args, return_stderr=False):
def run(self, args):
"""Runs git-cl with the given arguments and returns the output.
Args:
args: A list of arguments passed to `git cl`.
return_stderr: Whether to include stderr in the returned output (the
default is False because git-cl will show a warning when running
on Swarming bots with local git cache).
Returns:
A string (the output from git-cl).
......@@ -67,7 +64,10 @@ class GitCL(object):
command = [self._git_executable_name, 'cl'] + args
if self._auth_refresh_token_json and args[0] in _COMMANDS_THAT_TAKE_REFRESH_TOKEN:
command += ['--auth-refresh-token-json', self._auth_refresh_token_json]
return self._host.executive.run_command(command, cwd=self._cwd, return_stderr=return_stderr)
# Suppress the stderr of git-cl because git-cl will show a warning when
# running on Swarming bots with local git cache.
return self._host.executive.run_command(
command, cwd=self._cwd, return_stderr=False, ignore_stderr=True)
def trigger_try_jobs(self, builders, bucket=None):
"""Triggers try jobs on the given builders.
......
......@@ -311,13 +311,17 @@ class Executive(object):
error_handler=None,
return_exit_code=False,
return_stderr=True,
decode_output=True, debug_logging=True):
ignore_stderr=False,
decode_output=True,
debug_logging=True):
"""Popen wrapper for convenience and to work around python bugs."""
assert isinstance(args, list) or isinstance(args, tuple)
start_time = time.time()
assert not (return_stderr and ignore_stderr)
stdin, string_to_communicate = self._compute_stdin(input)
stderr = self.STDOUT if return_stderr else None
stderr = self.STDOUT if return_stderr else (
self.DEVNULL if ignore_stderr else None)
process = self.popen(args,
stdin=stdin,
......
......@@ -123,6 +123,7 @@ class MockExecutive(object):
error_handler=None,
return_exit_code=False,
return_stderr=True,
ignore_stderr=False,
decode_output=True,
debug_logging=True):
self._append_call(args, cwd=cwd, input=input, env=env)
......@@ -156,7 +157,7 @@ class MockExecutive(object):
output = self._output
if return_stderr:
output += self._stderr
if decode_output and type(output) is not unicode:
if decode_output and not isinstance(output, unicode):
output = output.decode('utf-8')
return output
......
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