Changeset 5545 for branches/uq


Ignore:
Timestamp:
May 18, 2015, 11:03:41 AM (9 years ago)
Author:
mmh
Message:

update for new python api

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/uq/builder/scripts/templates/python.tl

    r3177 r5545  
    33# ======================================================================
    44#  AUTHOR:  Michael McLennan, Purdue University
    5 #  Copyright (c) 2004-2012  HUBzero Foundation, LLC
     5#  Copyright (c) 2004-2015  HUBzero Foundation, LLC
    66#
    77#  See the file "license.terms" for information on usage and
     
    1717import Rappture
    1818import sys
    19 from math import *
     19import numpy as np
     20
     21# uncomment these to redirect stdout and stderr
     22# to files for debugging.
     23#sys.stderr = open('debug.err', 'w')
     24#sys.stdout = open('debug.out', 'w')
    2025
    2126# open the XML file containing the run parameters
    22 io = Rappture.library(sys.argv[1])
     27io = Rappture.PyXml(sys.argv[1])
    2328
    2429#########################################################
     
    4247@@OUTPUTS@@
    4348
    44 Rappture.result(io)
     49io.close()
    4550sys.exit()
    4651}
     
    4954    code "\n# get input value for $path"
    5055    code "# returns value as string \"yes\" or \"no\""
    51     code "$id = io.get('$path.current') == 'yes'"
     56    code "$id = io\['$path.current'\].value == 'yes'"
    5257  }
    5358  input image {
    5459    code "\n# get input value for $path"
    5560    code "# returns base64-encoded image data"
    56     code "$id = io.get('$path.current')"
     61    code "$id = io\['$path.current'\].value"
    5762  }
    5863  input integer {
    5964    code "\n# get input value for $path"
    60     code "$id = int(io.get('$path.current'))"
     65    code "$id = int(io\['$path.current'\].value)"
    6166  }
    6267  input number {
     
    6469    if {$units ne ""} {
    6570      code "\n# get input value for $path and convert to $units"
    66       code "str = io.get('$path.current')"
     71      code "str = io\['$path.current'\].value"
    6772      code "$id = Rappture.Units.convert(str, to=\"$units\", units=\"off\")"
    6873    } else {
    6974      code "\n# get input value for $path"
    70       code "$id = float(io.get('$path.current'))"
     75      code "$id = float(io\['$path.current'\].value)"
    7176    }
    7277  }
    7378  input * {
    7479    code "\n# get input value for $path"
    75     code "$id = io.get('$path.current')"
     80    code "$id = io\['$path.current'\].value"
    7681  }
    7782
    7883  output curve {
    7984    code "\n# save output value for $path"
    80     code "# this shows just one (x,y) point -- modify as needed"
    81     code "line = \"%g %g\n\" % (x, y)"
    82     code "io.put('$path.component.xy', line, append=1)"
     85    code "# x and y should be lists or arrays -- modify as needed"
     86    code "io\['$path.component.xy'\] = (x, y)"
    8387  }
    8488  output histogram {
    8589    code "\n# save output value for $path"
    86     code "# this shows just one point -- modify as needed"
    87     code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)"
    88     code "line = \"%g %g %g\n\" % (x, h, w)"
    89     code "io.put('$path.component.xhw', line, append=1)"
     90    code "# x and y should be lists or arrays -- modify as needed"
     91    code "# (x,h,w) = x-coord, height of bar, and width of bar"
     92    code "io\['$path.component.xhw'\] = (x, h, w)"
    9093  }
    9194  output image {
    9295    code "\n# save output value for $path"
    9396    code "# data should be base64-encoded image data"
    94     code "io.put('$path.current', imdata)"
     97    code "io\['$path.current'\] = imdata"
    9598  }
    9699  output * {
    97100    code "\n# save output value for $path"
    98     code "io.put('$path.current',$id)"
     101    code "io\['$path.current'\] = $id"
    99102  }
    100103}
Note: See TracChangeset for help on using the changeset viewer.