shell_command: ShellCommandError fix

Ensure that the stdout and stderr attributes cannot be set to a None type.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-27 19:29:57 -04:00 committed by Arksine
parent d6de095e66
commit fb1f76e008
1 changed files with 5 additions and 4 deletions

View File

@ -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()