diff options
| author | Jeff Epler <jepler@gmail.com> | 2020-05-26 09:55:23 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-05-26 09:55:23 -0500 |
| commit | 9966bf86da6abcc6a43b3415737dcf0284f9e998 (patch) | |
| tree | 613eef1f67a912e89c7761f601d3b8784fb57cad | |
| parent | 8f81beea7e83b33664d5ab6fc5e210723b10bb04 (diff) | |
shared_bindings_matrix: sommersoft's suggestions
| -rw-r--r-- | docs/shared_bindings_matrix.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index 0c838fedb..02ef68349 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -89,18 +89,27 @@ def get_settings_from_makefile(port_dir, board_name): into account, without having to re-encode the logic that sets them in this script, something that has proved error-prone """ - - status, contents = subprocess.getstatusoutput(f"make -C {port_dir} BOARD={board_name} -qp print-CC") + contents = subprocess.run( + ["make", "-C", port_dir, f"BOARD={board_name}", "-qp", "print-CC"], + encoding="utf-8", + errors="replace", + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) # Make signals errors with exit status 2; 0 and 1 are "non-error" statuses - if status not in (0, 1): - raise RuntimeError(f'Invoking make exited with {status}') - if isinstance(contents, bytes): - contents = contents.decode('utf-8', errors='replace') + if contents.returncode not in (0, 1): + error_msg = ( + f"Invoking '{' '.join(contents.args)}' exited with " + f"{contents.returncode}: {contents.stderr}" + ) + raise RuntimeError(error_msg) + settings = {} - for line in contents.split('\n'): + for line in contents.stdout.split('\n'): m = re.match(r'^([A-Z][A-Z0-9_]*) = (.*)$', line) if m: settings[m.group(1)] = m.group(2) + return settings def lookup_setting(settings, key, default=''): |
