- Timestamp:
- May 21, 2015, 9:23:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/builder/scripts/templates/python.tl
r3177 r5602 3 3 # ====================================================================== 4 4 # AUTHOR: Michael McLennan, Purdue University 5 # Copyright (c) 2004-201 2HUBzero Foundation, LLC5 # Copyright (c) 2004-2015 HUBzero Foundation, LLC 6 6 # 7 7 # See the file "license.terms" for information on usage and … … 17 17 import Rappture 18 18 import sys 19 from math import * 19 import 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') 20 25 21 26 # open the XML file containing the run parameters 22 io = Rappture. library(sys.argv[1])27 io = Rappture.PyXml(sys.argv[1]) 23 28 24 29 ######################################################### … … 42 47 @@OUTPUTS@@ 43 48 44 Rappture.result(io)49 io.close() 45 50 sys.exit() 46 51 } … … 49 54 code "\n# get input value for $path" 50 55 code "# returns value as string \"yes\" or \"no\"" 51 code "$id = io .get('$path.current')== 'yes'"56 code "$id = io\['$path.current'\].value == 'yes'" 52 57 } 53 58 input image { 54 59 code "\n# get input value for $path" 55 60 code "# returns base64-encoded image data" 56 code "$id = io .get('$path.current')"61 code "$id = io\['$path.current'\].value" 57 62 } 58 63 input integer { 59 64 code "\n# get input value for $path" 60 code "$id = int(io .get('$path.current'))"65 code "$id = int(io\['$path.current'\].value)" 61 66 } 62 67 input number { … … 64 69 if {$units ne ""} { 65 70 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" 67 72 code "$id = Rappture.Units.convert(str, to=\"$units\", units=\"off\")" 68 73 } else { 69 74 code "\n# get input value for $path" 70 code "$id = float(io .get('$path.current'))"75 code "$id = float(io\['$path.current'\].value)" 71 76 } 72 77 } 73 78 input * { 74 79 code "\n# get input value for $path" 75 code "$id = io .get('$path.current')"80 code "$id = io\['$path.current'\].value" 76 81 } 77 82 78 83 output curve { 79 84 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)" 83 87 } 84 88 output histogram { 85 89 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)" 90 93 } 91 94 output image { 92 95 code "\n# save output value for $path" 93 96 code "# data should be base64-encoded image data" 94 code "io .put('$path.current', imdata)"97 code "io\['$path.current'\] = imdata" 95 98 } 96 99 output * { 97 100 code "\n# save output value for $path" 98 code "io .put('$path.current',$id)"101 code "io\['$path.current'\] = $id" 99 102 } 100 103 }
Note: See TracChangeset
for help on using the changeset viewer.