mirror of https://git.48k.eu/ogclient
(BUG) Handling command error
This patch adds support for handling the error when the command is wrong formed. Now, if we send a shell/run command and the shell command is incomplete, the program crashes.more_events
parent
af903503a2
commit
e6eba4b91f
|
@ -17,5 +17,9 @@ def reboot():
|
||||||
|
|
||||||
def execCMD(cmd):
|
def execCMD(cmd):
|
||||||
cmds = cmd.split(" ")
|
cmds = cmd.split(" ")
|
||||||
result = subprocess.run(cmds, stdout=subprocess.PIPE)
|
try:
|
||||||
return result.stdout.decode('utf-8')
|
result = subprocess.check_output(cmds)
|
||||||
|
except:
|
||||||
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
|
||||||
|
return result.decode('utf-8')
|
||||||
|
|
|
@ -96,7 +96,13 @@ class ogRest():
|
||||||
client.send(self.getResponse(ogResponses.BAD_REQUEST))
|
client.send(self.getResponse(ogResponses.BAD_REQUEST))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
ogThread.execcmd(self.msgqueue, cmd)
|
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))
|
client.send(self.getResponse(ogResponses.OK))
|
||||||
|
|
||||||
def process_shellout(self, client):
|
def process_shellout(self, client):
|
||||||
|
|
Loading…
Reference in New Issue