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

Method run

bmtools/tools/python/api.py:17–29  ·  view source on GitHub ↗

Run command with own globals/locals and returns anything printed.

(self, command: str)

Source from the content-addressed store, hash-verified

15 self.locals: Optional[Dict] = None
16
17 def run(self, command: str) -> str:
18 """Run command with own globals/locals and returns anything printed."""
19 old_stdout = sys.stdout
20 sys.stdout = mystdout = StringIO()
21 try:
22 exec(command, self.globals, self.locals)
23 sys.stdout = old_stdout
24 output = mystdout.getvalue()
25 except Exception as e:
26 sys.stdout = old_stdout
27 output = repr(e)
28 print(output)
29 return output
30
31def build_tool(config) -> Tool:
32 tool = Tool(

Callers 5

serveMethod · 0.45
run_pythonFunction · 0.45
tutorialFunction · 0.45
test.pyFile · 0.45
test.pyFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected