mirror of https://git.48k.eu/ogclient
Blocks the program execution until a command is processing
This patch changes the command process blocking the execution until is processing. Moreover, the response will be OK (200) instead of IN_PROGRESS (202).more_events
parent
59a28237f1
commit
b571f40482
|
@ -11,6 +11,7 @@ if platform.system() == 'Linux':
|
||||||
class ogThread():
|
class ogThread():
|
||||||
# Executing cmd thread
|
# Executing cmd thread
|
||||||
def execcmd(msgqueue, cmd):
|
def execcmd(msgqueue, cmd):
|
||||||
|
msgqueue.queue.clear()
|
||||||
msgqueue.put(ogOperations.execCMD(cmd))
|
msgqueue.put(ogOperations.execCMD(cmd))
|
||||||
|
|
||||||
# Powering off thread
|
# Powering off thread
|
||||||
|
@ -95,12 +96,12 @@ class ogRest():
|
||||||
client.send(self.getResponse(ogResponses.BAD_REQUEST))
|
client.send(self.getResponse(ogResponses.BAD_REQUEST))
|
||||||
return
|
return
|
||||||
|
|
||||||
threading.Thread(target=ogThread.execcmd, args=(self.msgqueue, cmd,)).start()
|
ogThread.execcmd(self.msgqueue, cmd)
|
||||||
client.send(self.getResponse(ogResponses.IN_PROGRESS))
|
client.send(self.getResponse(ogResponses.OK))
|
||||||
|
|
||||||
def process_shellout(self, client):
|
def process_shellout(self, client):
|
||||||
if self.msgqueue.empty():
|
if self.msgqueue.empty():
|
||||||
client.send(self.getResponse(ogResponses.IN_PROGRESS, 'out', ''))
|
client.send(self.getResponse(ogResponses.OK, 'out', ''))
|
||||||
else:
|
else:
|
||||||
out = self.msgqueue.get()
|
out = self.msgqueue.get()
|
||||||
client.send(self.getResponse(ogResponses.IN_PROGRESS, 'out', out))
|
client.send(self.getResponse(ogResponses.OK, 'out', out))
|
||||||
|
|
Loading…
Reference in New Issue