Changeset 96


Ignore:
Timestamp:
Oct 10, 2005 3:29:58 PM (17 years ago)
Author:
dkearney
Message:

added units conversion to coerce to the number.py
added a command to exec a new process to launch the gui in interface.py
these might make it possible to run examples/app-fermi/2.0

Location:
trunk/python/Rappture
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/Rappture/interface.py

    r55 r96  
    1414#  Copyright (c) 2005  Purdue Research Foundation, West Lafayette, IN
    1515# ======================================================================
    16 import getopt, sys
     16import getopt, sys, os
    1717import atexit
    1818import Rappture
     
    4646            lib = Rappture.library('<?xml version="1.0"?><run><tool>' +
    4747                    '<about>Press Simulate to view results.</about>' +
    48                     '<command>' +argv[0]+ ' -d @driver</command></tool></run>')
     48                    '<command>python ' +argv[0]+ ' -d @driver</command></tool></run>')
    4949
    5050            for module in args:
     
    5454                        s.put(lib)
    5555
    56             f = open("driver.xml","w")
     56            toolFileName = "tool.xml"
     57            f = open(toolFileName,"w")
    5758            f.write( lib.xml() )
    5859            f.close()
    5960
    6061            print 'launch the gui...'
     62            #
     63            # this doesnt work, but needs to. when we
     64            # os.execvp('driver', driverArgs ) with following definition of
     65            # driverArgs (and we change the name of toolFileName), program
     66            # does not send the driver program the arguments as expected.
     67            #
     68            #driverArgs = ('-tool', toolFileName)
     69            driverArgs = ()
     70            os.execvp('driver', driverArgs )
    6171            sys.exit(0)
    6272
  • trunk/python/Rappture/number.py

    r55 r96  
    77# ======================================================================
    88import Rappture
     9import Rappture.Units
    910
    1011class number:
     
    3132                attrName = attr
    3233        s = Rappture.driver.get(self.path+'.'+attrName)
    33         return (float(s),other)
     34        # return (float(s),other)
     35        #
     36        # the following code doesnt work if the <units> tag does not exist
     37        # becasue it sends an empty string to convert and it fails there
     38        toUnit = Rappture.driver.get(self.path+'.units')
     39        if (toUnit != None):
     40            val = Rappture.Units.convert(s,to=toUnit,units="off")
     41        else :
     42            # you have to hope the user didn't put units onto the <default>
     43            # value (which is unlikely in most cases, btw)
     44            val = float(s)
     45        return (val,other)
Note: See TracChangeset for help on using the changeset viewer.