comparison WebServiceToolWorkflow/workflowclients/client_1.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 os
2 import sys
3 import urllib
4 '''This script is the client for invoking RESTful Web services.'''
5
6 outputFile = open(sys.argv[1],'w')
7 resUrl = sys.argv[2]
8
9 if(resUrl.find('__tilda__')>-1):
10 ulist = resUrl.split('__tilda__')
11 resUrl = '~'.join(ulist)
12
13 paramdict={}
14 length=(len(sys.argv))
15
16 i=3
17 while( i>=3 and i<(length-1)):
18 key=sys.argv[i]
19 val=sys.argv[i+1]
20 if val=='fileInput':
21 print '##########fileInput found#############'
22 f=open(sys.argv[i+2])
23 line = f.readline().strip('\n')
24 line = line.strip(' ')
25 val = line
26 i=i+1
27
28 while(val.find('**')>-1):
29 vlist = val.split('**')
30 val = ' '.join(vlist)
31 print key + '\t' + val
32 paramdict[key]=val
33 i=i+2
34
35 params = urllib.urlencode(paramdict)
36 data = urllib.urlopen(resUrl, params).read()
37 outputFile.write(data)
38 outputFile.close()