From 6441448876e6c1c542103133fd68f93059e617b4 Mon Sep 17 00:00:00 2001 From: Feras Muki Date: Mon, 31 Oct 2022 17:31:52 -0400 Subject: [PATCH] add a fallback for the 'coloredlogs' import in 'codegen.py' --- scripts/codegen.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/codegen.py b/scripts/codegen.py index da81b06210d933..ef228cb0486abc 100755 --- a/scripts/codegen.py +++ b/scripts/codegen.py @@ -15,10 +15,15 @@ import click import logging -import coloredlogs import enum import sys +try: + import coloredlogs + _has_coloredlogs = True +except: + _has_coloredlogs = False + try: from idl.matter_idl_parser import CreateParser except: @@ -94,8 +99,16 @@ def main(log_level, generator, output_dir, dry_run, name_only, expected_outputs, Parses MATTER IDL files (.matter) and performs SDK code generation as set up by the program arguments. """ - coloredlogs.install(level=__LOG_LEVELS__[ - log_level], fmt='%(asctime)s %(levelname)-7s %(message)s') + if _has_coloredlogs: + coloredlogs.install(level=__LOG_LEVELS__[ + log_level], fmt='%(asctime)s %(levelname)-7s %(message)s') + else: + logging.basicConfig( + level=__LOG_LEVELS__[log_level], + format='%(asctime)s %(levelname)-7s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' + ) + logging.info("Parsing idl from %s" % idl_path) idl_tree = CreateParser().parse(open(idl_path, "rt").read())