tests/unit/test_process_utils/impl_aep_protocol.py
raw| 1 | from osrf_pycommon.process_utils import AsyncSubprocessProtocol |
| 2 | |
| 3 | |
| 4 | def create_protocol(): |
| 5 | class CustomProtocol(AsyncSubprocessProtocol): |
| 6 | def __init__(self, **kwargs): |
| 7 | self.stdout_buffer = b"" |
| 8 | self.stderr_buffer = b"" |
| 9 | AsyncSubprocessProtocol.__init__(self, **kwargs) |
| 10 | |
| 11 | def on_stdout_received(self, data): |
| 12 | self.stdout_buffer += data |
| 13 | |
| 14 | def on_stderr_received(self, data): |
| 15 | self.stderr_buffer += data |
| 16 | return CustomProtocol |