MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / _run_persistent

Method _run_persistent

bmtools/tools/shell/api.py:99–121  ·  view source on GitHub ↗

Run commands and return final output.

(self, command: str)

Source from the content-addressed store, hash-verified

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
124def get_platform() -> str:

Callers 1

runMethod · 0.95

Calls 2

process_outputMethod · 0.95
_lazy_import_pexpectFunction · 0.85

Tested by

no test coverage detected