comparison WebServiceToolWorkflow/getMethods.py @ 0:d5cd409b8a18 default tip

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author ganjoo
date Tue, 07 Jun 2011 18:00:50 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d5cd409b8a18
1 import warnings
2
3 with warnings.catch_warnings():
4 warnings.simplefilter("ignore")
5 import platform
6
7 from jpype._jpackage import JPackage
8 from jpype import *
9 import os.path
10 import sys
11
12 class Document(object):
13
14 #invoked to get methods described in a WADL document
15 def getWADLMethods(self, wadlUrl, outputFileUrl ):
16
17 #get environment variables JAVA_HOME and GALAXY_HOME
18 javahome = os.environ.get('JAVA_HOME')
19 galaxyhome=os.environ.get('GALAXY_HOME')
20
21 #classpath, jarpath are variables pointing to the java libraries required to parse a WADL document
22 classpath= galaxyhome + '/tools/WebServiceToolWorkflow/ParserForWADL/bin'
23 jarpath = galaxyhome + '/tools/WebServiceToolWorkflow/ParserForWADL/lib/'
24
25 #start JVM depending on the machine. The location of libjvm.so is assumed to be standard.
26 #you can replace lines 28 to 35, with startJVM("LOCATION OF YOUR LIBJVM.SO","-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
27 machine = platform.machine()
28 if machine == 'x86_64' :
29 startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
30 elif machine == 'i686' :
31 startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
32 elif machine == 'sun4u' :
33 startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
34 else :
35 System.exit("Could not identify machine, please specify path to libjvm.so")
36
37 #tell JPYPE that the package name is lsdis
38 pkg=JPackage('lsdis')
39
40 urlToPass=java.net.URL(wadlUrl)
41
42 #convert __tilda__ to ~
43 if(wadlUrl.find('__tilda__')>-1):
44 ulist = wadlUrl.split('__tilda__')
45 urlToPass = java.net.URL('~'.join(ulist))
46
47
48 outputfile=open(outputFileUrl,'w')
49 outputfile.seek(0,0)
50
51 urls = []
52 methods = []
53
54 #using JPYPE call appropriate Java classes and methods to parse the WADL document and get a list of methods defined in it
55 WADLParserDriver=pkg.WADLParserDriver
56 wPD=WADLParserDriver()
57 wPD.parse(urlToPass)
58 urls = wPD.getUrl()
59 methods = wPD.getCompleteMethodList()
60
61 #write the url of the WADL and the list of methods to the output in a tabular format, for the Step 2 tool to read from.
62 i=0
63 for url in urls:
64 outputfile.write(wadlUrl+"\t")
65 outputfile.write(str(methods[i].getId())+"\t")
66 outputfile.write(str(url)+"\n")
67 i=i+1
68
69
70
71 #invoked to get REST methods described in a WSDL 2.0 document. Steps are similar to getWADLMethods except the library to parse WSDL 2.0 is used.
72 def getWSDLMethods(self, wsdlUrl, outputFileUrl ):
73 javahome = os.environ.get('JAVA_HOME')
74 galaxyhome=os.environ.get('GALAXY_HOME')
75 classpath= galaxyhome + '/tools/restClientWSDL/WodenWSDLParser/bin'
76 jarpath = galaxyhome + '/tools/restClientWSDL/WodenWSDLParser/lib/'
77 machine = platform.machine()
78
79 #start JVM depending on the machine. The location of libjvm.so is assumed to be standard.
80 #you can replace lines 81 to 88, with startJVM("LOCATION OF YOUR LIBJVM.SO","-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
81 if machine == 'x86_64' :
82 startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
83 elif machine == 'i686' :
84 startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
85 elif machine == 'sun4u' :
86 startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
87 else :
88 System.exit("Could not identify machine, please specify path to libjvm.so")
89
90 pkg=JPackage('lsdis')
91
92 outputfile=open(outputFileUrl,'w')
93 outputfile.seek(0,0)
94 length=(len(sys.argv))
95
96 urls = []
97 methods = []
98
99 if(wsdlUrl.find('__tilda__')>-1):
100 ulist = wsdlUrl.split('__tilda__')
101 urlToPass = '~'.join(ulist)
102
103 WSDLParserDriver=pkg.WSDLParserDriver
104 wPD=WSDLParserDriver()
105 wPD.parse(urlToPass)
106 urls = wPD.getUrl()
107 methods = wPD.getCompleteMethodList()
108
109 i=0
110 for url in urls:
111 outputfile.write(wsdlUrl+"\t")
112 outputfile.write(str(methods[i].getName().getLocalPart())+"\t")
113 outputfile.write(str(url)+"\n")
114 i=i+1
115
116
117 # invoked to get methods described in a SAWADL document
118 def getSAWADLMethods(self, sawadlUrl, outputFileUrl ):
119 javahome = os.environ.get('JAVA_HOME')
120 galaxyhome=os.environ.get('GALAXY_HOME')
121 classpath= galaxyhome + '/tools/restclientSAWADL/lib/SAWADLParser/bin'
122 machine = platform.machine()
123
124 #start JVM depending on the machine. The location of libjvm.so is assumed to be standard.
125 #you can replace lines 126 to 133, with startJVM("LOCATION OF YOUR LIBJVM.SO","-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
126 if machine == 'x86_64' :
127 startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath)
128 elif machine == 'i686' :
129 startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath)
130 elif machine == 'sun4u' :
131 startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath)
132 else :
133 System.exit("Could not identify machine, please specify path to libjvm.so")
134
135 pkg=JPackage('edu.uga.cs.lsdis.meteors.wadls')
136
137
138
139 outputfile=open(outputFileUrl,'w')
140 outputfile.seek(0,0)
141
142 if(sawadlUrl.find('__tilda__')>-1):
143 ulist = sawadlUrl.split('__tilda__')
144 urlToPass = '~'.join(ulist)
145
146 urls = []
147 methods = []
148
149
150 SAWADLParserDriver=pkg.SAWADLParserDriver
151 sawPD=SAWADLParserDriver()
152 sawPD.parse(urlToPass)
153 urls = sawPD.getUrl()
154 methods = sawPD.getCompleteMethodList()
155
156 i=0
157 for url in urls:
158 outputfile.write(sawadlUrl+"\t")
159 outputfile.write(str(methods[i].getName())+"\t")
160 outputfile.write(str(url)+"\n")
161 i=i+1
162
163
164
165
166