comparison WebServiceToolWorkflow/edit_tool_conf1.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
3 class editToolConfig1(object):
4 def addTool(self,toolName):
5 galaxyhome=os.environ.get('GALAXY_HOME')
6 f1=open(galaxyhome+'/tool_conf.xml','r')
7 f1.seek(0,0)
8 f2=open(galaxyhome+'/tool_conf_backup.xml','w')
9 f2.seek(0,0)
10
11 #copy everything from tool_conf.xml upto the section 'Web Service Tools' into another file f2
12 line = f1.readline()
13 f2.write(line)
14
15 lineStripped=line.lstrip()
16 lineStripped=lineStripped.rstrip()
17
18 #add the one-time Web service invocation tool under Web Service Tools section
19 while not lineStripped == '<section name="Web Service Tools" id="WebServices">':
20 line = f1.readline()
21 f2.write(line)
22 lineStripped = line.lstrip()
23 lineStripped=lineStripped.rstrip()
24 else:
25 print line
26
27 f2.write(' <tool file="WebServiceToolWorkflow/clients/'+toolName + '.xml"/>\n')
28
29 #copy rest of tool_conf.xml file f2
30 while not lineStripped == '</toolbox>':
31 line = f1.readline()
32 f2.write(line)
33 lineStripped = line.lstrip()
34 lineStripped=lineStripped.rstrip()
35 else:
36 print line
37
38 ##close f1 and f2
39 f1.close()
40 f2.close()
41
42 ##interchange modes of f1 and f2
43 f1=open(galaxyhome+'/tool_conf.xml','w')
44 f1.seek(0,0)
45 f2=open(galaxyhome+'/tool_conf_backup.xml','r')
46 f2.seek(0,0)
47
48 line = f2.readline()
49 f1.write(line)
50
51 lineStripped=line.lstrip()
52
53 ##write entire f2 into f1 (reverse roles)
54 while not lineStripped == '</toolbox>\n':
55 line = f2.readline()
56 f1.write(line)
57 lineStripped = line.lstrip()
58 else:
59 print line
60
61 f1.close()
62 f2.close()