diff --git a/scripts/tools/zap/README.md b/scripts/tools/zap/README.md index 03512dec8f6cab..66a59cbb32f6cf 100644 --- a/scripts/tools/zap/README.md +++ b/scripts/tools/zap/README.md @@ -15,7 +15,9 @@ attributes, events or commands are implemented accordingly. ## Prerequisites -This tool uses the python environment, which can be built and activated using: +This tool may require the python environment to parse the latest version of the +cluster revisions (i.e. if you don't provide a '--new-revision' argument). The python +environment can be built and activated using: ``` # Build diff --git a/scripts/tools/zap/update_cluster_revisions.py b/scripts/tools/zap/update_cluster_revisions.py index bab77b16039c4a..3a0041ec54dc39 100755 --- a/scripts/tools/zap/update_cluster_revisions.py +++ b/scripts/tools/zap/update_cluster_revisions.py @@ -25,8 +25,6 @@ from dataclasses import dataclass from pathlib import Path -from chip.testing.spec_parsing import build_xml_clusters - BASIC_INFORMATION_CLUSTER_ID = int("0x0039", 16) CHIP_ROOT_DIR = os.path.realpath( os.path.join(os.path.dirname(__file__), '../../..')) @@ -222,10 +220,20 @@ def main(): os.chdir(CHIP_ROOT_DIR) targets = getTargets(args.cluster_id if args.cluster_id else 0) - spec_xml_clusters, problems = build_xml_clusters() - items = [(args, target, spec_xml_clusters) for target in targets] - update_func = updateOne if args.new_revision else updateOneToLatest + if args.new_revision: + update_func = updateOne + items = [(args, target, None) for target in targets] + else: + update_func = updateOneToLatest + try: + from chip.testing.spec_parsing import build_xml_clusters + except ImportError: + print("Couldn't import 'chip.testing.spec_parsing'. Try building/activating your python environment: ./scripts/build_python.sh -i out/python_env && source out/python_env/bin/activate)") + return 1 + spec_xml_clusters, problems = build_xml_clusters() + items = [(args, target, spec_xml_clusters) for target in targets] + if args.parallel: # Ensure each zap run is independent os.environ['ZAP_TEMPSTATE'] = '1'