Mercurial > repos > icfp2013
annotate src/requests.tp @ 30:a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
author | William Morgan <bill@mrgn.org> |
---|---|
date | Sat, 10 Aug 2013 20:30:05 -0700 |
parents | 18a043613dae |
children | 8a2925ab0d4a |
rev | line source |
---|---|
10
79c1db5e7ebd
sending broken file for mike to check error
William Morgan <bill@mrgn.org>
parents:
diff
changeset
|
1 #{ |
18 | 2 |
20 | 3 strJoin <- :str arr { |
4 acc <- "" | |
5 arr foreach: :i el { | |
6 if: i = 0 { | |
7 acc <- (string: el) | |
8 } else: { | |
9 acc <- acc . ", " . (string: el) | |
10 } | |
11 } | |
12 acc | |
13 //arr fold: "" with: :acc el {acc . el} | |
14 } | |
15 | |
18 | 16 quote <- :str { |
24
e1109e33b796
some work that probably needs to be trashed on requests.tp
Mike Pavone <pavone@retrodev.com>
parents:
23
diff
changeset
|
17 "\"" . str . "\"" |
18 | 18 } |
19 | |
24
e1109e33b796
some work that probably needs to be trashed on requests.tp
Mike Pavone <pavone@retrodev.com>
parents:
23
diff
changeset
|
20 println <- :str { |
23 | 21 print: str . "\n" |
22 } | |
23 | |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
24 fixArgs <- :args { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
25 args map: :el { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
26 "\"0x" . (hex: el) . "\"" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
27 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
28 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
29 |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
30 |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
31 evalId <- :id args { |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
32 args <- fixArgs: args |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
33 #{ |
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
34 string <- { |
20 | 35 idStr <- (quote: "id") . ":" . (quote: id) |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
36 argsStr <- (quote: "arguments") . ":[" . (strJoin: "," args) . "]" |
18 | 37 "{" . idStr . "," . argsStr . "}" |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
38 } |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
39 sendWithKey <- :key { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
40 print: "Sending: " . string . "\n" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
41 cli <- http client: "icfpc2013.cloudapp.net" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
42 resp <- cli post: string toPath: "/eval?auth=" . key withType: "application/json" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
43 evalResponse: resp |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
44 } |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
45 } |
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
46 } |
10
79c1db5e7ebd
sending broken file for mike to check error
William Morgan <bill@mrgn.org>
parents:
diff
changeset
|
47 |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
48 evalProgram <- :program args { |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
49 args <- fixArgs: args |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
50 #{ |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
51 string <- { |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
52 progStr <- (quote: "program") . ":" . (quote: program) |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
53 argsStr <- (quote: "arguments") . ":[" . (strJoin: "," args) . "]" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
54 "{" . progStr . "," . argsStr . "}" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
55 } |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
56 sendWithKey <- :key { |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
57 print: "Sending: " . string . "\n" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
58 cli <- http client: "icfpc2013.cloudapp.net" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
59 resp <- cli post: string toPath: "/eval?auth=" . key withType: "application/json" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
60 evalResponse: resp |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
61 } |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
62 } |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
63 } |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
64 |
15
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
65 guessRequest <- :id :prog { |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
66 #{ |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
67 string <- { |
17
566960135ea1
Small bit of cleanup now that the string escaping bug is fixed.
Mike Pavone <pavone@retrodev.com>
parents:
16
diff
changeset
|
68 idStr <- "\"id\":\"" . id . "\"" |
566960135ea1
Small bit of cleanup now that the string escaping bug is fixed.
Mike Pavone <pavone@retrodev.com>
parents:
16
diff
changeset
|
69 progStr <- "\"program\":\"" . prog . "\"" |
566960135ea1
Small bit of cleanup now that the string escaping bug is fixed.
Mike Pavone <pavone@retrodev.com>
parents:
16
diff
changeset
|
70 "{" . idStr . "," . progStr . "}" |
15
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
71 } |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
72 } |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
73 } |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
74 |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
75 evalResponse <- :httpResp { |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
76 _code <- httpResp statusCode |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
77 bod <- httpResp body |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
78 print: "Response code: " . (string: _code) . "\n" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
79 print: bod . "\n" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
80 decoded <- json decode: bod |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
81 _status <- "error" |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
82 if: _code = 200 { |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
83 _status <- decoded get: "status" withDefault: "error" |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
84 if: _status = "ok" { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
85 _outputs <- (decoded get: "outputs" withDefault: #[]) map: :num { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
86 (num from: 2) parseHex64 |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
87 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
88 #{ |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
89 status <- { "ok" } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
90 outputs <- { _outputs } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
91 string <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
92 str <- "OK:" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
93 foreach: _outputs :idx val { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
94 str <- str . "\n" . (string: idx) . ": 0x" . (hex: val) |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
95 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
96 str |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
97 } |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
98 print <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
99 print: string . "\n" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
100 } |
22
a4837071b73d
some attempts at parsing an eval response
William Morgan <bill@mrgn.org>
parents:
21
diff
changeset
|
101 } |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
102 } else: { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
103 _message <- decoded get: "message" withDefault: "" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
104 #{ |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
105 status <- { "error" } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
106 message <- { _message } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
107 string <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
108 "Error: " . _message |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
109 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
110 print <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
111 print: string . "\n" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
112 } |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
113 } |
22
a4837071b73d
some attempts at parsing an eval response
William Morgan <bill@mrgn.org>
parents:
21
diff
changeset
|
114 } |
24
e1109e33b796
some work that probably needs to be trashed on requests.tp
Mike Pavone <pavone@retrodev.com>
parents:
23
diff
changeset
|
115 } else: { |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
116 #{print <- print: "HTTP response gave error! code was: " . _code . "\n"} |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
117 |
22
a4837071b73d
some attempts at parsing an eval response
William Morgan <bill@mrgn.org>
parents:
21
diff
changeset
|
118 } |
a4837071b73d
some attempts at parsing an eval response
William Morgan <bill@mrgn.org>
parents:
21
diff
changeset
|
119 } |
a4837071b73d
some attempts at parsing an eval response
William Morgan <bill@mrgn.org>
parents:
21
diff
changeset
|
120 |
26 | 121 guessResponse <- :httpResp { |
122 _code <- httpResp statusCode | |
123 bod <- httpResp body | |
124 print: "Response code: " . (string: _code) . "\n" | |
125 print: bod . "\n" | |
126 decoded <- json decode: bod | |
127 _status <- "error" | |
128 if: _code = 200 { | |
129 _status <- decoded get: "status" withDefault: "error" | |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
130 if: _status = "win" { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
131 #{ |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
132 status <- { "win" } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
133 string <- { "OK: win" } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
134 print <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
135 print: string . "\n" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
136 } |
26 | 137 } |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
138 } else: { if: _status = "mismatch" { |
26 | 139 |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
140 _values <- (decoded get: "values" withDefault: #[]) map: :num { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
141 (num from: 2) parseHex64 |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
142 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
143 #{ |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
144 status <- { "mismatch" } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
145 values <- { _values } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
146 string <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
147 str <- "OK:" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
148 foreach: _values :idx val { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
149 str <- str . "\n" . (string: idx) . ": 0x" . (hex: val) |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
150 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
151 str |
26 | 152 } |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
153 print <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
154 print: string . "\n" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
155 } |
26 | 156 } |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
157 } else: { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
158 _message <- decoded get: "message" withDefault: "" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
159 #{ |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
160 status <- { "error" } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
161 message <- { _message } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
162 string <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
163 "Error: " . _message |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
164 } |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
165 print <- { |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
166 print: string . "\n" |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
167 } |
26 | 168 } |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
169 }} // end if |
26 | 170 } else: { |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
171 #{print <- print: "HTTP response gave error! code was: " . _code . "\n"} |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
172 } |
26 | 173 } |
174 | |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
175 main <- :args { |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
176 print: ((evalId: "someId" #[1u64 2u64 3u64]) string) . "\n" |
15
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
177 print: ((guessRequest: "someId" "someProg") string) . "\n" |
22
a4837071b73d
some attempts at parsing an eval response
William Morgan <bill@mrgn.org>
parents:
21
diff
changeset
|
178 |
25
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
179 if: (args length) > 1 { |
bb80f86c5048
Added code for sending and decoding the responses of evalRequests
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
180 key <- args get: 1 |
30
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
181 //print: ((evalProgram: "(lambda (input) (shl1 input))" #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key) |
a4bffcd381cd
eval(id) request fixed. Fail gracefully on non-200 http response.
William Morgan <bill@mrgn.org>
parents:
26
diff
changeset
|
182 print: ((evalId: "QwhG7ZpaVsfXiLRvbJfIfxl8" #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key) |
22
a4837071b73d
some attempts at parsing an eval response
William Morgan <bill@mrgn.org>
parents:
21
diff
changeset
|
183 } |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
184 } |
10
79c1db5e7ebd
sending broken file for mike to check error
William Morgan <bill@mrgn.org>
parents:
diff
changeset
|
185 } |