-
Notifications
You must be signed in to change notification settings - Fork 49
Led integration between webview and python api #192
Changes from 18 commits
806576b
deceeb7
8ed9e5b
32060ce
ef6498c
d2a7672
16beee3
52ba07e
91352a0
cc0ac13
c761e8b
4cbda2b
3557047
0717e6b
ecd96e0
9652a23
ddcf389
20690b2
b627989
e13db4c
5ee0a0a
3643afb
aafbf63
2a6553e
90bd1d0
d325d4a
2edea8f
1c9d190
268b168
f178c97
b24e214
2d84074
44794a1
c67d610
4d368a5
1762d97
18ce589
b2cde9b
4d106ed
4011d50
1e0e059
a3b4de8
7593b04
f9f9ee5
72069b8
ccc752c
5a11e1c
39643f4
7c2640a
6f0cbe9
ce63229
77dcd03
88a1226
8a76684
a6d24b9
7c3b53f
b694739
02d4e25
68420f0
3952361
25a2f72
f978503
9d1c0bf
80ebeb2
b4a8ad8
e00ac69
20969a4
6d175b2
7d04635
a5ce294
4a0a84b
01f52e3
579985f
e4ae67e
7214d37
a8c12db
dc8470c
61ec635
f5f0132
b62b076
de38218
e27a428
5231b03
8596f0c
bac6cc2
09e5370
2fccfce
4ea844d
8f73070
b4e7b6a
7dbfa8d
5067bab
7b6d2ca
42be28a
ec606b2
13b9852
059b9f5
a8a4ea5
e5593dc
6ed027d
c96a4e3
55b7250
05f9bca
ca1ed69
35a945a
eeb025d
7363419
50db730
78066e8
ba328aa
7551e5c
4437284
a109abc
dc73efb
d859420
26358b0
84fd761
4e8e95e
6cbdf5b
ee50718
6b4f9f1
afc1a5a
3611b56
2318a06
f962c0e
c510ba3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| MAC_OS = "darwin" | ||
|
|
||
| TIME_DELAY = 0.03 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,17 +10,23 @@ | |
| previous_state = {} | ||
|
|
||
|
|
||
| def show(state, device_name, debug_mode=False): | ||
| def create_message(state, device_name): | ||
| state_ext = { | ||
| "device_name": device_name, | ||
| } | ||
| state.update(state_ext) | ||
|
|
||
| message = {"type": "state", "data": json.dumps(state)} | ||
| return message | ||
|
|
||
|
|
||
| def send_to_simulator(state, device_name): | ||
| global previous_state | ||
|
|
||
| if not device_name in previous_state or state != previous_state[device_name]: | ||
| message = create_message(state, device_name) | ||
|
|
||
| previous_state[device_name] = copy.deepcopy(state) | ||
| state_ext = { | ||
| "device_name": device_name, | ||
| } | ||
| state.update(state_ext) | ||
| message = {"type": "state", "data": json.dumps(state)} | ||
| if state != previous_state: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for addressing the comment!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I just abstracted out the state updating and made the process two function calls :). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, tried to fix it in the last commit :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost perfect!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops! fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. *nit*
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| previous_state = copy.deepcopy(state) | ||
| print(json.dumps(message) + "\0", end="", file=sys.__stdout__, flush=True) | ||
| time.sleep(CONSTANTS.TIME_DELAY) | ||
|
|
||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.