From 3f73a459b6d6693cdb71e902997c500ee233981e Mon Sep 17 00:00:00 2001
From: Elliott Hughes <enh@google.com>
Date: Wed, 1 Aug 2018 14:18:15 -0700
Subject: [PATCH] Distinguish more clearly between the three states.

Showing the things you need to fix in green was surprising to me.

Errors and successfully determining that a project is stale both deserve
to be red, but use bold so that we can see the projects that need to be
updated even while there are lots of unsupported METADATA files.

Bug: N/A
Test: manual
Change-Id: Idad71a46c675b19d1fa204268c27816375f3e394
---
 external_updater.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/external_updater.py b/external_updater.py
index 4ceaa21..4bc8aa3 100644
--- a/external_updater.py
+++ b/external_updater.py
@@ -36,8 +36,9 @@ UPDATERS = [GithubArchiveUpdater, GitUpdater]
 def color_string(string, color):
     """Changes the color of a string when print to terminal."""
     colors = {
-        'SUCCESS': '\x1b[92m',
-        'FAILED': '\x1b[91m',
+        'FRESH': '\x1b[32m',
+        'STALE': '\x1b[31;1m',
+        'ERROR': '\x1b[31m',
     }
     end_color = '\033[0m'
     return colors[color] + string + end_color
@@ -59,14 +60,14 @@ def build_updater(proj_path):
     try:
         metadata = fileutils.read_metadata(proj_path)
     except text_format.ParseError as err:
-        print('{} {}.'.format(color_string('Invalid metadata file:', 'FAILED'),
+        print('{} {}.'.format(color_string('Invalid metadata file:', 'ERROR'),
                               err))
         return None
 
     try:
         updater = updater_utils.create_updater(metadata, proj_path, UPDATERS)
     except ValueError:
-        print(color_string('No supported URL.', 'FAILED'))
+        print(color_string('No supported URL.', 'ERROR'))
         return None
     return updater
 
@@ -79,8 +80,7 @@ def check_update(proj_path):
     """
 
     print(
-        '{} {}. '.format(color_string('Checking', 'SUCCESS'),
-                         fileutils.get_relative_project_path(proj_path)),
+        'Checking {}. '.format(fileutils.get_relative_project_path(proj_path)),
         end='')
     updater = build_updater(proj_path)
     if updater is None:
@@ -88,12 +88,12 @@ def check_update(proj_path):
     try:
         new_version = updater.check()
         if new_version:
-            print(color_string(' New version found.', 'SUCCESS'))
+            print(color_string(' Out of date!', 'STALE'))
         else:
-            print(' No new version.')
+            print(color_string(' Up to date.', 'FRESH'))
         return (updater, new_version)
     except IOError as err:
-        print('{} {}.'.format(color_string('Failed.', 'FAILED'),
+        print('{} {}.'.format(color_string('Failed.', 'ERROR'),
                               err))
         return (None, None)
     except subprocess.CalledProcessError as err:
@@ -101,7 +101,7 @@ def check_update(proj_path):
             '{} {}\nstdout: {}\nstderr: {}.'.format(
                 color_string(
                     'Failed.',
-                    'FAILED'),
+                    'ERROR'),
                 err,
                 err.stdout,
                 err.stderr))
-- 
GitLab