--- ray/src/util/do_action.tcl 1994/10/27 15:56:06 2.1 +++ ray/src/util/do_action.tcl 1995/10/17 21:28:06 2.9 @@ -3,6 +3,9 @@ # Action screen for trad # +set batch_fmt "Process %d on %s started" +set hostname [exec hostname] + proc make_script {} { # make run script global scname rpview curmess set rfn /usr/tmp/rf[pid] @@ -37,7 +40,6 @@ proc make_oct args { # Make octree file ($args is {-t set fi [open "|make $radvar(OCTREE) $args" r] while {[gets $fi curmess] >= 0} { update ; after 1000 } catch {close $fi} curmess - if {"$args" == {}} {return} } if {"$args" == {}} { run_rad -v 0 @@ -65,13 +67,14 @@ proc run_rad args { # Run rad command with given argu } proc run_batch {} { # start rendering in background - global rpview bfname batch_pid curmess rifname mywin + global rpview bfname batch_pid curmess rifname mywin batch_fmt hostname if {! [chksave]} {return} if [catch {set fo [open $bfname w]} curmess] { return } # Make space for PID to be written later - puts $fo " " + puts $fo \ +" " if {$rpview == " ALL"} { set radcom "rad" } else { @@ -85,7 +88,8 @@ proc run_batch {} { # start rendering in background set batch_pid [eval exec $radcom >>& $bfname &] # Now, write PID and close file seek $fo 0 - puts -nonewline $fo $batch_pid + puts -nonewline $fo "[format $batch_fmt $batch_pid $hostname]\ + [exec date]" close $fo set curmess "Batch rendering process $batch_pid started." # Correct button stati @@ -101,7 +105,7 @@ proc kill_batch {} { # kill batch rendering switch -glob [exec uname] { SunOS - ULTRIX {set ps "ps -lg"} - default {set ps "ps -lu $env(USER)"} + default {set ps "ps -lu $env(LOGNAME)"} } set fi [open "|$ps" r] gets $fi li @@ -144,37 +148,33 @@ proc make_vmenus {} { # make/update view menus set rvview [lindex [lindex $radvar(view) 0] 0] } catch {destroy $mywin.rivmb.m} + catch {destroy $mywin.rbvmb.m} if {[llength $radvar(view)] < 2} { $mywin.rivmb configure -state disabled - } else { - menu $mywin.rivmb.m - $mywin.rivmb configure -menu $mywin.rivmb.m - foreach v $radvar(view) { - $mywin.rivmb.m add radiobutton -label [lindex $v 0] \ - -variable rvview -value [lindex $v 0] - } + return } - catch {destroy $mywin.rbvmb.m} - if {[llength $radvar(view)] < 2} { - $mywin.rbvmb configure -state disabled - } else { - menu $mywin.rbvmb.m - $mywin.rbvmb configure -menu $mywin.rbvmb.m - $mywin.rbvmb.m add radiobutton -label ALL \ - -variable rpview -value " ALL" - $mywin.rbvmb.m add separator - foreach v $radvar(view) { - $mywin.rbvmb.m add radiobutton -label [lindex $v 0] \ - -variable rpview -value [lindex $v 0] - } + menu $mywin.rivmb.m + $mywin.rivmb configure -menu $mywin.rivmb.m -state normal + foreach v $radvar(view) { + $mywin.rivmb.m add radiobutton -label [lindex $v 0] \ + -variable rvview -value [lindex $v 0] } + menu $mywin.rbvmb.m + $mywin.rbvmb configure -menu $mywin.rbvmb.m + $mywin.rbvmb.m add radiobutton -label ALL \ + -variable rpview -value " ALL" + $mywin.rbvmb.m add separator + foreach v $radvar(view) { + $mywin.rbvmb.m add radiobutton -label [lindex $v 0] \ + -variable rpview -value [lindex $v 0] + } } proc do_action w { # Action screen global rifname rvview rpview radvar bfname batch_pid \ - curmess scname mywin alldone + curmess scname mywin alldone batch_fmt hostname if {"$w" == "done"} { - unset rpview bfname batch_pid mywin + unset rvview rpview bfname batch_pid mywin return } set bfname [file rootname [file tail $rifname]].err @@ -223,13 +223,34 @@ proc do_action w { # Action screen -command {view_txt $bfname} place $w.rbce -relwidth .1786 -relheight .0610 -relx .6429 -rely .5488 helplink $w.rbce trad action checkerr - if [file exists $bfname] { + if [file isfile $bfname] { set fi [open $bfname r] - eval set batch_pid [gets $fi] - gets $fi radcom + if {[scan [gets $fi] $batch_fmt batch_pid batch_host] != 2} { + set batch_host unknown + set radcom {} + } else { + gets $fi radcom + } close $fi - if [catch {exec /bin/kill -0 $batch_pid}] { + if [string match "rad -v *" $radcom] { + set rpview [lindex $radcom 2] + } else { + set rpview " ALL" + } + if {"$hostname" != "$batch_host"} { if $alldone { + set curmess "Batch rendering finished\ + on $batch_host." + } else { + set curmess "Batch rendering on\ + $batch_host -- status UNKNOWN." + $w.rbst configure -state disabled + $w.rbvmb configure -state disabled + } + set batch_pid 0 + $w.rbki configure -state disabled + } elseif {[catch {exec /bin/kill -0 $batch_pid}]} { + if $alldone { set curmess "Batch rendering finished." } else { set curmess "Batch rendering stopped." @@ -239,11 +260,6 @@ proc do_action w { # Action screen $w.rbki configure -state disabled } else { set curmess "Batch rendering process $batch_pid running." - if [string match "rad -v *" $radcom] { - set rpview [lindex $radcom 2] - } else { - set rpview " ALL" - } $w.rbst configure -state disabled $w.rbvmb configure -state disabled }