| 599 | |
| 600 | |
| 601 | def run_simple_pex( |
| 602 | pex, # type: str |
| 603 | args=(), # type: Iterable[str] |
| 604 | interpreter=None, # type: Optional[PythonInterpreter] |
| 605 | stdin=None, # type: Optional[bytes] |
| 606 | **kwargs # type: Any |
| 607 | ): |
| 608 | # type: (...) -> Tuple[bytes, int] |
| 609 | p = PEX(pex, interpreter=interpreter) |
| 610 | process = p.run( |
| 611 | args=args, |
| 612 | blocking=False, |
| 613 | stdin=subprocess.PIPE, |
| 614 | stdout=subprocess.PIPE, |
| 615 | stderr=kwargs.pop("stderr", subprocess.STDOUT), |
| 616 | **kwargs |
| 617 | ) |
| 618 | stdout, _ = process.communicate(input=stdin) |
| 619 | return stdout.replace(b"\r", b""), process.returncode |
| 620 | |
| 621 | |
| 622 | def run_simple_pex_test( |