1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
|
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
|
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
-
-
+
+
+
+
+
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(tdb:step-get-event_time step)))
steps)))))))))
tests)))))
runs)
(if (eq? dmode 'json)(json-write data))
(let* ((metadat-fields (delete-duplicates
(append keys '( "runname" "time" "owner" "pass_count" "fail_count" "state" "status" "comment" "id"))))
(run-fields '("state"
"shortdir"
(run-fields '(
"testname"
"item_path"
"state"
"status"
"comment"
"item_path"
"event_time"
"host"
"run_id"
"run_duration"
"attemptnum"
"testname"
"id"
"uname"
"archived"
"diskfree"
"rundir"
"cpuload"
"final_logf"))
"final_logf"
"shortdir"
"rundir"
"uname"
)
)
(newdat (to-alist data))
(allrundat (car (map cdr newdat))) ;; (car (map cdr (car (map cdr newdat)))))
(runs (append
(list "runs" ;; sheetname
metadat-fields)
(map (lambda (run)
;; (print "run: " run)
(let* ((runname (car run))
(rundat (cdr run))
(metadat (let ((tmp (assoc "meta" rundat)))
(if tmp (cdr tmp) #f))))
;; (print "runname: " runname "\n\nrundat: " )(pp rundat)(print "\n\nmetadat: ")(pp metadat)
(if metadat
(map (lambda (field)
(let ((tmp (assoc field metadat)))
(if tmp (cdr tmp) "")))
metadat-fields)
(begin
(debug:print 0 "WARNING: meta data for run " runname " not found")
'())))
'()))))
allrundat)))
;; '( ( "target" ( "runname" ( "data" ( "runid" ( "id . "37" ) ( ... ))))
(run-pages (map (lambda (targdat)
(let* ((target (car targdat))
(runsdat (cdr targdat)))
(if runsdat
(map (lambda (rundat)
(let* ((runname (car rundat))
(rundat (cdr rundat))
(testsdat (let ((tmp (assoc "data" rundat)))
(if tmp (cdr tmp) #f))))
(if testsdat
(let ((tests (map (lambda (test)
(let* ((test-id (car test))
(test-dat (cdr test)))
(map (lambda (field)
(let ((tmp (assoc field test-dat)))
(if tmp (cdr tmp) "")))
run-fields)))
testsdat)))
(print "Target: " target "/" runname ":")
(pp testsdat)
;; (print "Target: " target "/" runname " tests:")
;; (pp tests)
(cons (conc target "/" runname)
(cons (list (conc target "/" runname))
(cons '()
tests))
'())))
(cons run-fields tests)))))
(begin
(debug:print 0 "WARNING: run " target "/" runname " appears to have no data")
;; (pp rundat)
'()))))
runsdat)
'())))
newdat)) ;; we use newdat to get target
(sheets (apply list runs run-pages)))
(sheets (filter (lambda (x)
(not (null? x)))
(cons runs (map car run-pages)))))
;; (print "allrundat:")
;; (pp allrundat)
;; (print "runs:")
;; (pp runs)
(print "sheets: ")
(pp sheets)
(system "rm -rf /tmp/construct-ods")
(create-directory "/tmp/construct-ods" #t)
(if (eq? dmode 'ods)(ods:list->ods "/tmp/construct-ods" "blah.ods" sheets)))
;(print "sheets: ")
;; (pp sheets)
(let* ((tempdir (conc "/tmp/" (current-user-name) "/" (random 10000) "_" (current-process-id)))
(outputfile (or (args:get-arg "-o") "out.ods"))
(ouf (if (string-match (regexp "^[/~]+.*") outputfile) ;; full path?
outputfile
(begin
(debug:print 0 "WARNING: path given, " outputfile " is relative, prefixing with current directory")
(conc (current-directory) "/" outputfile)))))
(create-directory tempdir #t)
(if (eq? dmode 'ods)(ods:list->ods tempdir ouf sheets))
;; (system (conc "rm -rf " tempdir))
))
(set! *didsomething* #t))))
;; Don't think I need this. Incorporated into -list-runs instead
;;
;; (if (and (args:get-arg "-since")
;; (launch:setup-for-run))
;; (let* ((since-time (string->number (args:get-arg "-since")))
|