From 951fa7e3158555978d63ea0f6f729a7b9f9ceb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Wed, 31 May 2023 15:19:41 -0700 Subject: [PATCH] app: move some code around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moving all the "work" of main() into WestApp.run() will help us in future patches where we need to set up logging in a way that requires internal state from that object. Signed-off-by: Martí Bolívar --- src/west/app/main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/west/app/main.py b/src/west/app/main.py index bcd0332..2611478 100755 --- a/src/west/app/main.py +++ b/src/west/app/main.py @@ -85,6 +85,15 @@ class WestApp: def run(self, argv): # Run the command-line application with argument list 'argv'. + # Silence validation errors from pykwalify, which are logged at + # logging.ERROR level. We want to handle those ourselves as + # needed. + logging.getLogger('pykwalify').setLevel(logging.CRITICAL) + + # Makes ANSI color escapes work on Windows, and strips them when + # stdout/stderr isn't a terminal + colorama.init() + # See if we're in a workspace. It's fine if we're not. # Note that this falls back on searching from ZEPHYR_BASE # if the current directory isn't inside a west workspace. @@ -910,15 +919,6 @@ def dump_traceback(): return name def main(argv=None): - # Silence validation errors from pykwalify, which are logged at - # logging.ERROR level. We want to handle those ourselves as - # needed. - logging.getLogger('pykwalify').setLevel(logging.CRITICAL) - - # Makes ANSI color escapes work on Windows, and strips them when - # stdout/stderr isn't a terminal - colorama.init() - # Create the WestApp instance and let it run. app = WestApp() app.run(argv or sys.argv[1:])