From fb1f76e008e0d12b64c1c14958a456f93ec7fc2e Mon Sep 17 00:00:00 2001 From: Arksine Date: Sat, 27 Mar 2021 19:29:57 -0400 Subject: [PATCH] shell_command: ShellCommandError fix Ensure that the stdout and stderr attributes cannot be set to a None type. Signed-off-by: Eric Callahan --- moonraker/components/shell_command.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/moonraker/components/shell_command.py b/moonraker/components/shell_command.py index eb8c228..2fe8c48 100644 --- a/moonraker/components/shell_command.py +++ b/moonraker/components/shell_command.py @@ -12,10 +12,11 @@ from tornado import gen from utils import ServerError class ShellCommandError(ServerError): - def __init__(self, message, return_code, err_output=(b"", b""), - status_code=400): + def __init__(self, message, return_code, stdout=b"", + stderr=b"", status_code=400): super().__init__(message, status_code=status_code) - self.stdout, self.stderr = err_output + self.stdout = stdout or b"" + self.stderr = stderr or b"" self.return_code = return_code class SCProcess(asyncio.subprocess.Process): @@ -166,7 +167,7 @@ class ShellCommand: await gen.sleep(.5) raise ShellCommandError( f"Error running shell command: '{self.command}'", - self.return_code, err_output=(stdout, stderr)) + self.return_code, stdout, stderr) async def _create_subprocess(self): loop = asyncio.get_event_loop()