Run command with own globals/locals and returns anything printed.
(self, command: str)
| 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 | |
| 31 | def build_tool(config) -> Tool: |
| 32 | tool = Tool( |
no outgoing calls
no test coverage detected