view WebServiceToolWorkflow/WADLRESTclient2.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
line wrap: on
line source

import warnings
import platform

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    from jpype._jpackage import JPackage
    from jpype import *
    import os.path
    import sys


    
    javahome = os.environ.get('JAVA_HOME')
    galaxyhome=os.environ.get('GALAXY_HOME')
    classpath= galaxyhome + '/tools/restclientWADL/ParserForWADL/bin'
    jarpath = galaxyhome + '/tools/restclientWADL/WADLParser/dist/lib/'
    machine = platform.machine()
    
    if machine == 'x86_64' :
        print 'a'
        startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
    elif machine == 'i686' :
        print 'b'
        startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
    elif machine == 'sun4u' :
        startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
    else :
        print 'c'
        System.exit("Could not identify machine, please specify path to libjvm.so")

   
    
    pkg=JPackage('lsdis')
    urlToPass=java.net.URL(sys.argv[2])
    wadlUrl = sys.argv[2]
    
    outputfileParamNames=open(sys.argv[5],'w')
    outputfileParamNames.seek(0,0)
#    outputfileParamTypes=open(sys.argv[6],'w')
#    outputfileParamTypes.seek(0,0)
   
    webserviceId = sys.argv[3]
    resUrl = sys.argv[4]
    
    urls = []
    methods = []

    WADLParserDriver=pkg.WADLParserDriver
    wPD=WADLParserDriver()
    wPD.parse(urlToPass)
    urls = wPD.getUrl()
    methods = wPD.getCompleteMethodList()

    i=0
    for method in methods:
    	x = str(method.getId())
    	y = str(urls.get(0))
        if x == webserviceId :
            if y == resUrl : 
                for param in method.getRequest().getParams():
                    if param.isRequired():
                        val = 'true'
                    else :
                        val = 'false'
                    outputfileParamNames.write(str(param.getName())+"\t" + str(param.getType())+"\t" + str(param.getDefault1()) + "\t" + val +"\t"+resUrl+"\n")
#                   outputfileParamTypes.write(str(param.getType())+"\n")
                break
        i=i+1