comparison WebServiceToolWorkflow/edit_tool_conf.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 editToolConfig(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 ##first copy everything upto WebServiceTool1.xml 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 workflow Web service invocation tool under Web Service Workflow Tools section
19 while not lineStripped == '<section name="Web Service Workflow Tools" id="WebServiceWorkflow">':
20 line = f1.readline()
21 f2.write(line)
22 lineStripped = line.lstrip()
23 lineStripped=lineStripped.rstrip()
24 else:
25 print line
26
27 ## add new tool to f2
28 f2.write(' <tool file="WebServiceToolWorkflow/workflowclients/'+toolName + '.xml"/>\n')
29
30 ## copy rest of f1 into f2
31 while not lineStripped == '</toolbox>':
32 line = f1.readline()
33 f2.write(line)
34 lineStripped = line.lstrip()
35 lineStripped=lineStripped.rstrip()
36 else:
37 print line
38
39 ##close f1 and f2
40 f1.close()
41 f2.close()
42
43 ##interchange modes of f1 and f2
44 f1=open(galaxyhome+'/tool_conf.xml','w')
45 f1.seek(0,0)
46 f2=open(galaxyhome+'/tool_conf_backup.xml','r')
47 f2.seek(0,0)
48
49 line = f2.readline()
50 f1.write(line)
51
52 lineStripped=line.lstrip()
53
54 ##write entire f2 into f1 (reverse roles)
55 while not lineStripped == '</toolbox>':
56 line = f2.readline()
57 f1.write(line)
58 lineStripped = line.lstrip()
59 lineStripped=lineStripped.rstrip()
60 else:
61 print line
62
63 f1.close()
64 f2.close()