Mercurial > repos > uga-galaxy-group > webservice_toolsuite_v1_1
comparison WebServiceExtensionsV1.1/WebServiceToolWorkflow_REST_SOAP/workflowclients/client_2.py~ @ 0:049760c677de default tip
Galaxy WSExtensions added successfully
author | uga-galaxy-group |
---|---|
date | Tue, 05 Jul 2011 19:34:18 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:049760c677de |
---|---|
1 # To change this template, choose Tools | Templates | |
2 # and open the template in the editor. | |
3 import warnings | |
4 with warnings.catch_warnings(): | |
5 warnings.simplefilter("ignore") | |
6 | |
7 import sys | |
8 import os | |
9 import time | |
10 galaxyhome=os.environ.get('GALAXY_HOME') | |
11 sys.path.append(galaxyhome+'/tools/WebServiceToolWorkflow_REST_SOAP/clientGenerator/') | |
12 from creatorEngineComplex import * | |
13 from wsdl2path import * | |
14 from paramConverter import * | |
15 from ZSI.writer import SoapWriter | |
16 from collections import deque | |
17 | |
18 __author__="Shefali Shastri" | |
19 | |
20 def main(): | |
21 """ | |
22 | |
23 This script takes the values of the input parameters of the | |
24 web service from the user and invokes the web service. | |
25 The URL to the WSDL is the command line argument | |
26 | |
27 """ | |
28 with warnings.catch_warnings(): | |
29 warnings.simplefilter("ignore") | |
30 | |
31 #galaxyhome=os.environ.get('GALAXY_HOME') | |
32 #sys.path.append(galaxyhome+'/tools/SOAPclient/clients/clientGenerator/') | |
33 os.chdir(galaxyhome+'/tools/WebServiceToolWorkflow_REST_SOAP/clientGenerator/') | |
34 webservice = str(sys.argv[5]) | |
35 #print 'WS ', webservice | |
36 operation = str(sys.argv[6]) | |
37 #print 'OP ',operation | |
38 resultfile=open(sys.argv[1],'w') | |
39 length=len(sys.argv) | |
40 inputdict={} | |
41 i=7 | |
42 test=ClientCreator() | |
43 while(i>=7 and i<(length-1)): | |
44 key=sys.argv[i] | |
45 print 'key is : ',key | |
46 #if(sys.argv[i+1]=='ZSI.TC.String'): | |
47 val=sys.argv[i+1] | |
48 while(val.find('__at__')>-1): | |
49 vlist = val.split('__at__') | |
50 val = '@'.join(vlist) | |
51 while(val.find('__sq__')>-1): | |
52 vlist = val.split('__sq__') | |
53 val = ''.join(vlist) | |
54 while(val.find('__gt__')>-1): | |
55 vlist = val.split('__gt__') | |
56 val = '>'.join(vlist) | |
57 while(val.find('***')>-1): | |
58 vlist = val.split('***') | |
59 val = '\n'.join(vlist) | |
60 while(val.find('**')>-1): | |
61 vlist = val.split('**') | |
62 val = ' '.join(vlist) | |
63 while(val.find('__ob__')>-1): | |
64 vlist = val.split('__ob__') | |
65 val = '['.join(vlist) | |
66 while(val.find('__cb__')>-1): | |
67 vlist = val.split('__cb__') | |
68 val = ']'.join(vlist) | |
69 | |
70 print 'value is : ',val | |
71 | |
72 #if(val.find('__sq__')>-1): | |
73 # j=i+4 | |
74 # val=val.lstrip('__sq__') | |
75 # while(str(sys.argv[j]).find('__sq__')==-1): | |
76 # val=val+' '+sys.argv[j] | |
77 # j=j+1 | |
78 #val=val+' '+(str(sys.argv[j]).rstrip('__sq__')) | |
79 #i=j-3 | |
80 | |
81 #elif((sys.argv[i+1]=='ZSI.TC.Integer')or (sys.argv[i+1]=='ZSI.TCnumbers.Iint')): | |
82 # val=int(sys.argv[i+1]) | |
83 #elif(sys.argv[i+1]=='ZSI.TC.Decimal'): | |
84 # val=float(sys.argv[i+1]) | |
85 #elif(sys.argv[i+2]=='Yes'): | |
86 # valFile=open(sys.argv[i+3],'r') | |
87 # val=valFile.read() | |
88 #else: | |
89 # val=sys.argv[i+1] | |
90 if val == 'fileInput': | |
91 f = open(sys.argv[i+2]) | |
92 #line = f.readline() | |
93 val = '' | |
94 #for j in line: | |
95 # val = val+j | |
96 #linestripped = line.strip('\n') | |
97 for line in f: | |
98 #line = f.readline().strip('\n') | |
99 #line = line.strip(' ') | |
100 | |
101 val = val+line | |
102 val = val.strip("\n") | |
103 print val | |
104 i = i+1 | |
105 | |
106 if(val != "0"): | |
107 inputdict[key] = val | |
108 #resultfile.write('value is :'+ val+'\n') | |
109 | |
110 i=i+2 | |
111 print inputdict | |
112 if len(inputdict) == 0: | |
113 print 'empty inputs' | |
114 inputdic = {} | |
115 else: | |
116 inputdic = flat2nestedDict(inputdict) | |
117 print 'the inputs are',inputdic | |
118 result = None | |
119 try: | |
120 result = test.invokeOp(operation,webservice,inputdic) | |
121 except: | |
122 pass | |
123 print 'The result before is ',result | |
124 #print ps | |
125 while result == None: | |
126 time.sleep(2) | |
127 print 'in loop' | |
128 result = test.invokeOp(operation,webservice,inputdic) | |
129 | |
130 print 'The result after is',result | |
131 | |
132 # Writing the output to he o/p file when the result is parsed | |
133 for r in result: | |
134 if type(result[r])==list: | |
135 for i in result[r]: | |
136 resultfile.write(str(i)+'\n') | |
137 print str(i) | |
138 else: | |
139 resultfile.write(str(result[r])+'\n') | |
140 | |
141 #Writes the result without parsinf in the XML format it gets. | |
142 #sw = SoapWriter(header=False, envelope=False); | |
143 #res = test.opname2outputClassOb(operation,webservice) | |
144 #res_tc = getattr(res,'typecode') | |
145 #ofwhat = res_tc.ofwhat; | |
146 #for tc in ofwhat : | |
147 # sw.serialize(getattr(result, tc.aname), tc); | |
148 # doc = sw.dom.getDocument(); | |
149 # fp = open(sys.argv[1], 'w'); | |
150 # try : | |
151 # doc.writexml(fp, '\t', '', '\n'); | |
152 # finally : | |
153 # fp.close(); | |
154 | |
155 | |
156 | |
157 | |
158 if __name__ == "__main__": | |
159 main(); | |
160 |