Improve handling of gnuplot executable.

(`which` at startup, check for executable)
This commit is contained in:
interp 2003-01-16 11:10:38 +00:00
parent 1b5098bea0
commit 0656602636
1 changed files with 19 additions and 5 deletions

View File

@ -9,6 +9,7 @@
define-record-types
locks
let-opt
receiving
)
(begin
@ -30,8 +31,8 @@
(define (state-counter)
(state:counter (get-servlet-data)))
;; Leave this global. Server is running on a single system.
(define gnuplot "/usr/bin/gnuplot")
;; Leave this global. Servers are running on a single system.
(define gnuplot #f) ;; Set in main.
(define lock (make-lock))
(define (profile req . maybe-update-text)
@ -63,7 +64,11 @@
,new-url
POST
(p "This uses " (var "gnuplot") " that is searched at "
,input-field ,change-button)))
,input-field ,change-button (br)
,(if (not (gnuplot-executable? gnuplot))
'(font (@ (color "red"))
"Note: There is no executable.")
#f))))
(li (URL ,(reset-address new-url)
"Delete files and reset profile state.")))
(hr)
@ -90,12 +95,15 @@
(reset-and-return-to-main-page req))
(else
(let ((new-gnuplot-location (input-field-value input-field bindings)))
(if (and new-gnuplot-location
(file-executable? new-gnuplot-location))
(if (gnuplot-executable? new-gnuplot-location)
(begin
(set! gnuplot new-gnuplot-location)
(profile req (format #f "Gnuplot is now searched at ~a." gnuplot)))
(profile req "Please enter a file name of an existing executable.")))))))
(define (gnuplot-executable? gnuplot-file-name)
(and gnuplot-file-name
(file-executable? gnuplot-file-name)))
(define (new-profile req)
(let ((state (get-servlet-data)))
@ -223,8 +231,14 @@ plot '~a' title 'Servlet Profiling ~a' with lines"
(define (main req)
;; We'll fill this out soon.
(set! gnuplot (search-gnuplot))
(set-servlet-data! (make-state #f #f 0))
(reset-profiling-state!)
(profile req))
(define (search-gnuplot)
(receive (status ports) (run/collecting (1) (which gnuplot))
(if (zero? status)
(read-line ports)
"")))
))