diff --git a/moonraker/plugins/shell_command.py b/moonraker/plugins/shell_command.py index d1916b2..04d3e7e 100644 --- a/moonraker/plugins/shell_command.py +++ b/moonraker/plugins/shell_command.py @@ -93,6 +93,20 @@ class ShellCommand: self.io_loop.remove_handler(fd) return complete + async def run_with_response(self, timeout=2.): + result = [] + + def cb(data): + data = data.strip() + if data: + result.append(data.decode()) + prev_cb = self.output_cb + self.output_cb = cb + await self.run(timeout) + self.output_cb = prev_cb + return "\n".join(result) + + class ShellCommandFactory: def build_shell_command(self, cmd, callback): return ShellCommand(cmd, callback)