Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a fallback for the 'coloredlogs' import in 'codegen.py' #23411

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions scripts/codegen.py
Original file line number Diff line number Diff line change
@@ -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())