Changeset 4962 for branches/1.3/gui/apps/launcher.tcl
- Timestamp:
- Jan 29, 2015 7:05:50 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/apps/launcher.tcl
r4850 r4962 27 27 set mainscript "" 28 28 set alist "" 29 set loadlist "" 29 30 set toolxml "" 31 32 # ---------------------------------------------------------------------- 33 # Look for parameters passed into the tool session. If there are 34 # any "file" parameters, they indicate files that should be loaded 35 # for browsing or executed to get results: 36 # 37 # file(load):/path/to/run.xml 38 # file(execute):/path/to/driver.xml 39 # ---------------------------------------------------------------------- 40 set params(opt) "" 41 set params(load) "" 42 set params(execute) "" 43 set params(input) "" 44 45 if {[info exists env(TOOL_PARAMETERS)]} { 46 # if we can't find the file, wait a little 47 set ntries 25 48 while {$ntries > 0 && ![file exists $env(TOOL_PARAMETERS)]} { 49 after 200 50 incr ntries -1 51 } 52 53 if {![file exists $env(TOOL_PARAMETERS)]} { 54 # still no file after all that? then skip parameters 55 puts stderr "WARNING: can't read tool parameters in file \"$env(TOOL_PARAMETERS)\"\nFile not found." 56 57 } elseif {[catch { 58 # read the file and parse the contents 59 set fid [open $env(TOOL_PARAMETERS) r] 60 set info [read $fid] 61 close $fid 62 } result] != 0} { 63 puts stderr "WARNING: can't read tool parameters in file \"$env(TOOL_PARAMETERS)\"\n$result" 64 65 } else { 66 # parse the contents of the tool parameter file 67 foreach line [split $info \n] { 68 set line [string trim $line] 69 if {$line eq "" || [regexp {^#} $line]} { 70 continue 71 } 72 73 if {[regexp {^([a-zA-Z]+)(\(into\:)(.+)\)\:(.+)$} $line match type name path value] 74 || [regexp {^([a-zA-Z]+)(\([^)]+\))?\:(.+)} $line match type name value]} { 75 if {$type eq "file"} { 76 switch -exact -- $name { 77 "(load)" - "" { 78 lappend params(load) $value 79 set params(opt) "-load" 80 } 81 "(execute)" { 82 set params(execute) $value 83 set params(opt) "-execute" 84 } 85 "(input)" { 86 set params(input) $value 87 set params(opt) "-input" 88 } 89 "(into:" { 90 namespace eval ::Rappture { # forward decl } 91 set ::Rappture::parameters($path) $value 92 } 93 default { 94 puts stderr "WARNING: directive $name not recognized for file parameter \"$value\"" 95 } 96 } 97 } 98 } 99 } 100 } 101 } 30 102 31 103 # scan through the arguments and look for the function … … 81 153 lappend alist -tool $toolxml 82 154 } 83 -t ool - -testdir - -nosim {155 -testdir - -nosim { 84 156 lappend alist $opt [lindex $argv 0] 85 157 set argv [lrange $argv 1 end] … … 93 165 } 94 166 -load { 95 lappend alist $opt96 167 while { [llength $argv] > 0 } { 97 168 set val [lindex $argv 0] … … 99 170 break 100 171 } 101 lappend alist $val172 lappend loadlist $val 102 173 set argv [lrange $argv 1 end] 103 174 } … … 115 186 } 116 187 117 # If no arguments, assume that it's the -run option 188 # If no arguments, check to see if there are any tool parameters. 189 # If not, then assume that it's the -run option. 118 190 if {$mainscript eq ""} { 119 package require RapptureGUI 120 set guidir $RapptureGUI::library 121 set mainscript [file join $guidir scripts main.tcl] 122 set reqpkgs Tk 191 switch -- $params(opt) { 192 -load { 193 # add tool parameters to the end of any files given on cmd line 194 set loadlist [concat $loadlist $params(load)] 195 set alist [concat $alist -load $loadlist] 196 197 package require RapptureGUI 198 set guidir $RapptureGUI::library 199 set mainscript [file join $guidir scripts main.tcl] 200 set reqpkgs Tk 201 } 202 -execute { 203 if {[llength $params(execute)] != 1} { 204 puts stderr "ERROR: wrong number of (execute) files in TOOL_PARAMETERS (should be only 1)" 205 exit 1 206 } 207 set driverxml [lindex $params(execute) 0] 208 if {![file readable $driverxml]} { 209 puts stderr "error: driver file \"$driverxml\" not found" 210 exit 1 211 } 212 set dir [file dirname [info script]] 213 set mainscript [file join $dir execute.tcl] 214 set reqpkgs "" 215 } 216 "" - "-input" { 217 package require RapptureGUI 218 set guidir $RapptureGUI::library 219 set mainscript [file join $guidir scripts main.tcl] 220 set reqpkgs Tk 221 222 # finalize the -input argument for "rappture -run" 223 if {$params(input) ne ""} { 224 if {![file readable $params(input)]} { 225 puts stderr "error: driver file \"$params(input)\" not found" 226 exit 1 227 } 228 set alist [concat $alist -input $params(input)] 229 } 230 231 # finalize any pending -load arguments for "rappture -run" 232 if {[llength $loadlist] > 0} { 233 set alist [concat $alist -load $loadlist] 234 } 235 } 236 default { 237 puts stderr "internal error: funny action \"$params(opt)\" inferred from TOOL_PARAMETERS" 238 exit 1 239 } 240 } 241 } else { 242 # finalize any pending -load arguments for "rappture -run" 243 if {[llength $loadlist] > 0} { 244 set alist [concat $alist -load $loadlist] 245 } 123 246 } 124 247
Note: See TracChangeset
for help on using the changeset viewer.