-
Notifications
You must be signed in to change notification settings - Fork 4
/
BakedMessages.elm
167 lines (153 loc) · 9.02 KB
/
BakedMessages.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
module BakedMessages exposing
( kernel_info_request_msg
, error_execute_request_msg
, basic_execute_request_msg
, fancy_execute_request_msg
, stdout_execute_request_msg
, resource_info_request_msg
, sleep_request_msg
)
import JMessages
kernel_info_request_msg = """
{
"header": {
"msg_type": "kernel_info_request",
"username": "Popular Front",
"session": "sessionyo",
"date": "sup",
"msg_id": ""
},
"parent_header": {},
"content": {},
"metadata": {}
}
"""
empty_execute_request_msg = """{"header":{"msg_type": "execute_request", "msg_id": ""}, "parent_header": {}, "metadata":{}}"""
error_execute_request_msg = """
{
"header": {
"msg_type": "execute_request",
"username": "Popular Front",
"date": "k",
"session": "37F4106072824F45A3D2CF209C44C479",
"msg_id": ""
},
"parent_header": {},
"content": {
"code": "import IPython.displas as d; d.HTML('I\'m a <b>fancy</b> <i>kind</i> of message'",
"silent": false,
"store_history": true,
"user_expressions": {},
"allow_stdin": true,
"stop_on_error": true
},
"metadata": {}
}
"""
fancy_execute_request_msg = """
{
"header": {
"msg_type": "execute_request",
"username": "Popular Front",
"date": "k",
"session": "37F4106072824F45A3D2CF209C44C479",
"msg_id": ""
},
"parent_header": {},
"content": {
"code": "import IPython.display as d; import time, base64; logo = base64.decodebytes(b'iVBORw0KGgoAAA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gd9CdSXO/Hggw8WvXYvQoRxjVxfbtiPQP25fnvTpk3R/SgRIvgh359/qkgXbne9/YsQoaGRz+c/nevLnfAiUD6fL3n/S4QI4x5btmyR8335vWeI05c/0NfXd3O9/YoQ4ZyBbdsTNm/e3JzL5Rbs2LGjYe9NjRChEfB/dvylsVVgrbwAAAAASUVORK5CYII=');d.display(d.Image(logo));time.sleep(1); d.HTML('<b>fancy</b>')",
"silent": false,
"store_history": true,
"user_expressions": {},
"allow_stdin": true,
"stop_on_error": true
},
"metadata": {}
}
"""
stdout_execute_request_msg = """
{
"header": {
"msg_type": "execute_request",
"username": "Popular Front",
"session": "sessionyo",
"date": "",
"msg_id": ""
},
"parent_header": {},
"content": {
"code": "print('hallo JupyterCon!')",
"silent": false,
"store_history": true,
"user_expressions": {},
"allow_stdin": true,
"stop_on_error": true
},
"metadata": {}
}
"""
basic_execute_request_msg = """
{
"header": {
"msg_id": "",
"username": "Popular Front",
"session": "37F4106072824F45A3D2CF209C44C479",
"msg_type": "execute_request",
"version": "5.0"
},
"metadata": {},
"content": {
"code": "2+2",
"silent": false,
"store_history": true,
"user_expressions": {},
"allow_stdin": true,
"stop_on_error": true
},
"buffers": [],
"parent_header": {},
"channel": "shell"
}
"""
-- Still kind of bonkers that there's no String.replace
sleep_request_msg = String.split "2+2" basic_execute_request_msg |> String.join "import time; time.sleep(10)"
resource_info_request_msg = """
{
"header": {
"msg_id": "",
"username": "Popular Front",
"session": "47F4106072824F45A3D2CF209C44C479",
"msg_type": "resource_info_request",
"version": "5.0"
},
"metadata": {},
"content": {},
"buffers": [],
"parent_header": {},
"channel": "shell"
}
"""
--"channel": "control"
--basic_execute_request_msg_ : Jmsg
--basic_execute_request_msg_ =
-- {
-- {},
-- "metadata": {},
-- "content": {
-- "code": "2+2",
-- "silent": false,
-- "store_history": true,
-- "user_expressions": {},
-- "allow_stdin": true,
-- "stop_on_error": true
-- },
-- "buffers": [],
-- {
-- "msg_id": "",
-- "username": "Popular Front",
-- "session": "37F4106072824F45A3D2CF209C44C479",
-- "msg_type": "execute_request",
-- "version": "5.0"
-- },
-- "channel": "shell"
-- }