Changeset 6435


Ignore:
Timestamp:
Jul 21, 2016, 6:39:00 PM (8 years ago)
Author:
mmh
Message:

add option to set status and add support for running tools from python

Location:
trunk/lang/python/Rappture
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/python/Rappture/__init__.py

    r5592 r6435  
    1010import Utils
    1111import encoding
     12from raptool import Tool
    1213
    1314# encoding/decoding flags
  • trunk/lang/python/Rappture/python_api.rst

    r5669 r6435  
    257257
    258258
     259
     260----------
     261
     262RUNNING RAPPTURE TOOLS FROM PYTHON
     263----------------------------------
     264
     265If you want to write a Python program that runs Rappture tools, you can do it with the above API and
     266the Rappture Tool class.  For example, to run a published tool named "complam":
     267
     268.. code-block:: python
     269
     270    import Rappture
     271    io = Rappture.Tool("complam")
     272
     273    # Set input values for the Complam tool
     274    material = io['input.group(tabs).group(Material)']
     275    material['number(E1).current'] = E1 / 1e9
     276    material['number(E2).current'] = E2 / 1e9
     277
     278    # run the tool
     279    io.run()
     280
     281    # read the results
     282    ex = io['output.number(Ex).current'].value
     283    nu = io['output.number(nu).current'].value
     284
    259285REFERENCE
    260286=========
     
    272298-------
    273299
    274 - node.close()
    275     Writes out the XML.
     300- node.close(status=0)
     301    Sets the output status field and writes out the XML.
    276302
    277303Reading
  • trunk/lang/python/Rappture/pyxml.py

    r5669 r6435  
    7979        return elem.xml()
    8080
    81     def close(self):
     81    def close(self, status=0):
     82        self.lib.result(status)
    8283        result(self.lib)
     84
Note: See TracChangeset for help on using the changeset viewer.