(cmd, cwd=None, capture_output=False, check=True)
| 33 | |
| 34 | |
| 35 | def run_command(cmd, cwd=None, capture_output=False, check=True): |
| 36 | print(f"> Running: {cmd} (cwd={cwd})") |
| 37 | |
| 38 | # We redirect stdin to devnull in an attempt |
| 39 | # to stop the process from interfering with the terminal's input buffer. |
| 40 | # This needs some work. After running the script I found that my buffer |
| 41 | # was filled with a sequence like 8;1R8;1R8;1R8;1R8;... This doesn't seem |
| 42 | # to affect the script but is annoying. |
| 43 | result = subprocess.run( |
| 44 | cmd, |
| 45 | cwd=cwd, |
| 46 | text=True, |
| 47 | capture_output=capture_output, |
| 48 | check=check, |
| 49 | shell=True, |
| 50 | stdin=subprocess.DEVNULL, |
| 51 | ) |
| 52 | if capture_output: |
| 53 | return result.stdout.strip() |
| 54 | else: |
| 55 | print(result.stdout or "") |
| 56 | return None |
| 57 | |
| 58 | |
| 59 | def export_datasets_and_test( |
no test coverage detected