comparison WebServiceExtensionsV1.1/WebServiceToolWorkflow_REST_SOAP/edit_tool_conf.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 '''
2 @author Chaitanya Guttula, Sumedha Ganjoo
3 @see LICENSE (MIT style license file).
4 '''
5
6 import os
7
8 '''
9 Open the toolconf.xml file and adds the tool under 'Web Service Workflow Tools' that has been passed to it.
10
11 '''
12
13 __author__="Chaitanya Guttula, Sumedha Ganjoo"
14
15 class editToolConfig(object):
16 def addTool(self,toolName):
17 galaxyhome=os.environ.get('GALAXY_HOME')
18 f1=open(galaxyhome+'/tool_conf.xml','r')
19 f1.seek(0,0)
20 f2=open(galaxyhome+'/tool_conf_backup.xml','w')
21 f2.seek(0,0)
22
23 ##first copy everything upto WebServiceTool1.xml into another file f2
24 line = f1.readline()
25 f2.write(line)
26
27 lineStripped=line.lstrip()
28 lineStripped=lineStripped.rstrip()
29
30 #add the workflow Web service invocation tool under Web Service Workflow Tools section
31 while not lineStripped == '<section name="Web Service Workflow Tools" id="WebServiceWorkflow">':
32 line = f1.readline()
33 f2.write(line)
34 lineStripped = line.lstrip()
35 lineStripped=lineStripped.rstrip()
36 else:
37 print line
38
39 ## add new tool to f2
40 f2.write(' <tool file="WebServiceToolWorkflow_REST_SOAP/workflowclients/'+toolName + '.xml"/>\n')
41
42 ## copy rest of f1 into f2
43 while not lineStripped == '</toolbox>':
44 line = f1.readline()
45 f2.write(line)
46 lineStripped = line.lstrip()
47 lineStripped=lineStripped.rstrip()
48 else:
49 print line
50
51 ##close f1 and f2
52 f1.close()
53 f2.close()
54
55 ##interchange modes of f1 and f2
56 f1=open(galaxyhome+'/tool_conf.xml','w')
57 f1.seek(0,0)
58 f2=open(galaxyhome+'/tool_conf_backup.xml','r')
59 f2.seek(0,0)
60
61 line = f2.readline()
62 f1.write(line)
63
64 lineStripped=line.lstrip()
65
66 ##write entire f2 into f1 (reverse roles)
67 while not lineStripped == '</toolbox>':
68 line = f2.readline()
69 f1.write(line)
70 lineStripped = line.lstrip()
71 lineStripped=lineStripped.rstrip()
72 else:
73 print line
74
75 f1.close()
76 f2.close()