Commit 24b5f908 authored by Hans Wennborg's avatar Hans Wennborg Committed by Commit Bot

Metrics: stop trying to print the notice in color and unicode

It breaks gclient for some users depending on locale settings (see bug).
The feature just doesn't seem worth the complexity.

Bug: 934279
Change-Id: I2c6e2b77ab764381db9f2c4e63ff8a84526769bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1520646Reviewed-by: 's avatarElliott Friedman <friedman@chromium.org>
Reviewed-by: 's avatarRyan Tseng <hinoka@chromium.org>
Commit-Queue: Ryan Tseng <hinoka@chromium.org>
Auto-Submit: Hans Wennborg <hans@chromium.org>
parent e5c289fd
......@@ -11,8 +11,6 @@ import subprocess2
import sys
import urlparse
from third_party import colorama
# Current version of metrics recording.
# When we add new metrics, the version number will be increased, we display the
......@@ -277,26 +275,20 @@ def get_repo_timestamp(path_to_repo):
# Get the age of the checkout in weeks.
return seconds_to_weeks(stdout.strip())
def print_red_boxed_text(out, min_width, lines):
colorama.init()
if sys.platform == 'win32':
[EW, NS, SE, SW, NE, NW] = list('=|++++')
else:
[EW, NS, SE, SW, NE, NW] = list(u'\u2501\u2503\u250F\u2513\u2517\u251B')
out(colorama.Fore.RED + colorama.Style.BRIGHT)
def print_boxed_text(out, min_width, lines):
[EW, NS, SE, SW, NE, NW] = list('=|++++')
width = max(min_width, max(len(line) for line in lines))
out(SE + EW * (width + 2) + SW + '\n')
for line in lines:
out('%s %-*s %s\n' % (NS, width, line, NS))
out(NE + EW * (width + 2) + NW + '\n')
out(colorama.Style.RESET_ALL)
def print_notice(countdown):
"""Print a notice to let the user know the status of metrics collection."""
lines = list(get_notice_countdown_header(countdown))
lines.append('')
lines += list(get_notice_footer())
print_red_boxed_text(sys.stderr.write, 49, lines)
print_boxed_text(sys.stderr.write, 49, lines)
def print_version_change(config_version):
"""Print a notice to let the user know we are collecting more metrics."""
......@@ -304,4 +296,4 @@ def print_version_change(config_version):
for version in xrange(config_version + 1, CURRENT_VERSION + 1):
lines.append('')
lines += list(get_change_notice(version))
print_red_boxed_text(sys.stderr.write, 49, lines)
print_boxed_text(sys.stderr.write, 49, lines)
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