source: trunk/python/Rappture/number.py @ 665

Last change on this file since 665 was 665, checked in by dkearney, 14 years ago

Updates to Rappture::Utils::progress for all languages
removed the dependancy on Rappture.Units from within number.py, it should only depend on Rappture which will include Rappture.Units
added Rappture.Units as a module to load when people import Rappture in python.
added -V pbs variable to queue.py to include qsub environment variables in the submitted job.
updated setup.py.in to install Rappture.Utils
added progress bar to all app-fermi examples showing how to use the Rappture::Utils::progress function in all languages.
added destructor definitions to Node classes in src2/core

File size: 1.7 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: number
3#
4# ======================================================================
5#  AUTHOR:  Michael McLennan, Purdue University
6#  Copyright (c) 2004-2005  Purdue Research Foundation
7#
8#  See the file "license.terms" for information on usage and
9#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10# ======================================================================
11import Rappture
12
13class number:
14    def __init__(self,path,id,**kwargs):
15        """
16        Blah, blah...
17        """
18
19        self.basePath = path
20        self.path = path + ".number(" + id + ")"
21        self.id = id
22        self.attribs = kwargs
23
24    def put(self,lib):
25        lib.put(self.path)
26        for key,val in self.attribs.items():
27            lib.put(self.path+'.'+key, str(val))
28
29    def __coerce__(self,other):
30        attrList = Rappture.driver.children(self.path, "id")
31        attrName = 'default'
32        for attr in attrList:
33            if attr == 'current':
34                attrName = attr
35        s = Rappture.driver.get(self.path+'.'+attrName)
36        # return (float(s),other)
37        #
38        # the following code doesnt work if the <units> tag does not exist
39        # becasue it sends an empty string to convert and it fails there
40        toUnit = Rappture.driver.get(self.path+'.units')
41        if (toUnit != None):
42            val = Rappture.Units.convert(s,to=toUnit,units="off")
43        else :
44            # you have to hope the user didn't put units onto the <default>
45            # value (which is unlikely in most cases, btw)
46            val = float(s)
47        return (val,other)
Note: See TracBrowser for help on using the repository browser.