source: branches/1.3/gui/apps/execute.tcl @ 4857

Last change on this file since 4857 was 4857, checked in by dkearney, 5 years ago

merging in r4856 to 1.3 branch

  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#! /bin/sh
2# ----------------------------------------------------------------------
3#  RAPPTURE PROGRAM EXECUTION
4#
5#  This script implements the -execute option for Rappture.  It
6#  provides a way to run a specific Rappture simulation without
7#  invoking the Rappture GUI.  Instead, it takes a driver file with
8#  the required parameters, submits that for execution, and then
9#  returns the run.xml file.  If the -tool file is specified, then
10#  it double-checks the driver against the tool to make sure that
11#  the requested tool and version are compatible.
12#
13#  This is normally invoked by launcher.tcl, so it expects $driverxml
14#  and $toolxml variable to be already set.
15#
16#  USAGE: execute.tcl
17# ======================================================================
18#  AUTHORS:  Michael McLennan, Purdue University
19#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
20#
21#  See the file "license.terms" for information on usage and
22#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
23# ======================================================================
24#\
25exec tclsh "$0" $*
26# ----------------------------------------------------------------------
27# tclsh executes everything from here on...
28
29# bring in the Rappture object system
30package require Rappture
31Rappture::objects::init
32Rappture::resources::load
33
34# load the XML info in the driver file
35if {[catch {Rappture::library $driverxml} result]} {
36    puts stderr "ERROR while loading driver file \"$driverxml\""
37    puts stderr $result
38    exit 1
39}
40set driverobj $result
41
42# If tool.xml is not specified, try to find it the way Rappture would.
43if {$toolxml eq ""} {
44    if {[file isfile tool.xml]} {
45        set toolxml [file normalize tool.xml]
46    } elseif {[file isfile [file join rappture tool.xml]]} {
47        set toolxml [file normalize [file join rappture tool.xml]]
48    }
49}
50
51# If there's still no tool.xml, then see if we can find tooldir in driver
52if {$toolxml eq ""} {
53    set tooldir [$driverobj get tool.version.application.directory(tool)]
54    if {$tooldir eq ""} {
55        puts stderr "ERROR: missing -tool option, and driver file doesn't contain sufficient detail to locate the desired tool."
56        exit 1
57    }
58
59    set toolxml [file join $tooldir tool.xml]
60    if {![file exists $toolxml]} {
61        puts stderr "ERROR: missing tool.xml file \"$toolxml\""
62        exit 1
63    }
64}
65
66set installdir [file dirname [file normalize $toolxml]]
67set toolobj [Rappture::library $toolxml]
68set TaskObj [Rappture::Task ::#auto $toolobj $installdir]
69
70# tasks in execute mode run quietly and don't try to save results
71$TaskObj configure -jobstats "" -resultdir ""
72
73# Transfer input values from driver to TaskObj, and then run.
74# ----------------------------------------------------------------------
75
76# copy inputs from the test into the run file
77$TaskObj reset
78foreach path [Rappture::entities -as path $driverobj input] {
79    if {[$driverobj element -as type $path.current] ne ""} {
80        lappend args $path [$driverobj get $path.current]
81    }
82}
83
84# run the desired case...
85foreach {status result} [eval $TaskObj run $args] break
86
87if {$status == 0 && [Rappture::library isvalid $result]} {
88    set runxml $result
89    $runxml put output.status ok
90} else {
91    # build a run file for the result output
92    set info "<?xml version=\"1.0\"?>\n[$driverobj xml]"
93    set runxml [Rappture::LibraryObj ::#auto $info]
94    $runxml put output.log $result
95    $runxml put output.status failed
96}
97$runxml put output.time [clock format [clock seconds]]
98
99$runxml put tool.version.rappture.version $::Rappture::version
100$runxml put tool.version.rappture.revision $::Rappture::build
101
102if {[info exists tcl_platform(user)]} {
103    $runxml put output.user $::tcl_platform(user)
104}
105
106puts "<?xml version=\"1.0\"?>\n[$runxml xml]"
107exit $status
Note: See TracBrowser for help on using the repository browser.