Commit 2b71832f authored by Sergiy Byelozyorov's avatar Sergiy Byelozyorov Committed by Commit Bot

Hide standard output from the browser when running git-cl-web

R=nodir@chromium.org

Change-Id: I0816a109bc50cbc5c06339b832748f03abee372a
Reviewed-on: https://chromium-review.googlesource.com/c/1296511
Commit-Queue: Sergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: 's avatarNodir Turakulov <nodir@chromium.org>
parent 879d5e37
......@@ -5408,7 +5408,16 @@ def CMDweb(parser, args):
print('ERROR No issue to open', file=sys.stderr)
return 1
webbrowser.open(issue_url)
# Redirect I/O before invoking browser to hide its output. For example, this
# allows to hide "Created new window in existing browser session." message
# from Chrome. Based on https://stackoverflow.com/a/2323563.
saved_stdout = os.dup(1)
os.close(1)
os.open(os.devnull, os.O_RDWR)
try:
webbrowser.open(issue_url)
finally:
os.dup2(saved_stdout, 1)
return 0
......
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