Skip to content

Commit e8b6694

Browse files
committed
[nrf noup] [west zap-*] Apply copilot suggestions
- Refined error handling - Reduced the verbosity Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
1 parent dc43616 commit e8b6694

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

scripts/west/zap_append.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from zap_common import DEFAULT_MATTER_PATH, DEFAULT_MATTER_TYPES_RELATIVE_PATH, DEFAULT_ZCL_JSON_RELATIVE_PATH
1313

1414

15-
def get_attribute_name(attribute: ET.Element) -> str | None:
15+
def get_attribute_name(attribute: ET.Element) -> str:
1616
"""If attribute has a name, return it, otherwise fallback to the text of the attribute entry."""
1717
from_attr = attribute.get('name')
1818
if from_attr:

scripts/west/zap_common.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,12 @@ def display_zap_message(output: subprocess.CompletedProcess[str]) -> None:
301301
"""
302302
If the output contains the error from napi_throw, suggest user to use zap-sync to sync the ZAP file and make sure that all attributes are provided.
303303
"""
304-
print(f"output: {output.stdout}")
304+
if output.stdout:
305+
log.dbg(f"output: {output.stdout}")
306+
307+
if output.stderr:
308+
log.wrn(f"stderr: {output.stderr}")
309+
305310
if 'Unknown attribute' in output.stdout:
306311
log.err("Your zcl.json file seems to be outdated or is missing some attributes. "
307312
"Please use 'west zap-sync' command to synchronize it with the newest Matter Data Model "

scripts/west/zap_gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def run_zap():
104104
output = subprocess.run([str(x) for x in cmd], capture_output=True, text=True)
105105
# Chromium often prints nothing to stdout when the sandbox aborts early.
106106
# returncode -5 is a sentinel consumed by fix_sandbox_permissions().
107-
if not output.stdout:
107+
if output.returncode != 0 and not output.stdout and not output.stderr:
108108
raise subprocess.CalledProcessError(-5, cmd)
109109
display_zap_message(output)
110110
return output

scripts/west/zap_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def run_zap():
9797
output = subprocess.run([str(x) for x in cmd], capture_output=True, text=True)
9898
# Chromium often prints nothing to stdout when the sandbox aborts early.
9999
# returncode -5 is a sentinel consumed by fix_sandbox_permissions().
100-
if not output.stdout:
100+
if output.returncode != 0 and not output.stdout and not output.stderr:
101101
raise subprocess.CalledProcessError(-5, cmd)
102102
display_zap_message(output)
103103
return output

0 commit comments

Comments
 (0)