Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -29,11 +29,11 @@ subrun.scm portlogger.scm archive.scm env.scm \ diff-report.scm cgisetup/models/pgdb.scm # module source files MSRCFILES = dbfile.scm debugprint.scm mtargs.scm commonmod.scm dbmod.scm \ - tcp-transportmod.scm + tcp-transportmod.scm rmtmod.scm all : $(PREFIX)/bin/.$(ARCHSTR) mtest dboard mtut tcmt transport-mode.scm : transport-mode.scm.template cp transport-mode.scm.template transport-mode.scm Index: rmt.scm ================================================================== --- rmt.scm +++ rmt.scm @@ -27,16 +27,16 @@ (declare (uses dbfile)) ;; (declare (uses dbmemmod)) (declare (uses dbmod)) (declare (uses tcp-transportmod)) (include "common_records.scm") -;; (declare (uses rmtmod)) +(declare (uses rmtmod)) ;; used by http-transport -(import dbfile) ;; rmtmod) - -(import commonmod +(import dbfile + rmtmod + commonmod ;; dbmemmod dbfile dbmod tcp-transportmod) @@ -133,10 +133,12 @@ (case (rmt:transport-mode) ((http)(http-transport-handler runremote cmd rid params attemptnum area-dat areapath readonly-mode)) ((tcp) (tcp-transport-handler runremote cmd rid params attemptnum area-dat areapath readonly-mode testsuite mtexe)) ((nfs) (nfs-transport-handler runremote cmd rid params attemptnum area-dat areapath readonly-mode testsuite mtexe)) ))) + +(rmtmod:send-receive rmt:send-receive) ;; make send-receive available to rmtmod via parameter (define (nfs-transport-handler runremote cmd run-id params attemptnum area-dat areapath readonly-mode testsuite mtexe) (let* ((keys (common:get-fields *configdat*)) (dbstruct (dbmod:nfs-get-dbstruct run-id keys (dbfile:db-init-proc) areapath))) (api:dispatch-request dbstruct cmd run-id params))) Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -18,30 +18,72 @@ ;;====================================================================== (declare (unit rmtmod)) (declare (uses commonmod)) -(declare (uses apimod)) +;; (declare (uses apimod)) ;; (declare (uses apimod.import)) -(declare (uses ulex)) +;; (declare (uses ulex)) ;; (include "ulex/ulex.scm") (module rmtmod * -(import scheme chicken data-structures extras) +(import scheme chicken data-structures extras matchable) (import (prefix sqlite3 sqlite3:) posix typed-records srfi-18) -(import (prefix commonmod cmod:)) -(import apimod) -(import (prefix ulex ulex:)) +(import commonmod) ;; (prefix commonmod cmod:)) +;; (import apimod) +;; (import (prefix ulex ulex:)) (defstruct alldat (areapath #f) (ulexdat #f) ) +;; hold the send-receive proc in this parameter +(define rmtmod:send-receive (make-parameter #f)) + +;;====================================================================== +;; import an sexpr file into the db +;;====================================================================== + +(define (rmt:import-sexpr sexpr-file) + (if (file-exists? sexpr-file) + (let* ((data (with-input-from-file sexpr-file read))) + (for-each + (lambda (targ-dat) + (rmt:import-target targ-dat)) ;; ("target" ("run1" ("data" (1 ("field" . "value") ... + data)))) + +(define (rmt:import-target targ-dat) + (let* ((target (car targ-dat)) + (data (cdr targ-dat))) + (for-each + (lambda (run-dat) + (rmt:import-run target run-dat)) ;; ("runname" ("data" ("testid" ("field" . "value") ... + data))) + +(define (rmt:import-run target run-dat) + (let* ((runname (car run-dat)) + (all-dat (cdr run-dat)) + (tests-data (alist-ref "data" all-dat equal?)) + (run-meta (alist-ref "meta" all-dat equal?)) + (run-id (rmt:insert-run target runname run-meta))) + (for-each + (lambda (test-dat) + (let* ((test-id (car test-dat)) + (test-rec (cdr test-dat))) + (rmt:insert-test run-id test-rec))) + tests-data))) + +(define (rmt:insert-run target runname run-meta) + (rmtmod:send-receive 'insert-run #f (list target runname run-meta))) + +(define (rmt:insert-test run-id test-rec) + (rmtmod:send-receive 'insert-test run-id test-rec)) + ;;====================================================================== ;; return the handle struct for sending queries to a specific database ;; - initializes the connection object if this is the first access ;; - finds the "captain" and asks who to talk to for the given dbfname ;; - establishes the connection to the current dbowner