source: TI04-geosplat/trunk/gsc/scripts/plotTester.py @ 798

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI04-geosplat/trunk/gsc/scripts/plotTester.py@798
Revision 798, 2.8 KB checked in by astephen, 14 years ago (diff)

Latest working version with install method.
Can accept more than one file but doesn't combine variables yet.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3keys=["filename", "var", "plotclass", "plottype", "format", "projection", "imagesize", "cont"]
4tests=[["/dxd/0d.nc", "t", "PointValueAndMetadata", "dud", "dud", "dud", "dud", "dud"],
5       ["/dxd/2dzx.nc", "t", "2DPlot", "boxfill", "gif", "standard", "800x600", "off"],
6       ["/dxd/2dyx.nc", "t", "2DPlot", "boxfill", "gif", "standard", "800x600", "on"]]
7   
8import sys
9sys.path.append("..")
10sys.path.append(".")
11sys.path.append("testSuite")
12import readline
13from ZSI.client import Binding
14from clientConfig import SOAP_SERVER_PORT
15from common import *
16import os,shutil
17from clientConfig import OUTPUT_DIR_LOCAL_PATH, OUTPUT_DIR_URL_PATH
18
19for test in tests:
20    print "Setting internal parameters for this test: ",test[3]
21    for i in range(len(keys)):
22        exec('%s="%s"' % (keys[i], test[i]))
23
24    # start session
25    print "Start session..."
26    server = Binding(url="", host="localhost", port=SOAP_SERVER_PORT)
27
28    (sessionID, secureToken)=server.startSession("jane", "jane1")
29    print (sessionID, secureToken)
30
31    print "\nProvide file URIs..."
32    (optionCategories, options, \
33               optionStrings, secureToken)=server.provideFileURIs(sessionID, secureToken, [filename])
34               
35    print (optionCategories, options, optionStrings, secureToken)
36               
37
38    print "\nSelecting variables from files..."       
39    output=server.selectOptions(sessionID, [["secureToken", secureToken], ["fileVariable_1.1", var]])
40    output=deUnicodeObject(output)
41    print output
42
43    print "\nSelecting graphical outputs from options..."
44    output=server.selectOptions(sessionID, [["secureToken", secureToken], ["graphicalOutputType", "%s_1.1" % plotclass]])
45    output=deUnicodeObject(output)
46    print output
47
48    if plotclass=="PointValueAndMetadata":       
49        print "RESULT.........\n\n"
50        output=server.createOutput(sessionID, secureToken)
51        output=deUnicodeObject(output)
52        print output
53        continue
54
55    print "\nSelecting plot options..."
56    output=server.selectOptions(sessionID, [["secureToken",secureToken], ["plotType", plottype], ["fileFormat",format], \
57                                        ["projection", projection], ["imageSize", imagesize], ["continentsSwitch",cont]])
58    output=deUnicodeObject(output)
59    print output
60
61    print "\nCreating output..."
62    output=server.createOutput(sessionID, secureToken)
63    output=deUnicodeObject(output)
64    print output
65
66
67    path=str(output[0]).replace(OUTPUT_DIR_URL_PATH, OUTPUT_DIR_LOCAL_PATH)
68
69    if not os.path.exists(path):
70        raise "No such file: "+path
71    else:
72        newpath=filename+"_"+plottype+"."+path.split(".")[-1]
73        shutil.copy(path, newpath)
74       
75    print "LOOK at my file:", newpath
76    if path.split(".")[-1]=="ps":
77        os.system("gv %s &" % newpath) 
78    else:
79        os.system("konqueror %s &" % newpath)
Note: See TracBrowser for help on using the repository browser.