diff options
author | Zhizhou Yang <zhizhouy@google.com> | 2019-12-23 16:56:26 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-09 07:34:17 +0000 |
commit | 45e4c1f8be303b43030e3dfac6cab5cd67d10a99 (patch) | |
tree | f00931a3bf505fded2f375f7589b41e6dfc34f18 /cros_utils/logger.py | |
parent | e41baa8073f6f5d160ef8cf75ccb7ca9beb1ad72 (diff) | |
download | toolchain-utils-45e4c1f8be303b43030e3dfac6cab5cd67d10a99.tar.gz |
toolchain-utils: Migrate cros_utils to python3
This patch fixes all presubmit checks in cros_utils and migrated it from
python2 to python3.
TEST=Passed all unittests and presubmit checks.
BUG=chromium:1011676
Change-Id: I3a7097d6570fb2cb4e5dcdd5ae22f30c5c5762e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1981087
Commit-Queue: Zhizhou Yang <zhizhouy@google.com>
Tested-by: Zhizhou Yang <zhizhouy@google.com>
Auto-Submit: Zhizhou Yang <zhizhouy@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'cros_utils/logger.py')
-rw-r--r-- | cros_utils/logger.py | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/cros_utils/logger.py b/cros_utils/logger.py index 364d9c9d..4cc4618e 100644 --- a/cros_utils/logger.py +++ b/cros_utils/logger.py @@ -1,4 +1,8 @@ -# Copyright 2010 Google Inc. All Rights Reserved. +# -*- coding: utf-8 -*- +# Copyright 2019 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + """Logging helper module.""" from __future__ import print_function @@ -9,7 +13,7 @@ import sys import traceback -#TODO(yunlian@google.com): Use GetRoot from misc +# TODO(yunlian@google.com): Use GetRoot from misc def GetRoot(scr_name): """Break up pathname into (dir+name).""" abs_path = os.path.abspath(scr_name) @@ -182,16 +186,12 @@ class Logger(object): self.LogWarning(msg) def LogCommandOutput(self, msg, print_to_console=True): - self.LogMsg(self.stdout, - self._GetStdout(print_to_console), - msg, - flush=False) + self.LogMsg( + self.stdout, self._GetStdout(print_to_console), msg, flush=False) def LogCommandError(self, msg, print_to_console=True): - self.LogMsg(self.stderr, - self._GetStderr(print_to_console), - msg, - flush=False) + self.LogMsg( + self.stderr, self._GetStderr(print_to_console), msg, flush=False) def Flush(self): self.cmdfd.flush() @@ -319,16 +319,12 @@ class MockLogger(object): self.LogWarning(msg) def LogCommandOutput(self, msg, print_to_console=True): - self.LogMsg(self.stdout, - self._GetStdout(print_to_console), - msg, - flush=False) + self.LogMsg( + self.stdout, self._GetStdout(print_to_console), msg, flush=False) def LogCommandError(self, msg, print_to_console=True): - self.LogMsg(self.stderr, - self._GetStderr(print_to_console), - msg, - flush=False) + self.LogMsg( + self.stderr, self._GetStderr(print_to_console), msg, flush=False) def Flush(self): print('MockLogger: Flushing cmdfd, stdout, stderr') @@ -363,7 +359,7 @@ def HandleUncaughtExceptions(fun): def _Interceptor(*args, **kwargs): try: return fun(*args, **kwargs) - except StandardError: + except Exception: GetLogger().LogFatal('Uncaught exception:\n%s' % traceback.format_exc()) return _Interceptor |