Skip to content

Commit

Permalink
Avoid requiring the python env if the user provides --new-revision
Browse files Browse the repository at this point in the history
  • Loading branch information
soares-sergio committed Dec 12, 2024
1 parent 44691e6 commit d1de25b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion scripts/tools/zap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions scripts/tools/zap/update_cluster_revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__), '../../..'))
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit d1de25b

Please sign in to comment.