comparison WebServiceExtensionsV1.1/WebServiceToolWorkflow_REST_SOAP/edit_tool_conf1.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 Opens the toolconf.xml file and then adds the tool that is paased to it under Web Service tools
10 '''
11
12 __author__=""
13
14 class editToolConfig1(object):
15 def addTool(self,toolName):
16 galaxyhome=os.environ.get('GALAXY_HOME')
17 f1=open(galaxyhome+'/tool_conf.xml','r')
18 f1.seek(0,0)
19 f2=open(galaxyhome+'/tool_conf_backup.xml','w')
20 f2.seek(0,0)
21
22 #copy everything from tool_conf.xml upto the section 'Web Service Tools' into another file f2
23 line = f1.readline()
24 f2.write(line)
25
26 lineStripped=line.lstrip()
27 lineStripped=lineStripped.rstrip()
28
29 #add the one-time Web service invocation tool under Web Service Tools section
30 while not lineStripped == '<section name="Select Web Service Tool" id="WebServices">':
31 line = f1.readline()
32 f2.write(line)
33 lineStripped = line.lstrip()
34 lineStripped=lineStripped.rstrip()
35 else:
36 print line
37
38 f2.write(' <tool file="WebServiceToolWorkflow_REST_SOAP/clients/'+toolName + '.xml"/>\n')
39
40 #copy rest of tool_conf.xml file f2
41 while not lineStripped == '</toolbox>':
42 line = f1.readline()
43 f2.write(line)
44 lineStripped = line.lstrip()
45 lineStripped=lineStripped.rstrip()
46 else:
47 print line
48
49 ##close f1 and f2
50 f1.close()
51 f2.close()
52
53 ##interchange modes of f1 and f2
54 f1=open(galaxyhome+'/tool_conf.xml','w')
55 f1.seek(0,0)
56 f2=open(galaxyhome+'/tool_conf_backup.xml','r')
57 f2.seek(0,0)
58
59 line = f2.readline()
60 f1.write(line)
61
62 lineStripped=line.lstrip()
63 lineStripped = lineStripped.rstrip()
64
65 ##write entire f2 into f1 (reverse roles)
66 while not lineStripped == '</toolbox>':
67 line = f2.readline()
68 f1.write(line)
69 lineStripped = line.lstrip()
70 lineStripped = lineStripped.rstrip()
71 else:
72 print line
73
74 f1.close()
75 f2.close()