Skip to content

Commit 9966bf8

Browse files
committed
shared_bindings_matrix: sommersoft's suggestions
1 parent 8f81bee commit 9966bf8

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

docs/shared_bindings_matrix.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,27 @@ def get_settings_from_makefile(port_dir, board_name):
8989
into account, without having to re-encode the logic that sets them
9090
in this script, something that has proved error-prone
9191
"""
92-
93-
status, contents = subprocess.getstatusoutput(f"make -C {port_dir} BOARD={board_name} -qp print-CC")
92+
contents = subprocess.run(
93+
["make", "-C", port_dir, f"BOARD={board_name}", "-qp", "print-CC"],
94+
encoding="utf-8",
95+
errors="replace",
96+
stdout=subprocess.PIPE,
97+
stderr=subprocess.PIPE
98+
)
9499
# Make signals errors with exit status 2; 0 and 1 are "non-error" statuses
95-
if status not in (0, 1):
96-
raise RuntimeError(f'Invoking make exited with {status}')
97-
if isinstance(contents, bytes):
98-
contents = contents.decode('utf-8', errors='replace')
100+
if contents.returncode not in (0, 1):
101+
error_msg = (
102+
f"Invoking '{' '.join(contents.args)}' exited with "
103+
f"{contents.returncode}: {contents.stderr}"
104+
)
105+
raise RuntimeError(error_msg)
106+
99107
settings = {}
100-
for line in contents.split('\n'):
108+
for line in contents.stdout.split('\n'):
101109
m = re.match(r'^([A-Z][A-Z0-9_]*) = (.*)$', line)
102110
if m:
103111
settings[m.group(1)] = m.group(2)
112+
104113
return settings
105114

106115
def lookup_setting(settings, key, default=''):

0 commit comments

Comments
 (0)