diff options
-rw-r--r-- | src/linux/ogOperations.py | 8 | ||||
-rw-r--r-- | src/ogRest.py | 8 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index 1502f40..147944f 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -17,5 +17,9 @@ def reboot(): def execCMD(cmd): cmds = cmd.split(" ") - result = subprocess.run(cmds, stdout=subprocess.PIPE) - return result.stdout.decode('utf-8') + try: + result = subprocess.check_output(cmds) + except: + raise ValueError('Error: Incorrect command value') + + return result.decode('utf-8') diff --git a/src/ogRest.py b/src/ogRest.py index c21fcbb..1e4a3ee 100644 --- a/src/ogRest.py +++ b/src/ogRest.py @@ -96,7 +96,13 @@ class ogRest(): client.send(self.getResponse(ogResponses.BAD_REQUEST)) return - ogThread.execcmd(self.msgqueue, cmd) + try: + ogThread.execcmd(self.msgqueue, cmd) + except ValueError as err: + print(err.args[0]) + client.send(self.getResponse(ogResponses.BAD_REQUEST)) + return + client.send(self.getResponse(ogResponses.OK)) def process_shellout(self, client): |