Read lines from a subprocess stdout/stderr streams and write to sys.stdout & the logfile arguments: stream - subprocess stdout or stderr data stream exclude_pattern - lines matching this reg-ex will be excluded from stdout.
(stream, exclude_pattern=None)
| 31 | |
| 32 | |
| 33 | def show_progress(stream, exclude_pattern=None): |
| 34 | """ |
| 35 | Read lines from a subprocess stdout/stderr streams and write |
| 36 | to sys.stdout & the logfile |
| 37 | |
| 38 | arguments: |
| 39 | stream - subprocess stdout or stderr data stream |
| 40 | exclude_pattern - lines matching this reg-ex will be excluded |
| 41 | from stdout. |
| 42 | """ |
| 43 | while True: |
| 44 | s = stream.readline() |
| 45 | if not s: |
| 46 | break |
| 47 | data = s.decode("utf-8") |
| 48 | # Filter the annoying SIGTERM signal from the output when VPP is |
| 49 | # terminated after a test run |
| 50 | if "SIGTERM" not in data: |
| 51 | if exclude_pattern is not None: |
| 52 | if bool(re.search(exclude_pattern, data)) is False: |
| 53 | sys.stdout.write(data) |
| 54 | else: |
| 55 | sys.stdout.write(data) |
| 56 | logging.debug(data) |
| 57 | sys.stdout.flush() |
| 58 | stream.close() |
| 59 | |
| 60 | |
| 61 | def get_env(args): |
no test coverage detected