Check-in [f8c7c20a57]
Overview
Comment:More better API
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f8c7c20a57b88a7617195509539dfe936db79f57
User & Date: rkeene on 2019-02-28 10:19:39
Other Links: manifest | tags
Context
2019-02-28
10:29
Better error handling check-in: f2566d10e2 user: rkeene tags: trunk
10:19
More better API check-in: f8c7c20a57 user: rkeene tags: trunk
09:48
More options for the API client check-in: 3bc708ba71 user: rkeene tags: trunk
Changes

Modified build/utils/download-api-client from [172cc868bc] to [8826872ee9].

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
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




+
+
+
+
+
+
+
+
+
+




















-
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#! /usr/bin/env bash

# Define endpoint
endpoint_url="https://kitcreator.rkeene.org/kitcreator"

# Help
function print_help() {
	echo 'download-api-client [--platform <platform>] [--tcl-version <version>]'
	echo '                    [--kitcreator-version <version>] [--kitdll]'
	echo '                    [--threaded] [--debug] [--dynamictk]'
	echo '                    [--staticpkgs]'
	echo 'download-api-client {--help|--platforms|--tcl-versions|'
	echo '                     --kitcreator-versions|--packages}'
}

# Set arguments
declare -A jsonArgs
jsonArgs["platform"]="$(uname -s)-$(uname -m)"

nextArg=''
kit_filename=''
options=()
for arg in "$@"; do
	if [ -n "${nextArg}" ]; then
		jsonArgs["${nextArg}"]="${arg}"
		nextArg=''
		continue
	fi

	case "${arg}" in
		--platform|--tcl-version|--kitcreator-version)
			nextArg="${arg:2}"
			nextArg="${nextArg//-/_}"
			;;
		--kitdll|--threaded)
		--kitdll|--threaded|--debug|--dynamictk|--staticpkgs)
			options+=("${arg:2}")
			;;
		--platforms|--tcl-versions|--kitcreator-versions|--packages|--options)
			action="${arg:2}"
			action="${action//-/_}"

			formatString='%-20s | %s\n'
			printf "${formatString}" Name Description
			printf '%s+%s\n' --------------------- ---------------------
			curl -sSL -d "json={\"action\":\"${action}\"}" "${endpoint_url}" | jq -crM 'keys[] as $k | "\($k) \(.[$k])"' | while read -r platform description; do
				printf "${formatString}" "${platform}" "${description}"
			done
			exit 0
			;;
		--help)
			print_help
			exit 0
			;;
		*)
			echo "Invalid option \"${arg}\"" >&2
			print_help >&2
			exit 1
	esac
done

if [ -n "${options[*]}" ]; then
	jsonArgs["options"]="${options[@]}"
fi

72
73
74
75
76
77
78

79
80
81
82
83
84
85

86
87
88
89
90
91
92
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124







+







+







	fi

	sleep 30

	echo -n '.'
done
status="$(jq -crM .status <<<"${info}")"
build_log_url="$(jq -crM .build_log_url <<<"${info}")"

if [ -n "${buildStatusWroteHeader}" ]; then
	echo " ${status}"
fi

if [ "${status}" != "complete" ]; then
	echo "failed: ${status}" >&2
	curl -sSL "${build_log_url}" >&2

	exit 1
fi

kit_url="$(jq -crM .kit_url <<<"${info}")"
if [ -z "${kit_filename}" ]; then
	kit_filename="${kit_url//*\//}"

Modified build/web/building.cgi from [5e55e39bde] to [536bf400ea].

140
141
142
143
144
145
146
147

148
149
150
151
152
153
154
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154







-
+







	set resultsDict [dict create \
		status [string tolower $status] \
		terminal $terminalBoolean \
	]
	if {[string tolower $status] eq "complete"} {
		dict set resultsDict kit_url $url
	}
	if {[string tolower $status] in {complete building}} {
	if {[string tolower $status] in {complete building failed}} {
		dict set resultsDict build_log_url $build_log_url
		catch {
			dict set resultsDict tcl_version $buildinfo(tcl_version)
		}
		catch {
			dict set resultsDict kitcreator_version $buildinfo(kitcreator_version)
		}