1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#! /usr/bin/env tclsh
set outdir "/web/customers/kitcreator.rkeene.org/kits"
set key ""
if {[info exists ::env(PATH_INFO)]} {
set key [lindex [split $::env(PATH_INFO) "/"] 1]
}
set status "Unknown"
set terminal 0
if {![regexp {^[0-9a-f]+$} $key]} {
set status "Invalid Key"
unset key
}
if {[info exists key]} {
set workdir [file join $outdir $key]
}
|
|
>
>
>
>
>
>
>
|
>
>
>
>
|
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
|
#! /usr/bin/env tclsh
set outdir "/web/customers/kitcreator.rkeene.org/kits"
set info [list]
if {[info exists ::env(PATH_INFO)]} {
set info [lmap item [split $::env(PATH_INFO) /] {
if {$item eq ""} {
continue
}
return -level 0 $item
}]
}
set key [lindex $info end]
set resultFormat "html"
if {[llength $info] > 1} {
set resultFormat [lindex $info 0]
}
set status "Unknown"
set terminal 0
if {![regexp {^[0-9a-f]+$} $key]} {
set status "Invalid Key"
set terminal 1
unset key
}
if {[info exists key]} {
set workdir [file join $outdir $key]
}
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
} elseif {[file exists "${outfile}.buildfail"]} {
set status "Failed"
set terminal 1
} else {
set status "Building"
}
}
puts "Content-Type: text/html"
if {[info exists url]} {
# Use a refresh here instead of a "Location" so that
# the client can see the page
puts "Refresh: 0;url=$url"
} else {
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
168
169
170
171
172
173
174
175
|
} elseif {[file exists "${outfile}.buildfail"]} {
set status "Failed"
set terminal 1
} else {
set status "Building"
}
}
if {$resultFormat in {json dict}} {
set terminalBoolean [lindex {false true} $terminal]
}
switch -exact -- $resultFormat {
"html" {
# Handled below
}
"json" {
puts "Content-Type: application/json"
puts ""
if {$status eq "Complete"} {
puts "{\"status\":\"[string tolower $status]\", \"terminal\": $terminalBoolean, \"kit_url\":\"$url\"}"
} else {
puts "{\"status\":\"[string tolower $status]\", \"terminal\": $terminalBoolean}"
}
exit 0
}
"dict" {
puts "Content-Type: text/plain"
puts ""
if {$status eq "Complete"} {
puts [dict create \
status [string tolower $status] \
terminal $terminalBoolean \
kit_url $url \
]
} else {
puts [dict create \
status [string tolower $status] \
terminal $terminalBoolean \
]
}
exit 0
}
default {
exit 1
}
}
puts "Content-Type: text/html"
if {[info exists url]} {
# Use a refresh here instead of a "Location" so that
# the client can see the page
puts "Refresh: 0;url=$url"
} else {
|