Run commands and return final output.
(self, command: str)
| 72 | return self._run(commands) |
| 73 | |
| 74 | def _run(self, command: str) -> str: |
| 75 | """Run commands and return final output.""" |
| 76 | print("entering _run") |
| 77 | try: |
| 78 | output = subprocess.run( |
| 79 | command, |
| 80 | shell=True, |
| 81 | check=True, |
| 82 | stdout=subprocess.PIPE, |
| 83 | stderr=subprocess.STDOUT, |
| 84 | ).stdout.decode() |
| 85 | except subprocess.CalledProcessError as error: |
| 86 | if self.return_err_output: |
| 87 | return error.stdout.decode() |
| 88 | return str(error) |
| 89 | if self.strip_newlines: |
| 90 | output = output.strip() |
| 91 | return output |
| 92 | |
| 93 | def process_output(self, output: str, command: str) -> str: |
| 94 | # Remove the command from the output using a regular expression |