Changeset 4984 for branches/1.4/gui
- Timestamp:
- Feb 8, 2015, 6:57:52 PM (10 years ago)
- Location:
- branches/1.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4
-
branches/1.4/gui/apps/execute.tcl
r4864 r4984 67 67 set toolobj [Rappture::library $toolxml] 68 68 set TaskObj [Rappture::Task ::#auto $toolobj $installdir] 69 set LogFid "" 69 70 70 # tasks in execute mode run quietly and don't try to save results 71 $TaskObj configure -jobstats "" -resultdir "" 71 # Define some things that we need for logging status... 72 # ---------------------------------------------------------------------- 73 proc log_output {message} { 74 global LogFid 75 76 if {$LogFid ne ""} { 77 # 78 # Scan through and pick out any =RAPPTURE-PROGRESS=> messages. 79 # 80 set percent "" 81 while {[regexp -indices \ 82 {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \ 83 match percent mesg]} { 84 85 foreach {i0 i1} $percent break 86 set percent [string range $message $i0 $i1] 87 88 foreach {i0 i1} $mesg break 89 set mesg [string range $message $i0 $i1] 90 91 foreach {i0 i1} $match break 92 set message [string replace $message $i0 $i1] 93 } 94 if {$percent ne ""} { 95 # report the last percent progress found 96 log_append progress "$percent% - $mesg" 97 } 98 } 99 } 100 101 # Actually write to the log file 102 proc log_append {level message} { 103 global LogFid 104 105 if {$LogFid ne ""} { 106 set date [clock format [clock seconds] -format {%Y-%m-%dT%H:%M:%S%z}] 107 set host [info hostname] 108 puts $LogFid "$date $host rappture [pid] \[$level\] $message" 109 flush $LogFid 110 } 111 } 112 113 # Actually write to the log file 114 proc log_stats {args} { 115 set line "" 116 foreach {key val} $args { 117 append line "$key=$val " 118 } 119 log_append usage $line 120 } 121 122 # Parse command line options to see 123 # ---------------------------------------------------------------------- 124 Rappture::getopts argv params { 125 value -status "" 126 value -output "" 127 value -cleanup no 128 } 129 130 if {$params(-status) ne ""} { 131 set LogFid [open $params(-status) w] 132 $TaskObj configure -logger {log_append status} -jobstats log_stats 133 } 134 135 if {$params(-output) eq ""} { 136 # no output? then run quietly and don't try to save results 137 $TaskObj configure -jobstats "" -resultdir "" 138 } 72 139 73 140 # Transfer input values from driver to TaskObj, and then run. … … 80 147 lappend args $path [$driverobj get $path.current] 81 148 } 149 } 150 151 if {$params(-status) ne ""} { 152 # recording status? then look through output for progress messages 153 lappend args -output log_output 82 154 } 83 155 … … 95 167 $runxml put output.status failed 96 168 } 97 $runxml put output.time [clock format [clock seconds]]98 169 99 $runxml put tool.version.rappture.version $::Rappture::version 100 $runxml put tool.version.rappture.revision $::Rappture::build 101 102 if {[info exists tcl_platform(user)]} { 103 $runxml put output.user $::tcl_platform(user) 170 # Handle output 171 # ---------------------------------------------------------------------- 172 switch -- $params(-output) { 173 "" { 174 # no output file -- write to stdout 175 puts "<?xml version=\"1.0\"?>\n[$runxml xml]" 176 } 177 "@default" { 178 # do the usual Rappture thing -- move to results dir 179 # but ignore any errors if it fails 180 catch {$TaskObj save $runxml} 181 } 182 default { 183 # save to the specified file 184 $TaskObj save $runxml $params(-output) 185 } 104 186 } 105 187 106 puts "<?xml version=\"1.0\"?>\n[$runxml xml]" 188 if {$params(-cleanup)} { 189 file delete -force -- $driverxml 190 } 191 192 log_append status "exit $status" 107 193 exit $status -
branches/1.4/gui/apps/launcher.tcl
r4963 r4984 213 213 set mainscript [file join $dir execute.tcl] 214 214 set reqpkgs "" 215 216 # When executing from TOOL_PARAMETERS file directives, 217 # report status, clean up, and save output to data/results. 218 # This helps the web services interface do its thing. 219 set alist [list \ 220 -output @default \ 221 -status rappture.status \ 222 -cleanup yes] 215 223 } 216 224 "" - "-input" { -
branches/1.4/gui/scripts/tool.tcl
r4531 r4984 31 31 public method run {args} { 32 32 sync ;# sync all widget values to XML 33 eval $_task run $args 33 34 foreach {status result} [eval $_task run $args] break 35 if {$status == 0} { 36 # move good results to the data/results directory 37 $_task save $result 38 } 39 40 return [list $status $result] 34 41 } 35 42 public method abort {} {
Note: See TracChangeset
for help on using the changeset viewer.