Skip to content

Commit 643d060

Browse files
committed
Send pick after loading code
1 parent 4f3e5bf commit 643d060

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

manager/libs/applications/compatibility/exercise_wrapper.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, exercise_command, gui_command, update_callback):
2626
self.exercise_command = exercise_command
2727
self.gui_command = gui_command
2828
self.update_callback = update_callback
29+
self.pick = None
2930
# TODO: review hardcoded values
3031
process_ready, self.exercise_server = self._run_exercise_server(f"python {exercise_command}",
3132
f'{home_dir}/ws_code.log',
@@ -61,10 +62,13 @@ def send_freq(self, exercise_connection, is_alive):
6162
exercise_connection.send(
6263
"""#freq{"brain": 20, "gui": 10, "rtf": 100}""")
6364
time.sleep(1)
65+
66+
def save_pick(self, pick):
67+
self.pick = pick
6468

65-
def send_pick(self, data):
66-
self.gui_connection.send("#pick" + json.dumps(data))
67-
print("#pick" + json.dumps(data))
69+
def send_pick(self, pick):
70+
self.gui_connection.send("#pick" + json.dumps(pick))
71+
print("#pick" + json.dumps(pick))
6872

6973
def start_send_freq_thread(self):
7074
"""Start a thread to send the frequency of the brain and gui to the exercise server"""
@@ -148,6 +152,8 @@ def restart(self):
148152
'websocket_code=ready')
149153
if process_ready:
150154
self.start_send_freq_thread()
155+
if self.pick:
156+
self.send_pick(self.pick)
151157

152158

153159

manager/manager/manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ def signal_handler(sign, frame):
280280
except Exception as e:
281281
if message is not None:
282282
if message.command == "#pick":
283-
print(message)
284-
self.application.send_pick(message.data)
285-
ex = ManagerConsumerMessageException(
286-
id=message.id, message=str(e))
283+
self.application.save_pick(message.data)
284+
else:
285+
ex = ManagerConsumerMessageException(
286+
id=message.id, message=str(e))
287287
else:
288288
ex = ManagerConsumerMessageException(
289289
id=str(uuid4()), message=str(e))

0 commit comments

Comments
 (0)