(cmd, cwd=None)
| 7 | |
| 8 | |
| 9 | def run_command(cmd, cwd=None): |
| 10 | print('Running command: %s' % (' '.join(cmd))) |
| 11 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
| 12 | stderr=subprocess.STDOUT, cwd=cwd) |
| 13 | while True: |
| 14 | p.stdout.flush() |
| 15 | line = p.stdout.read(1) |
| 16 | if line: |
| 17 | print(line.decode('utf-8', 'ignore'), end='') |
| 18 | else: |
| 19 | if p.poll() is not None: |
| 20 | break |
| 21 | if p.returncode != 0: |
| 22 | raise ValueError('Process finished with error code %d' % p.returncode) |
| 23 | |
| 24 | |
| 25 | class Generator: |