Run commands and return final output.
(self, command: str)
| 97 | return output.strip() |
| 98 | |
| 99 | def _run_persistent(self, command: str) -> str: |
| 100 | """Run commands and return final output.""" |
| 101 | print("entering _run_persistent") |
| 102 | pexpect = _lazy_import_pexpect() |
| 103 | if self.process is None: |
| 104 | raise ValueError("Process not initialized") |
| 105 | self.process.sendline(command) |
| 106 | |
| 107 | # Clear the output with an empty string |
| 108 | self.process.expect(self.prompt, timeout=10) |
| 109 | self.process.sendline("") |
| 110 | |
| 111 | try: |
| 112 | self.process.expect([self.prompt, pexpect.EOF], timeout=10) |
| 113 | except pexpect.TIMEOUT: |
| 114 | return f"Timeout error while executing command {command}" |
| 115 | if self.process.after == pexpect.EOF: |
| 116 | return f"Exited with error status: {self.process.exitstatus}" |
| 117 | output = self.process.before |
| 118 | output = self.process_output(output, command) |
| 119 | if self.strip_newlines: |
| 120 | return output.strip() |
| 121 | return output |
| 122 | |
| 123 | |
| 124 | def get_platform() -> str: |
no test coverage detected