summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2019-12-28 17:18:38 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commitb571f40482c478af78da7014415e6d95c2a6a8a7 (patch)
tree98a5134b2abb17e83954d513661482e78b66f248
parent59a28237f15ae8760043a08fd4c6fd007e0a6ac7 (diff)
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).
-rw-r--r--src/ogRest.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ogRest.py b/src/ogRest.py
index f470f0b..80f6acd 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -11,6 +11,7 @@ if platform.system() == 'Linux':
class ogThread():
# Executing cmd thread
def execcmd(msgqueue, cmd):
+ msgqueue.queue.clear()
msgqueue.put(ogOperations.execCMD(cmd))
# Powering off thread
@@ -95,12 +96,12 @@ class ogRest():
client.send(self.getResponse(ogResponses.BAD_REQUEST))
return
- threading.Thread(target=ogThread.execcmd, args=(self.msgqueue, cmd,)).start()
- client.send(self.getResponse(ogResponses.IN_PROGRESS))
+ ogThread.execcmd(self.msgqueue, cmd)
+ client.send(self.getResponse(ogResponses.OK))
def process_shellout(self, client):
if self.msgqueue.empty():
- client.send(self.getResponse(ogResponses.IN_PROGRESS, 'out', ''))
+ client.send(self.getResponse(ogResponses.OK, 'out', ''))
else:
out = self.msgqueue.get()
- client.send(self.getResponse(ogResponses.IN_PROGRESS, 'out', out))
+ client.send(self.getResponse(ogResponses.OK, 'out', out))