Index: megatest.config ================================================================== --- megatest.config +++ megatest.config @@ -1,10 +1,11 @@ [setup] pktsdirs /tmp/pkts /some/other/source [areas] -fullrun tests/fullrun +# path-to-area map-target-script(optional) +fullrun tests/fullrun cat ext-tests ext-tests [contours] # mode-patt/tag-expr quick QUICKPATT/quick Index: mtut.scm ================================================================== --- mtut.scm +++ mtut.scm @@ -135,13 +135,16 @@ ;; misc ("-repl" . #f) ("-immediate" . I) )) +;; Card types: +;; ;; a action ;; u username (Unix) ;; D timestamp +;; T card type ;; process args (define *action* (if (> (length (argv)) 1) (cadr (argv)) #f)) @@ -167,14 +170,14 @@ ) )) (debug:print-error 0 *default-log-port* "Unrecognised arguments: " (string-intersperse (if (list? remargs) remargs (argv)) " "))) ;;====================================================================== -;; Process pkts +;; pkts ;;====================================================================== -(define (load-pkts-to-db mtconf) +(define (with-queue-db mtconf proc) (let* ((pktsdirs (configf:lookup mtconf "setup" "pktsdirs")) (pktsdir (if pktsdirs (car (string-split pktsdirs " ")) #f)) (toppath (configf:lookup mtconf "dyndat" "toppath")) (pdbpath (or (configf:lookup mtconf "setup" "pdbpath") pktsdir))) (if (not (and pktsdir toppath pdbpath)) @@ -181,32 +184,40 @@ (begin (print "ERROR: settings are missing in your megatest.config for area management.") (print " you need to have pktsdir in the [setup] section.")) (let* ((pdb (open-queue-db pdbpath "pkts.db" schema: '("CREATE TABLE groups (id INTEGER PRIMARY KEY,groupname TEXT, CONSTRAINT group_constraint UNIQUE (groupname));")))) - (for-each - (lambda (pktsdir) ;; look at all - (if (and (file-exists? pktsdir) - (directory? pktsdir) - (file-read-access? pktsdir)) - (let ((pkts (glob (conc pktsdir "/*.pkt")))) - (for-each - (lambda (pkt) - (let* ((uuid (cadr (string-match ".*/([0-9a-f]+).pkt" pkt))) - (exists (lookup-by-uuid pdb uuid #f))) - (if (not exists) - (let ((pktdat (string-intersperse - (with-input-from-file pkt read-lines) - "\n"))) - (add-to-queue pdb pktdat uuid 'cmd #f 0) - (print "Added " uuid " to queue")) - (print "pkt: " uuid " exists, skipping...") - ))) - pkts)))) - (string-split pktsdirs)) + (proc pktsdirs pktsdir pdb) (dbi:close pdb))))) +(define (load-pkts-to-db mtconf) + (with-queue-db + mtconf + (lambda (pktsdirs pktsdir pdb) + (for-each + (lambda (pktsdir) ;; look at all + (if (and (file-exists? pktsdir) + (directory? pktsdir) + (file-read-access? pktsdir)) + (let ((pkts (glob (conc pktsdir "/*.pkt")))) + (for-each + (lambda (pkt) + (let* ((uuid (cadr (string-match ".*/([0-9a-f]+).pkt" pkt))) + (exists (lookup-by-uuid pdb uuid #f))) + (if (not exists) + (let* ((pktdat (string-intersperse + (with-input-from-file pkt read-lines) + "\n")) + (apkt (convert-pkt->alist pktdat)) + (ptype (alist-ref 'T apkt))) + (add-to-queue pdb pktdat uuid (or ptype 'cmd) #f 0) + (print "Added " uuid " of type " ptype " to queue")) + (print "pkt: " uuid " exists, skipping...") + ))) + pkts)))) + (string-split pktsdirs))))) + ;;====================================================================== ;; Runs ;;====================================================================== ;; collect, translate, collate and assemble a pkt from the command-line @@ -270,13 +281,24 @@ (lambda () (print pkt))) (print "ERROR: cannot process commands without a pkts directory"))))) ((process import rungen) (let* ((mtconfdat (simple-setup (args:get-arg "-start-dir"))) - (mtconf (car mtconfdat))) + (mtconf (car mtconfdat)) + (toppath (configf:lookup mtconf "dyndat" "toppath"))) (case (string->symbol *action*) - ((import)(load-pkts-to-db mtconf))))))) + ((import)(load-pkts-to-db mtconf)) ;; import pkts + ((rungen) + (with-queue-db + mtconf + (lambda (pktsdirs pktdir pdb) + (let ((rgconf (find-and-read-config (conc toppath "/rungen.config"))) + (areas (configf:get-section mtconf "areas")) + (contours (configf:get-section mtconf "contours")) + (runstats (find-pkts pdb '(runstat) '()))) + (print "runstats: " runstats))))) + ))))) (if (or (args:get-arg "-repl") (args:get-arg "-load")) (begin (import extras) ;; might not be needed