From d83d87d5bdce6bbf77a836366a79eda838ad6dbc Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Thu, 17 Mar 2016 18:30:51 +0800 Subject: [PATCH] Make precheck more resilient to Travis changes --- mdk/commands/precheck.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mdk/commands/precheck.py b/mdk/commands/precheck.py index 099359d..889286a 100644 --- a/mdk/commands/precheck.py +++ b/mdk/commands/precheck.py @@ -99,7 +99,7 @@ class PrecheckCommand(Command): if outcome == CI.FAILURE: - logging.warning('Build failed, please refer to:\n %s', infos.url) + logging.warning('Build failed, please refer to:\n %s', infos.get('url', '[Unknown URL]')) sys.exit(self.FAILED) elif outcome == CI.SUCCESS: @@ -129,10 +129,15 @@ class PrecheckCommand(Command): } for key in mapping: - details = infos.get(key) - - symbol = ' ' if details['result'] == CI.SUCCESS else ('!' if details['result'] == CI.WARNING else 'X') - print ' [{}] {} ({} errors, {} warnings)'.format(symbol, mapping.get(key, key), details.get('errors'), details.get('warnings')) + try: + details = infos.get(key) + except KeyError: + logging.debug("Unknown key '%s', ignoring...", key) + continue + + result = details.get('result', None) + symbol = ' ' if result == CI.SUCCESS else ('!' if result == CI.WARNING else 'X') + print ' [{}] {:<20}({} errors, {} warnings)'.format(symbol, mapping.get(key, key), details.get('errors', '?'), details.get('warnings', '?')) logging.info('') logging.info('More details at: %s', infos.get('url')) -- 2.11.0