Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 3952fff

Browse files
committed
bypassed terminal print
1 parent ead1572 commit 3952fff

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/common/utils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ def update_state_with_device_name(state, device_name):
2424
return updated_state
2525

2626

27-
def create_message(state):
28-
message = {"type": "state", "data": json.dumps(state)}
27+
def create_message(msg,send_type="state"):
28+
if isinstance(msg,dict):
29+
msg = json.dumps(msg)
30+
31+
message = {"type": send_type, "data": msg}
2932
return message
3033

3134

@@ -41,6 +44,12 @@ def send_to_simulator(state, device_name):
4144
time.sleep(CONSTANTS.TIME_DELAY)
4245

4346

47+
def send_print_to_simulator(raw_msg):
48+
data_str = str(raw_msg)
49+
message = create_message(data_str,"print")
50+
print(json.dumps(message) + "\0", file=sys.__stdout__, flush=True)
51+
time.sleep(CONSTANTS.TIME_DELAY)
52+
4453
def remove_leading_slashes(string):
4554
string = string.lstrip("\\/")
4655
return string
@@ -53,6 +62,5 @@ def escape_if_OSX(file_name):
5362

5463

5564
def print_for_unimplemented_functions(function_name):
56-
print(
57-
f"'{function_name}' is not implemented in the simulator but it will work on the actual device!"
58-
)
65+
unimp_msg = f"'{function_name}' is not implemented in the simulator but it will work on the actual device!\n"
66+
send_print_to_simulator(unimp_msg)

0 commit comments

Comments
 (0)