Call the given cmd in a subprocess, piping stdout/err Parameters ---------- cmd : str Command to execute (can not end in '&', as background processes are not supported. Should not be a command that expects input other than simple text.
(self, cmd)
| 2649 | #------------------------------------------------------------------------- |
| 2650 | |
| 2651 | def system_piped(self, cmd): |
| 2652 | """Call the given cmd in a subprocess, piping stdout/err |
| 2653 | |
| 2654 | Parameters |
| 2655 | ---------- |
| 2656 | cmd : str |
| 2657 | Command to execute (can not end in '&', as background processes are |
| 2658 | not supported. Should not be a command that expects input |
| 2659 | other than simple text. |
| 2660 | """ |
| 2661 | if cmd.rstrip().endswith('&'): |
| 2662 | # this is *far* from a rigorous test |
| 2663 | # We do not support backgrounding processes because we either use |
| 2664 | # pexpect or pipes to read from. Users can always just call |
| 2665 | # os.system() or use ip.system=ip.system_raw |
| 2666 | # if they really want a background process. |
| 2667 | raise OSError("Background processes not supported.") |
| 2668 | |
| 2669 | # we explicitly do NOT return the subprocess status code, because |
| 2670 | # a non-None value would trigger :func:`sys.displayhook` calls. |
| 2671 | # Instead, we store the exit_code in user_ns. |
| 2672 | exit_code = system(self.var_expand(cmd, depth=1)) |
| 2673 | self.user_ns['_exit_code'] = exit_code |
| 2674 | |
| 2675 | # Raise an exception if the command failed and system_raise_on_error is True |
| 2676 | if self.system_raise_on_error and exit_code != 0: |
| 2677 | raise CalledProcessError(exit_code, cmd) |
| 2678 | |
| 2679 | def system_raw(self, cmd): |
| 2680 | """Call the given cmd in a subprocess using os.system on Windows or |
nothing calls this directly
no test coverage detected