annotate toolfactory/ToolFactory.py @ 6:efefe43f23c8 draft default tip

Uploaded
author fubar
date Fri, 30 Apr 2021 02:10:32 +0000
parents e2c8c2fa192d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
1
2a46da701dde Uploaded
fubar
parents:
diff changeset
2 # see https://github.com/fubar2/toolfactory
2a46da701dde Uploaded
fubar
parents:
diff changeset
3 #
2a46da701dde Uploaded
fubar
parents:
diff changeset
4 # copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012
2a46da701dde Uploaded
fubar
parents:
diff changeset
5 #
2a46da701dde Uploaded
fubar
parents:
diff changeset
6 # all rights reserved
2a46da701dde Uploaded
fubar
parents:
diff changeset
7 # Licensed under the LGPL
2a46da701dde Uploaded
fubar
parents:
diff changeset
8 # suggestions for improvement and bug fixes welcome at
2a46da701dde Uploaded
fubar
parents:
diff changeset
9 # https://github.com/fubar2/toolfactory
2a46da701dde Uploaded
fubar
parents:
diff changeset
10 #
2a46da701dde Uploaded
fubar
parents:
diff changeset
11 # April 2021: Refactored into two tools - generate and test/install
2a46da701dde Uploaded
fubar
parents:
diff changeset
12 # as part of GTN tutorial development and biocontainer adoption
2a46da701dde Uploaded
fubar
parents:
diff changeset
13 # The tester runs planemo on a non-tested archive, creates the test outputs
2a46da701dde Uploaded
fubar
parents:
diff changeset
14 # and returns a new proper tool with test.
2a46da701dde Uploaded
fubar
parents:
diff changeset
15 # The tester was generated from the ToolFactory_tester.py script
2a46da701dde Uploaded
fubar
parents:
diff changeset
16
2a46da701dde Uploaded
fubar
parents:
diff changeset
17
2a46da701dde Uploaded
fubar
parents:
diff changeset
18 import argparse
2a46da701dde Uploaded
fubar
parents:
diff changeset
19 import copy
2a46da701dde Uploaded
fubar
parents:
diff changeset
20 import json
2a46da701dde Uploaded
fubar
parents:
diff changeset
21 import logging
2a46da701dde Uploaded
fubar
parents:
diff changeset
22 import os
2a46da701dde Uploaded
fubar
parents:
diff changeset
23 import re
2a46da701dde Uploaded
fubar
parents:
diff changeset
24 import shlex
2a46da701dde Uploaded
fubar
parents:
diff changeset
25 import shutil
2a46da701dde Uploaded
fubar
parents:
diff changeset
26 import subprocess
2a46da701dde Uploaded
fubar
parents:
diff changeset
27 import sys
2a46da701dde Uploaded
fubar
parents:
diff changeset
28 import tarfile
2a46da701dde Uploaded
fubar
parents:
diff changeset
29 import tempfile
2a46da701dde Uploaded
fubar
parents:
diff changeset
30 import time
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
31 import urllib
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
32
2a46da701dde Uploaded
fubar
parents:
diff changeset
33 from bioblend import ConnectionError
2a46da701dde Uploaded
fubar
parents:
diff changeset
34 from bioblend import galaxy
2a46da701dde Uploaded
fubar
parents:
diff changeset
35 from bioblend import toolshed
2a46da701dde Uploaded
fubar
parents:
diff changeset
36
2a46da701dde Uploaded
fubar
parents:
diff changeset
37 import galaxyxml.tool as gxt
2a46da701dde Uploaded
fubar
parents:
diff changeset
38 import galaxyxml.tool.parameters as gxtp
2a46da701dde Uploaded
fubar
parents:
diff changeset
39
2a46da701dde Uploaded
fubar
parents:
diff changeset
40 import lxml.etree as ET
2a46da701dde Uploaded
fubar
parents:
diff changeset
41
2a46da701dde Uploaded
fubar
parents:
diff changeset
42 import yaml
2a46da701dde Uploaded
fubar
parents:
diff changeset
43
2a46da701dde Uploaded
fubar
parents:
diff changeset
44 myversion = "V2.3 April 2021"
2a46da701dde Uploaded
fubar
parents:
diff changeset
45 verbose = True
2a46da701dde Uploaded
fubar
parents:
diff changeset
46 debug = True
2a46da701dde Uploaded
fubar
parents:
diff changeset
47 toolFactoryURL = "https://github.com/fubar2/toolfactory"
2a46da701dde Uploaded
fubar
parents:
diff changeset
48 FAKEEXE = "~~~REMOVE~~~ME~~~"
2a46da701dde Uploaded
fubar
parents:
diff changeset
49 # need this until a PR/version bump to fix galaxyxml prepending the exe even
2a46da701dde Uploaded
fubar
parents:
diff changeset
50 # with override.
2a46da701dde Uploaded
fubar
parents:
diff changeset
51
2a46da701dde Uploaded
fubar
parents:
diff changeset
52
2a46da701dde Uploaded
fubar
parents:
diff changeset
53 def timenow():
2a46da701dde Uploaded
fubar
parents:
diff changeset
54 """return current time as a string"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
55 return time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(time.time()))
2a46da701dde Uploaded
fubar
parents:
diff changeset
56
2a46da701dde Uploaded
fubar
parents:
diff changeset
57 cheetah_escape_table = {"$": "\\$", "#": "\\#"}
2a46da701dde Uploaded
fubar
parents:
diff changeset
58
2a46da701dde Uploaded
fubar
parents:
diff changeset
59 def cheetah_escape(text):
2a46da701dde Uploaded
fubar
parents:
diff changeset
60 """Produce entities within text."""
2a46da701dde Uploaded
fubar
parents:
diff changeset
61 return "".join([cheetah_escape_table.get(c, c) for c in text])
2a46da701dde Uploaded
fubar
parents:
diff changeset
62
2a46da701dde Uploaded
fubar
parents:
diff changeset
63 def parse_citations(citations_text):
2a46da701dde Uploaded
fubar
parents:
diff changeset
64 """"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
65 citations = [c for c in citations_text.split("**ENTRY**") if c.strip()]
2a46da701dde Uploaded
fubar
parents:
diff changeset
66 citation_tuples = []
2a46da701dde Uploaded
fubar
parents:
diff changeset
67 for citation in citations:
2a46da701dde Uploaded
fubar
parents:
diff changeset
68 if citation.startswith("doi"):
2a46da701dde Uploaded
fubar
parents:
diff changeset
69 citation_tuples.append(("doi", citation[len("doi") :].strip()))
2a46da701dde Uploaded
fubar
parents:
diff changeset
70 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
71 citation_tuples.append(("bibtex", citation[len("bibtex") :].strip()))
2a46da701dde Uploaded
fubar
parents:
diff changeset
72 return citation_tuples
2a46da701dde Uploaded
fubar
parents:
diff changeset
73
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
74
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
75 class Tool_Conf_Updater():
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
76 # update config/tool_conf.xml with a new tool unpacked in /tools
2a46da701dde Uploaded
fubar
parents:
diff changeset
77 # requires highly insecure docker settings - like write to tool_conf.xml and to tools !
2a46da701dde Uploaded
fubar
parents:
diff changeset
78 # if in a container possibly not so courageous.
2a46da701dde Uploaded
fubar
parents:
diff changeset
79 # Fine on your own laptop but security red flag for most production instances
2a46da701dde Uploaded
fubar
parents:
diff changeset
80
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
81 def __init__(self, args, tool_conf_path, new_tool_archive_path, new_tool_name, tool_dir):
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
82 self.args = args
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
83 self.tool_conf_path = os.path.join(args.galaxy_root,tool_conf_path)
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
84 self.tool_dir = os.path.join(args.galaxy_root, tool_dir)
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
85 self.our_name = 'ToolFactory'
2a46da701dde Uploaded
fubar
parents:
diff changeset
86 tff = tarfile.open(new_tool_archive_path, "r:*")
2a46da701dde Uploaded
fubar
parents:
diff changeset
87 flist = tff.getnames()
2a46da701dde Uploaded
fubar
parents:
diff changeset
88 ourdir = os.path.commonpath(flist) # eg pyrevpos
2a46da701dde Uploaded
fubar
parents:
diff changeset
89 self.tool_id = ourdir # they are the same for TF tools
2a46da701dde Uploaded
fubar
parents:
diff changeset
90 ourxml = [x for x in flist if x.lower().endswith('.xml')]
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
91 res = tff.extractall()
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
92 tff.close()
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
93 self.run_rsync(ourdir, self.tool_dir)
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
94 self.update_toolconf(ourdir,ourxml)
2a46da701dde Uploaded
fubar
parents:
diff changeset
95
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
96 def run_rsync(self, srcf, dstf):
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
97 src = os.path.abspath(srcf)
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
98 dst = os.path.abspath(dstf)
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
99 if os.path.isdir(src):
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
100 cll = ['rsync', '-vr', src, dst]
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
101 else:
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
102 cll = ['rsync', '-v', src, dst]
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
103 p = subprocess.run(
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
104 cll,
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
105 capture_output=False,
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
106 encoding='utf8',
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
107 shell=False,
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
108 )
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
109
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
110 def install_deps(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
111 gi = galaxy.GalaxyInstance(url=self.args.galaxy_url, key=self.args.galaxy_api_key)
2a46da701dde Uploaded
fubar
parents:
diff changeset
112 x = gi.tools.install_dependencies(self.tool_id)
2a46da701dde Uploaded
fubar
parents:
diff changeset
113 print(f"Called install_dependencies on {self.tool_id} - got {x}")
2a46da701dde Uploaded
fubar
parents:
diff changeset
114
2a46da701dde Uploaded
fubar
parents:
diff changeset
115 def update_toolconf(self,ourdir,ourxml): # path is relative to tools
2a46da701dde Uploaded
fubar
parents:
diff changeset
116 updated = False
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
117 localconf = './local_tool_conf.xml'
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
118 self.run_rsync(self.tool_conf_path,localconf)
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
119 tree = ET.parse(localconf)
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
120 root = tree.getroot()
2a46da701dde Uploaded
fubar
parents:
diff changeset
121 hasTF = False
2a46da701dde Uploaded
fubar
parents:
diff changeset
122 TFsection = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
123 for e in root.findall('section'):
2a46da701dde Uploaded
fubar
parents:
diff changeset
124 if e.attrib['name'] == self.our_name:
2a46da701dde Uploaded
fubar
parents:
diff changeset
125 hasTF = True
2a46da701dde Uploaded
fubar
parents:
diff changeset
126 TFsection = e
2a46da701dde Uploaded
fubar
parents:
diff changeset
127 if not hasTF:
2a46da701dde Uploaded
fubar
parents:
diff changeset
128 TFsection = ET.Element('section')
2a46da701dde Uploaded
fubar
parents:
diff changeset
129 root.insert(0,TFsection) # at the top!
2a46da701dde Uploaded
fubar
parents:
diff changeset
130 our_tools = TFsection.findall('tool')
2a46da701dde Uploaded
fubar
parents:
diff changeset
131 conf_tools = [x.attrib['file'] for x in our_tools]
2a46da701dde Uploaded
fubar
parents:
diff changeset
132 for xml in ourxml: # may be > 1
2a46da701dde Uploaded
fubar
parents:
diff changeset
133 if not xml in conf_tools: # new
2a46da701dde Uploaded
fubar
parents:
diff changeset
134 updated = True
2a46da701dde Uploaded
fubar
parents:
diff changeset
135 ET.SubElement(TFsection, 'tool', {'file':xml})
2a46da701dde Uploaded
fubar
parents:
diff changeset
136 ET.indent(tree)
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
137 newconf = f"{self.tool_id}_conf"
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
138 tree.write(newconf, pretty_print=True)
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
139 self.run_rsync(newconf,self.tool_conf_path)
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
140 if False and self.args.packages and self.args.packages > '':
2a46da701dde Uploaded
fubar
parents:
diff changeset
141 self.install_deps()
2a46da701dde Uploaded
fubar
parents:
diff changeset
142
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
143 class Tool_Factory:
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
144 """Wrapper for an arbitrary script
2a46da701dde Uploaded
fubar
parents:
diff changeset
145 uses galaxyxml
2a46da701dde Uploaded
fubar
parents:
diff changeset
146
2a46da701dde Uploaded
fubar
parents:
diff changeset
147 """
2a46da701dde Uploaded
fubar
parents:
diff changeset
148
2a46da701dde Uploaded
fubar
parents:
diff changeset
149 def __init__(self, args=None): # noqa
2a46da701dde Uploaded
fubar
parents:
diff changeset
150 """
2a46da701dde Uploaded
fubar
parents:
diff changeset
151 prepare command line cl for running the tool here
2a46da701dde Uploaded
fubar
parents:
diff changeset
152 and prepare elements needed for galaxyxml tool generation
2a46da701dde Uploaded
fubar
parents:
diff changeset
153 """
2a46da701dde Uploaded
fubar
parents:
diff changeset
154 self.ourcwd = os.getcwd()
2a46da701dde Uploaded
fubar
parents:
diff changeset
155 self.collections = []
2a46da701dde Uploaded
fubar
parents:
diff changeset
156 if len(args.collection) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
157 try:
2a46da701dde Uploaded
fubar
parents:
diff changeset
158 self.collections = [
2a46da701dde Uploaded
fubar
parents:
diff changeset
159 json.loads(x) for x in args.collection if len(x.strip()) > 1
2a46da701dde Uploaded
fubar
parents:
diff changeset
160 ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
161 except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
162 print(
2a46da701dde Uploaded
fubar
parents:
diff changeset
163 f"--collections parameter {str(args.collection)} is malformed - should be a dictionary"
2a46da701dde Uploaded
fubar
parents:
diff changeset
164 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
165 try:
2a46da701dde Uploaded
fubar
parents:
diff changeset
166 self.infiles = [
2a46da701dde Uploaded
fubar
parents:
diff changeset
167 json.loads(x) for x in args.input_files if len(x.strip()) > 1
2a46da701dde Uploaded
fubar
parents:
diff changeset
168 ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
169 except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
170 print(
2a46da701dde Uploaded
fubar
parents:
diff changeset
171 f"--input_files parameter {str(args.input_files)} is malformed - should be a dictionary"
2a46da701dde Uploaded
fubar
parents:
diff changeset
172 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
173 try:
2a46da701dde Uploaded
fubar
parents:
diff changeset
174 self.outfiles = [
2a46da701dde Uploaded
fubar
parents:
diff changeset
175 json.loads(x) for x in args.output_files if len(x.strip()) > 1
2a46da701dde Uploaded
fubar
parents:
diff changeset
176 ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
177 except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
178 print(
2a46da701dde Uploaded
fubar
parents:
diff changeset
179 f"--output_files parameter {args.output_files} is malformed - should be a dictionary"
2a46da701dde Uploaded
fubar
parents:
diff changeset
180 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
181 try:
2a46da701dde Uploaded
fubar
parents:
diff changeset
182 self.addpar = [
2a46da701dde Uploaded
fubar
parents:
diff changeset
183 json.loads(x) for x in args.additional_parameters if len(x.strip()) > 1
2a46da701dde Uploaded
fubar
parents:
diff changeset
184 ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
185 except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
186 print(
2a46da701dde Uploaded
fubar
parents:
diff changeset
187 f"--additional_parameters {args.additional_parameters} is malformed - should be a dictionary"
2a46da701dde Uploaded
fubar
parents:
diff changeset
188 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
189 try:
2a46da701dde Uploaded
fubar
parents:
diff changeset
190 self.selpar = [
2a46da701dde Uploaded
fubar
parents:
diff changeset
191 json.loads(x) for x in args.selecttext_parameters if len(x.strip()) > 1
2a46da701dde Uploaded
fubar
parents:
diff changeset
192 ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
193 except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
194 print(
2a46da701dde Uploaded
fubar
parents:
diff changeset
195 f"--selecttext_parameters {args.selecttext_parameters} is malformed - should be a dictionary"
2a46da701dde Uploaded
fubar
parents:
diff changeset
196 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
197 self.args = args
2a46da701dde Uploaded
fubar
parents:
diff changeset
198 self.cleanuppar()
2a46da701dde Uploaded
fubar
parents:
diff changeset
199 self.lastxclredirect = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
200 self.xmlcl = []
2a46da701dde Uploaded
fubar
parents:
diff changeset
201 self.is_positional = self.args.parampass == "positional"
2a46da701dde Uploaded
fubar
parents:
diff changeset
202 if self.args.sysexe:
2a46da701dde Uploaded
fubar
parents:
diff changeset
203 if ' ' in self.args.sysexe:
2a46da701dde Uploaded
fubar
parents:
diff changeset
204 self.executeme = self.args.sysexe.split(' ')
2a46da701dde Uploaded
fubar
parents:
diff changeset
205 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
206 self.executeme = [self.args.sysexe, ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
207 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
208 if self.args.packages:
2a46da701dde Uploaded
fubar
parents:
diff changeset
209 self.executeme = [self.args.packages.split(",")[0].split(":")[0].strip(), ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
210 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
211 self.executeme = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
212 aXCL = self.xmlcl.append
2a46da701dde Uploaded
fubar
parents:
diff changeset
213 assert args.parampass in [
2a46da701dde Uploaded
fubar
parents:
diff changeset
214 "0",
2a46da701dde Uploaded
fubar
parents:
diff changeset
215 "argparse",
2a46da701dde Uploaded
fubar
parents:
diff changeset
216 "positional",
2a46da701dde Uploaded
fubar
parents:
diff changeset
217 ], 'args.parampass must be "0","positional" or "argparse"'
2a46da701dde Uploaded
fubar
parents:
diff changeset
218 self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name)
2a46da701dde Uploaded
fubar
parents:
diff changeset
219 self.tool_id = self.tool_name
2a46da701dde Uploaded
fubar
parents:
diff changeset
220 self.newtool = gxt.Tool(
2a46da701dde Uploaded
fubar
parents:
diff changeset
221 self.tool_name,
2a46da701dde Uploaded
fubar
parents:
diff changeset
222 self.tool_id,
2a46da701dde Uploaded
fubar
parents:
diff changeset
223 self.args.tool_version,
2a46da701dde Uploaded
fubar
parents:
diff changeset
224 self.args.tool_desc,
2a46da701dde Uploaded
fubar
parents:
diff changeset
225 FAKEEXE,
2a46da701dde Uploaded
fubar
parents:
diff changeset
226 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
227 self.newtarpath = "%s_toolshed.gz" % self.tool_name
2a46da701dde Uploaded
fubar
parents:
diff changeset
228 self.tooloutdir = "./tfout"
2a46da701dde Uploaded
fubar
parents:
diff changeset
229 self.repdir = "./TF_run_report"
2a46da701dde Uploaded
fubar
parents:
diff changeset
230 self.testdir = os.path.join(self.tooloutdir, "test-data")
2a46da701dde Uploaded
fubar
parents:
diff changeset
231 if not os.path.exists(self.tooloutdir):
2a46da701dde Uploaded
fubar
parents:
diff changeset
232 os.mkdir(self.tooloutdir)
2a46da701dde Uploaded
fubar
parents:
diff changeset
233 if not os.path.exists(self.testdir):
2a46da701dde Uploaded
fubar
parents:
diff changeset
234 os.mkdir(self.testdir)
2a46da701dde Uploaded
fubar
parents:
diff changeset
235 if not os.path.exists(self.repdir):
2a46da701dde Uploaded
fubar
parents:
diff changeset
236 os.mkdir(self.repdir)
2a46da701dde Uploaded
fubar
parents:
diff changeset
237 self.tinputs = gxtp.Inputs()
2a46da701dde Uploaded
fubar
parents:
diff changeset
238 self.toutputs = gxtp.Outputs()
2a46da701dde Uploaded
fubar
parents:
diff changeset
239 self.testparam = []
2a46da701dde Uploaded
fubar
parents:
diff changeset
240 if self.args.script_path:
2a46da701dde Uploaded
fubar
parents:
diff changeset
241 self.prepScript()
2a46da701dde Uploaded
fubar
parents:
diff changeset
242 if self.args.command_override:
2a46da701dde Uploaded
fubar
parents:
diff changeset
243 scos = open(self.args.command_override, "r").readlines()
2a46da701dde Uploaded
fubar
parents:
diff changeset
244 self.command_override = [x.rstrip() for x in scos]
2a46da701dde Uploaded
fubar
parents:
diff changeset
245 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
246 self.command_override = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
247 if self.args.test_override:
2a46da701dde Uploaded
fubar
parents:
diff changeset
248 stos = open(self.args.test_override, "r").readlines()
2a46da701dde Uploaded
fubar
parents:
diff changeset
249 self.test_override = [x.rstrip() for x in stos]
2a46da701dde Uploaded
fubar
parents:
diff changeset
250 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
251 self.test_override = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
252 if self.args.script_path:
2a46da701dde Uploaded
fubar
parents:
diff changeset
253 for ex in self.executeme:
2a46da701dde Uploaded
fubar
parents:
diff changeset
254 aXCL(ex)
2a46da701dde Uploaded
fubar
parents:
diff changeset
255 aXCL("$runme")
2a46da701dde Uploaded
fubar
parents:
diff changeset
256 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
257 for ex in self.executeme:
2a46da701dde Uploaded
fubar
parents:
diff changeset
258 aXCL(ex)
2a46da701dde Uploaded
fubar
parents:
diff changeset
259
2a46da701dde Uploaded
fubar
parents:
diff changeset
260 if self.args.parampass == "0":
2a46da701dde Uploaded
fubar
parents:
diff changeset
261 self.clsimple()
2a46da701dde Uploaded
fubar
parents:
diff changeset
262 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
263 if self.args.parampass == "positional":
2a46da701dde Uploaded
fubar
parents:
diff changeset
264 self.prepclpos()
2a46da701dde Uploaded
fubar
parents:
diff changeset
265 self.clpositional()
2a46da701dde Uploaded
fubar
parents:
diff changeset
266 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
267 self.prepargp()
2a46da701dde Uploaded
fubar
parents:
diff changeset
268 self.clargparse()
2a46da701dde Uploaded
fubar
parents:
diff changeset
269
2a46da701dde Uploaded
fubar
parents:
diff changeset
270 def clsimple(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
271 """no parameters or repeats - uses < and > for i/o"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
272 aXCL = self.xmlcl.append
2a46da701dde Uploaded
fubar
parents:
diff changeset
273 if len(self.infiles) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
274 aXCL("<")
2a46da701dde Uploaded
fubar
parents:
diff changeset
275 aXCL("$%s" % self.infiles[0]["infilename"])
2a46da701dde Uploaded
fubar
parents:
diff changeset
276 if len(self.outfiles) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
277 aXCL(">")
2a46da701dde Uploaded
fubar
parents:
diff changeset
278 aXCL("$%s" % self.outfiles[0]["name"])
2a46da701dde Uploaded
fubar
parents:
diff changeset
279 if self.args.cl_user_suffix: # DIY CL end
2a46da701dde Uploaded
fubar
parents:
diff changeset
280 clp = shlex.split(self.args.cl_user_suffix)
2a46da701dde Uploaded
fubar
parents:
diff changeset
281 for c in clp:
2a46da701dde Uploaded
fubar
parents:
diff changeset
282 aXCL(c)
2a46da701dde Uploaded
fubar
parents:
diff changeset
283
2a46da701dde Uploaded
fubar
parents:
diff changeset
284 def prepargp(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
285 xclsuffix = []
2a46da701dde Uploaded
fubar
parents:
diff changeset
286 for i, p in enumerate(self.infiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
287 nam = p["infilename"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
288 if p["origCL"].strip().upper() == "STDIN":
2a46da701dde Uploaded
fubar
parents:
diff changeset
289 xappendme = [
2a46da701dde Uploaded
fubar
parents:
diff changeset
290 nam,
2a46da701dde Uploaded
fubar
parents:
diff changeset
291 nam,
2a46da701dde Uploaded
fubar
parents:
diff changeset
292 "< $%s" % nam,
2a46da701dde Uploaded
fubar
parents:
diff changeset
293 ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
294 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
295 rep = p["repeat"] == "1"
2a46da701dde Uploaded
fubar
parents:
diff changeset
296 over = ""
2a46da701dde Uploaded
fubar
parents:
diff changeset
297 if rep:
2a46da701dde Uploaded
fubar
parents:
diff changeset
298 over = f'#for $rep in $R_{nam}:\n--{nam} "$rep.{nam}"\n#end for'
2a46da701dde Uploaded
fubar
parents:
diff changeset
299 xappendme = [p["CL"], "$%s" % p["CL"], over]
2a46da701dde Uploaded
fubar
parents:
diff changeset
300 xclsuffix.append(xappendme)
2a46da701dde Uploaded
fubar
parents:
diff changeset
301 for i, p in enumerate(self.outfiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
302 if p["origCL"].strip().upper() == "STDOUT":
2a46da701dde Uploaded
fubar
parents:
diff changeset
303 self.lastxclredirect = [">", "$%s" % p["name"]]
2a46da701dde Uploaded
fubar
parents:
diff changeset
304 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
305 xclsuffix.append([p["name"], "$%s" % p["name"], ""])
2a46da701dde Uploaded
fubar
parents:
diff changeset
306 for p in self.addpar:
2a46da701dde Uploaded
fubar
parents:
diff changeset
307 nam = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
308 rep = p["repeat"] == "1"
2a46da701dde Uploaded
fubar
parents:
diff changeset
309 if rep:
2a46da701dde Uploaded
fubar
parents:
diff changeset
310 over = f'#for $rep in $R_{nam}:\n--{nam} "$rep.{nam}"\n#end for'
2a46da701dde Uploaded
fubar
parents:
diff changeset
311 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
312 over = p["override"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
313 xclsuffix.append([p["CL"], '"$%s"' % nam, over])
2a46da701dde Uploaded
fubar
parents:
diff changeset
314 for p in self.selpar:
2a46da701dde Uploaded
fubar
parents:
diff changeset
315 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
2a46da701dde Uploaded
fubar
parents:
diff changeset
316 self.xclsuffix = xclsuffix
2a46da701dde Uploaded
fubar
parents:
diff changeset
317
2a46da701dde Uploaded
fubar
parents:
diff changeset
318 def prepclpos(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
319 xclsuffix = []
2a46da701dde Uploaded
fubar
parents:
diff changeset
320 for i, p in enumerate(self.infiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
321 if p["origCL"].strip().upper() == "STDIN":
2a46da701dde Uploaded
fubar
parents:
diff changeset
322 xappendme = [
2a46da701dde Uploaded
fubar
parents:
diff changeset
323 "999",
2a46da701dde Uploaded
fubar
parents:
diff changeset
324 p["infilename"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
325 "< $%s" % p["infilename"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
326 ]
2a46da701dde Uploaded
fubar
parents:
diff changeset
327 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
328 xappendme = [p["CL"], "$%s" % p["infilename"], ""]
2a46da701dde Uploaded
fubar
parents:
diff changeset
329 xclsuffix.append(xappendme)
2a46da701dde Uploaded
fubar
parents:
diff changeset
330 for i, p in enumerate(self.outfiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
331 if p["origCL"].strip().upper() == "STDOUT":
2a46da701dde Uploaded
fubar
parents:
diff changeset
332 self.lastxclredirect = [">", "$%s" % p["name"]]
2a46da701dde Uploaded
fubar
parents:
diff changeset
333 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
334 xclsuffix.append([p["CL"], "$%s" % p["name"], ""])
2a46da701dde Uploaded
fubar
parents:
diff changeset
335 for p in self.addpar:
2a46da701dde Uploaded
fubar
parents:
diff changeset
336 nam = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
337 rep = p["repeat"] == "1" # repeats make NO sense
2a46da701dde Uploaded
fubar
parents:
diff changeset
338 if rep:
2a46da701dde Uploaded
fubar
parents:
diff changeset
339 print(f'### warning. Repeats for {nam} ignored - not permitted in positional parameter command lines!')
2a46da701dde Uploaded
fubar
parents:
diff changeset
340 over = p["override"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
341 xclsuffix.append([p["CL"], '"$%s"' % nam, over])
2a46da701dde Uploaded
fubar
parents:
diff changeset
342 for p in self.selpar:
2a46da701dde Uploaded
fubar
parents:
diff changeset
343 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
2a46da701dde Uploaded
fubar
parents:
diff changeset
344 xclsuffix.sort()
2a46da701dde Uploaded
fubar
parents:
diff changeset
345 self.xclsuffix = xclsuffix
2a46da701dde Uploaded
fubar
parents:
diff changeset
346
2a46da701dde Uploaded
fubar
parents:
diff changeset
347 def prepScript(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
348 rx = open(self.args.script_path, "r").readlines()
2a46da701dde Uploaded
fubar
parents:
diff changeset
349 rx = [x.rstrip() for x in rx]
2a46da701dde Uploaded
fubar
parents:
diff changeset
350 rxcheck = [x.strip() for x in rx if x.strip() > ""]
2a46da701dde Uploaded
fubar
parents:
diff changeset
351 assert len(rxcheck) > 0, "Supplied script is empty. Cannot run"
2a46da701dde Uploaded
fubar
parents:
diff changeset
352 self.script = "\n".join(rx)
2a46da701dde Uploaded
fubar
parents:
diff changeset
353 fhandle, self.sfile = tempfile.mkstemp(
2a46da701dde Uploaded
fubar
parents:
diff changeset
354 prefix=self.tool_name, suffix="_%s" % (self.executeme[0])
2a46da701dde Uploaded
fubar
parents:
diff changeset
355 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
356 tscript = open(self.sfile, "w")
2a46da701dde Uploaded
fubar
parents:
diff changeset
357 tscript.write(self.script)
2a46da701dde Uploaded
fubar
parents:
diff changeset
358 tscript.close()
2a46da701dde Uploaded
fubar
parents:
diff changeset
359 self.spacedScript = [f" {x}" for x in rx if x.strip() > ""]
2a46da701dde Uploaded
fubar
parents:
diff changeset
360 rx.insert(0,'#raw')
2a46da701dde Uploaded
fubar
parents:
diff changeset
361 rx.append('#end raw')
2a46da701dde Uploaded
fubar
parents:
diff changeset
362 self.escapedScript = rx
2a46da701dde Uploaded
fubar
parents:
diff changeset
363 art = "%s.%s" % (self.tool_name, self.executeme[0])
2a46da701dde Uploaded
fubar
parents:
diff changeset
364 artifact = open(art, "wb")
2a46da701dde Uploaded
fubar
parents:
diff changeset
365 artifact.write(bytes(self.script, "utf8"))
2a46da701dde Uploaded
fubar
parents:
diff changeset
366 artifact.close()
2a46da701dde Uploaded
fubar
parents:
diff changeset
367
2a46da701dde Uploaded
fubar
parents:
diff changeset
368 def cleanuppar(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
369 """ positional parameters are complicated by their numeric ordinal"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
370 if self.args.parampass == "positional":
2a46da701dde Uploaded
fubar
parents:
diff changeset
371 for i, p in enumerate(self.infiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
372 assert (
2a46da701dde Uploaded
fubar
parents:
diff changeset
373 p["CL"].isdigit() or p["CL"].strip().upper() == "STDIN"
2a46da701dde Uploaded
fubar
parents:
diff changeset
374 ), "Positional parameters must be ordinal integers - got %s for %s" % (
2a46da701dde Uploaded
fubar
parents:
diff changeset
375 p["CL"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
376 p["label"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
377 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
378 for i, p in enumerate(self.outfiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
379 assert (
2a46da701dde Uploaded
fubar
parents:
diff changeset
380 p["CL"].isdigit() or p["CL"].strip().upper() == "STDOUT"
2a46da701dde Uploaded
fubar
parents:
diff changeset
381 ), "Positional parameters must be ordinal integers - got %s for %s" % (
2a46da701dde Uploaded
fubar
parents:
diff changeset
382 p["CL"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
383 p["name"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
384 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
385 for i, p in enumerate(self.addpar):
2a46da701dde Uploaded
fubar
parents:
diff changeset
386 assert p[
2a46da701dde Uploaded
fubar
parents:
diff changeset
387 "CL"
2a46da701dde Uploaded
fubar
parents:
diff changeset
388 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % (
2a46da701dde Uploaded
fubar
parents:
diff changeset
389 p["CL"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
390 p["name"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
391 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
392 for i, p in enumerate(self.infiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
393 infp = copy.copy(p)
2a46da701dde Uploaded
fubar
parents:
diff changeset
394 infp["origCL"] = infp["CL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
395 if self.args.parampass in ["positional", "0"]:
2a46da701dde Uploaded
fubar
parents:
diff changeset
396 infp["infilename"] = infp["label"].replace(" ", "_")
2a46da701dde Uploaded
fubar
parents:
diff changeset
397 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
398 infp["infilename"] = infp["CL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
399 self.infiles[i] = infp
2a46da701dde Uploaded
fubar
parents:
diff changeset
400 for i, p in enumerate(self.outfiles):
2a46da701dde Uploaded
fubar
parents:
diff changeset
401 p["origCL"] = p["CL"] # keep copy
2a46da701dde Uploaded
fubar
parents:
diff changeset
402 self.outfiles[i] = p
2a46da701dde Uploaded
fubar
parents:
diff changeset
403 for i, p in enumerate(self.addpar):
2a46da701dde Uploaded
fubar
parents:
diff changeset
404 p["origCL"] = p["CL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
405 self.addpar[i] = p
2a46da701dde Uploaded
fubar
parents:
diff changeset
406
2a46da701dde Uploaded
fubar
parents:
diff changeset
407 def clpositional(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
408 # inputs in order then params
2a46da701dde Uploaded
fubar
parents:
diff changeset
409 aXCL = self.xmlcl.append
2a46da701dde Uploaded
fubar
parents:
diff changeset
410 for (k, v, koverride) in self.xclsuffix:
2a46da701dde Uploaded
fubar
parents:
diff changeset
411 aXCL(v)
2a46da701dde Uploaded
fubar
parents:
diff changeset
412 if self.lastxclredirect:
2a46da701dde Uploaded
fubar
parents:
diff changeset
413 aXCL(self.lastxclredirect[0])
2a46da701dde Uploaded
fubar
parents:
diff changeset
414 aXCL(self.lastxclredirect[1])
2a46da701dde Uploaded
fubar
parents:
diff changeset
415 if self.args.cl_user_suffix: # DIY CL end
2a46da701dde Uploaded
fubar
parents:
diff changeset
416 clp = shlex.split(self.args.cl_user_suffix)
2a46da701dde Uploaded
fubar
parents:
diff changeset
417 for c in clp:
2a46da701dde Uploaded
fubar
parents:
diff changeset
418 aXCL(c)
2a46da701dde Uploaded
fubar
parents:
diff changeset
419
2a46da701dde Uploaded
fubar
parents:
diff changeset
420
2a46da701dde Uploaded
fubar
parents:
diff changeset
421 def clargparse(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
422 """argparse style"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
423 aXCL = self.xmlcl.append
2a46da701dde Uploaded
fubar
parents:
diff changeset
424 # inputs then params in argparse named form
2a46da701dde Uploaded
fubar
parents:
diff changeset
425
2a46da701dde Uploaded
fubar
parents:
diff changeset
426 for (k, v, koverride) in self.xclsuffix:
2a46da701dde Uploaded
fubar
parents:
diff changeset
427 if koverride > "":
2a46da701dde Uploaded
fubar
parents:
diff changeset
428 k = koverride
2a46da701dde Uploaded
fubar
parents:
diff changeset
429 aXCL(k)
2a46da701dde Uploaded
fubar
parents:
diff changeset
430 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
431 if len(k.strip()) == 1:
2a46da701dde Uploaded
fubar
parents:
diff changeset
432 k = "-%s" % k
2a46da701dde Uploaded
fubar
parents:
diff changeset
433 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
434 k = "--%s" % k
2a46da701dde Uploaded
fubar
parents:
diff changeset
435 aXCL(k)
2a46da701dde Uploaded
fubar
parents:
diff changeset
436 aXCL(v)
2a46da701dde Uploaded
fubar
parents:
diff changeset
437 if self.lastxclredirect:
2a46da701dde Uploaded
fubar
parents:
diff changeset
438 aXCL(self.lastxclredirect[0])
2a46da701dde Uploaded
fubar
parents:
diff changeset
439 aXCL(self.lastxclredirect[1])
2a46da701dde Uploaded
fubar
parents:
diff changeset
440 if self.args.cl_user_suffix: # DIY CL end
2a46da701dde Uploaded
fubar
parents:
diff changeset
441 clp = shlex.split(self.args.cl_user_suffix)
2a46da701dde Uploaded
fubar
parents:
diff changeset
442 for c in clp:
2a46da701dde Uploaded
fubar
parents:
diff changeset
443 aXCL(c)
2a46da701dde Uploaded
fubar
parents:
diff changeset
444
2a46da701dde Uploaded
fubar
parents:
diff changeset
445 def getNdash(self, newname):
2a46da701dde Uploaded
fubar
parents:
diff changeset
446 if self.is_positional:
2a46da701dde Uploaded
fubar
parents:
diff changeset
447 ndash = 0
2a46da701dde Uploaded
fubar
parents:
diff changeset
448 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
449 ndash = 2
2a46da701dde Uploaded
fubar
parents:
diff changeset
450 if len(newname) < 2:
2a46da701dde Uploaded
fubar
parents:
diff changeset
451 ndash = 1
2a46da701dde Uploaded
fubar
parents:
diff changeset
452 return ndash
2a46da701dde Uploaded
fubar
parents:
diff changeset
453
2a46da701dde Uploaded
fubar
parents:
diff changeset
454 def doXMLparam(self): # noqa
2a46da701dde Uploaded
fubar
parents:
diff changeset
455 """Add all needed elements to tool"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
456 for p in self.outfiles:
2a46da701dde Uploaded
fubar
parents:
diff changeset
457 newname = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
458 newfmt = p["format"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
459 newcl = p["CL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
460 test = p["test"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
461 oldcl = p["origCL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
462 test = test.strip()
2a46da701dde Uploaded
fubar
parents:
diff changeset
463 ndash = self.getNdash(newcl)
2a46da701dde Uploaded
fubar
parents:
diff changeset
464 aparm = gxtp.OutputData(
2a46da701dde Uploaded
fubar
parents:
diff changeset
465 name=newname, format=newfmt, num_dashes=ndash, label=newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
466 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
467 aparm.positional = self.is_positional
2a46da701dde Uploaded
fubar
parents:
diff changeset
468 if self.is_positional:
2a46da701dde Uploaded
fubar
parents:
diff changeset
469 if oldcl.upper() == "STDOUT":
2a46da701dde Uploaded
fubar
parents:
diff changeset
470 aparm.positional = 9999999
2a46da701dde Uploaded
fubar
parents:
diff changeset
471 aparm.command_line_override = "> $%s" % newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
472 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
473 aparm.positional = int(oldcl)
2a46da701dde Uploaded
fubar
parents:
diff changeset
474 aparm.command_line_override = "$%s" % newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
475 self.toutputs.append(aparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
476 ld = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
477 if test.strip() > "":
2a46da701dde Uploaded
fubar
parents:
diff changeset
478 if test.startswith("diff"):
2a46da701dde Uploaded
fubar
parents:
diff changeset
479 c = "diff"
2a46da701dde Uploaded
fubar
parents:
diff changeset
480 ld = 0
2a46da701dde Uploaded
fubar
parents:
diff changeset
481 if test.split(":")[1].isdigit:
2a46da701dde Uploaded
fubar
parents:
diff changeset
482 ld = int(test.split(":")[1])
2a46da701dde Uploaded
fubar
parents:
diff changeset
483 tp = gxtp.TestOutput(
2a46da701dde Uploaded
fubar
parents:
diff changeset
484 name=newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
485 value="%s_sample" % newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
486 compare=c,
2a46da701dde Uploaded
fubar
parents:
diff changeset
487 lines_diff=ld,
2a46da701dde Uploaded
fubar
parents:
diff changeset
488 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
489 elif test.startswith("sim_size"):
2a46da701dde Uploaded
fubar
parents:
diff changeset
490 c = "sim_size"
2a46da701dde Uploaded
fubar
parents:
diff changeset
491 tn = test.split(":")[1].strip()
2a46da701dde Uploaded
fubar
parents:
diff changeset
492 if tn > "":
2a46da701dde Uploaded
fubar
parents:
diff changeset
493 if "." in tn:
2a46da701dde Uploaded
fubar
parents:
diff changeset
494 delta = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
495 delta_frac = min(1.0, float(tn))
2a46da701dde Uploaded
fubar
parents:
diff changeset
496 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
497 delta = int(tn)
2a46da701dde Uploaded
fubar
parents:
diff changeset
498 delta_frac = None
2a46da701dde Uploaded
fubar
parents:
diff changeset
499 tp = gxtp.TestOutput(
2a46da701dde Uploaded
fubar
parents:
diff changeset
500 name=newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
501 value="%s_sample" % newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
502 compare=c,
2a46da701dde Uploaded
fubar
parents:
diff changeset
503 delta=delta,
2a46da701dde Uploaded
fubar
parents:
diff changeset
504 delta_frac=delta_frac,
2a46da701dde Uploaded
fubar
parents:
diff changeset
505 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
506 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
507 c = test
2a46da701dde Uploaded
fubar
parents:
diff changeset
508 tp = gxtp.TestOutput(
2a46da701dde Uploaded
fubar
parents:
diff changeset
509 name=newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
510 value="%s_sample" % newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
511 compare=c,
2a46da701dde Uploaded
fubar
parents:
diff changeset
512 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
513 self.testparam.append(tp)
2a46da701dde Uploaded
fubar
parents:
diff changeset
514 for p in self.infiles:
2a46da701dde Uploaded
fubar
parents:
diff changeset
515 newname = p["infilename"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
516 newfmt = p["format"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
517 ndash = self.getNdash(newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
518 reps = p.get("repeat", "0") == "1"
2a46da701dde Uploaded
fubar
parents:
diff changeset
519 if not len(p["label"]) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
520 alab = p["CL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
521 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
522 alab = p["label"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
523 aninput = gxtp.DataParam(
2a46da701dde Uploaded
fubar
parents:
diff changeset
524 newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
525 optional=False,
2a46da701dde Uploaded
fubar
parents:
diff changeset
526 label=alab,
2a46da701dde Uploaded
fubar
parents:
diff changeset
527 help=p["help"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
528 format=newfmt,
2a46da701dde Uploaded
fubar
parents:
diff changeset
529 multiple=False,
2a46da701dde Uploaded
fubar
parents:
diff changeset
530 num_dashes=ndash,
2a46da701dde Uploaded
fubar
parents:
diff changeset
531 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
532 aninput.positional = self.is_positional
2a46da701dde Uploaded
fubar
parents:
diff changeset
533 if self.is_positional:
2a46da701dde Uploaded
fubar
parents:
diff changeset
534 if p["origCL"].upper() == "STDIN":
2a46da701dde Uploaded
fubar
parents:
diff changeset
535 aninput.positional = 9999998
2a46da701dde Uploaded
fubar
parents:
diff changeset
536 aninput.command_line_override = "> $%s" % newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
537 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
538 aninput.positional = int(p["origCL"])
2a46da701dde Uploaded
fubar
parents:
diff changeset
539 aninput.command_line_override = "$%s" % newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
540 if reps:
2a46da701dde Uploaded
fubar
parents:
diff changeset
541 repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {alab} as needed")
2a46da701dde Uploaded
fubar
parents:
diff changeset
542 repe.append(aninput)
2a46da701dde Uploaded
fubar
parents:
diff changeset
543 self.tinputs.append(repe)
2a46da701dde Uploaded
fubar
parents:
diff changeset
544 tparm = gxtp.TestRepeat(name=f"R_{newname}")
2a46da701dde Uploaded
fubar
parents:
diff changeset
545 tparm2 = gxtp.TestParam(newname, value="%s_sample" % newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
546 tparm.append(tparm2)
2a46da701dde Uploaded
fubar
parents:
diff changeset
547 self.testparam.append(tparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
548 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
549 self.tinputs.append(aninput)
2a46da701dde Uploaded
fubar
parents:
diff changeset
550 tparm = gxtp.TestParam(newname, value="%s_sample" % newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
551 self.testparam.append(tparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
552 for p in self.addpar:
2a46da701dde Uploaded
fubar
parents:
diff changeset
553 newname = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
554 newval = p["value"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
555 newlabel = p["label"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
556 newhelp = p["help"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
557 newtype = p["type"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
558 newcl = p["CL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
559 oldcl = p["origCL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
560 reps = p["repeat"] == "1"
2a46da701dde Uploaded
fubar
parents:
diff changeset
561 if not len(newlabel) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
562 newlabel = newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
563 ndash = self.getNdash(newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
564 if newtype == "text":
2a46da701dde Uploaded
fubar
parents:
diff changeset
565 aparm = gxtp.TextParam(
2a46da701dde Uploaded
fubar
parents:
diff changeset
566 newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
567 label=newlabel,
2a46da701dde Uploaded
fubar
parents:
diff changeset
568 help=newhelp,
2a46da701dde Uploaded
fubar
parents:
diff changeset
569 value=newval,
2a46da701dde Uploaded
fubar
parents:
diff changeset
570 num_dashes=ndash,
2a46da701dde Uploaded
fubar
parents:
diff changeset
571 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
572 elif newtype == "integer":
2a46da701dde Uploaded
fubar
parents:
diff changeset
573 aparm = gxtp.IntegerParam(
2a46da701dde Uploaded
fubar
parents:
diff changeset
574 newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
575 label=newlabel,
2a46da701dde Uploaded
fubar
parents:
diff changeset
576 help=newhelp,
2a46da701dde Uploaded
fubar
parents:
diff changeset
577 value=newval,
2a46da701dde Uploaded
fubar
parents:
diff changeset
578 num_dashes=ndash,
2a46da701dde Uploaded
fubar
parents:
diff changeset
579 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
580 elif newtype == "float":
2a46da701dde Uploaded
fubar
parents:
diff changeset
581 aparm = gxtp.FloatParam(
2a46da701dde Uploaded
fubar
parents:
diff changeset
582 newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
583 label=newlabel,
2a46da701dde Uploaded
fubar
parents:
diff changeset
584 help=newhelp,
2a46da701dde Uploaded
fubar
parents:
diff changeset
585 value=newval,
2a46da701dde Uploaded
fubar
parents:
diff changeset
586 num_dashes=ndash,
2a46da701dde Uploaded
fubar
parents:
diff changeset
587 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
588 elif newtype == "boolean":
2a46da701dde Uploaded
fubar
parents:
diff changeset
589 aparm = gxtp.BooleanParam(
2a46da701dde Uploaded
fubar
parents:
diff changeset
590 newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
591 label=newlabel,
2a46da701dde Uploaded
fubar
parents:
diff changeset
592 help=newhelp,
2a46da701dde Uploaded
fubar
parents:
diff changeset
593 value=newval,
2a46da701dde Uploaded
fubar
parents:
diff changeset
594 num_dashes=ndash,
2a46da701dde Uploaded
fubar
parents:
diff changeset
595 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
596 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
597 raise ValueError(
2a46da701dde Uploaded
fubar
parents:
diff changeset
598 'Unrecognised parameter type "%s" for\
2a46da701dde Uploaded
fubar
parents:
diff changeset
599 additional parameter %s in makeXML'
2a46da701dde Uploaded
fubar
parents:
diff changeset
600 % (newtype, newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
601 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
602 aparm.positional = self.is_positional
2a46da701dde Uploaded
fubar
parents:
diff changeset
603 if self.is_positional:
2a46da701dde Uploaded
fubar
parents:
diff changeset
604 aparm.positional = int(oldcl)
2a46da701dde Uploaded
fubar
parents:
diff changeset
605 if reps:
2a46da701dde Uploaded
fubar
parents:
diff changeset
606 repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {newlabel} as needed")
2a46da701dde Uploaded
fubar
parents:
diff changeset
607 repe.append(aparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
608 self.tinputs.append(repe)
2a46da701dde Uploaded
fubar
parents:
diff changeset
609 tparm = gxtp.TestRepeat(name=f"R_{newname}")
2a46da701dde Uploaded
fubar
parents:
diff changeset
610 tparm2 = gxtp.TestParam(newname, value=newval)
2a46da701dde Uploaded
fubar
parents:
diff changeset
611 tparm.append(tparm2)
2a46da701dde Uploaded
fubar
parents:
diff changeset
612 self.testparam.append(tparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
613 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
614 self.tinputs.append(aparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
615 tparm = gxtp.TestParam(newname, value=newval)
2a46da701dde Uploaded
fubar
parents:
diff changeset
616 self.testparam.append(tparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
617 for p in self.selpar:
2a46da701dde Uploaded
fubar
parents:
diff changeset
618 newname = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
619 newval = p["value"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
620 newlabel = p["label"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
621 newhelp = p["help"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
622 newtype = p["type"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
623 newcl = p["CL"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
624 if not len(newlabel) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
625 newlabel = newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
626 ndash = self.getNdash(newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
627 if newtype == "selecttext":
2a46da701dde Uploaded
fubar
parents:
diff changeset
628 newtext = p["texts"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
629 aparm = gxtp.SelectParam(
2a46da701dde Uploaded
fubar
parents:
diff changeset
630 newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
631 label=newlabel,
2a46da701dde Uploaded
fubar
parents:
diff changeset
632 help=newhelp,
2a46da701dde Uploaded
fubar
parents:
diff changeset
633 num_dashes=ndash,
2a46da701dde Uploaded
fubar
parents:
diff changeset
634 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
635 for i in range(len(newval)):
2a46da701dde Uploaded
fubar
parents:
diff changeset
636 anopt = gxtp.SelectOption(
2a46da701dde Uploaded
fubar
parents:
diff changeset
637 value=newval[i],
2a46da701dde Uploaded
fubar
parents:
diff changeset
638 text=newtext[i],
2a46da701dde Uploaded
fubar
parents:
diff changeset
639 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
640 aparm.append(anopt)
2a46da701dde Uploaded
fubar
parents:
diff changeset
641 aparm.positional = self.is_positional
2a46da701dde Uploaded
fubar
parents:
diff changeset
642 if self.is_positional:
2a46da701dde Uploaded
fubar
parents:
diff changeset
643 aparm.positional = int(newcl)
2a46da701dde Uploaded
fubar
parents:
diff changeset
644 self.tinputs.append(aparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
645 tparm = gxtp.TestParam(newname, value=newval)
2a46da701dde Uploaded
fubar
parents:
diff changeset
646 self.testparam.append(tparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
647 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
648 raise ValueError(
2a46da701dde Uploaded
fubar
parents:
diff changeset
649 'Unrecognised parameter type "%s" for\
2a46da701dde Uploaded
fubar
parents:
diff changeset
650 selecttext parameter %s in makeXML'
2a46da701dde Uploaded
fubar
parents:
diff changeset
651 % (newtype, newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
652 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
653 for p in self.collections:
2a46da701dde Uploaded
fubar
parents:
diff changeset
654 newkind = p["kind"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
655 newname = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
656 newlabel = p["label"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
657 newdisc = p["discover"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
658 collect = gxtp.OutputCollection(newname, label=newlabel, type=newkind)
2a46da701dde Uploaded
fubar
parents:
diff changeset
659 disc = gxtp.DiscoverDatasets(
2a46da701dde Uploaded
fubar
parents:
diff changeset
660 pattern=newdisc, directory=f"{newname}", visible="false"
2a46da701dde Uploaded
fubar
parents:
diff changeset
661 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
662 collect.append(disc)
2a46da701dde Uploaded
fubar
parents:
diff changeset
663 self.toutputs.append(collect)
2a46da701dde Uploaded
fubar
parents:
diff changeset
664 try:
2a46da701dde Uploaded
fubar
parents:
diff changeset
665 tparm = gxtp.TestOutputCollection(newname) # broken until PR merged.
2a46da701dde Uploaded
fubar
parents:
diff changeset
666 self.testparam.append(tparm)
2a46da701dde Uploaded
fubar
parents:
diff changeset
667 except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
668 print("#### WARNING: Galaxyxml version does not have the PR merged yet - tests for collections must be over-ridden until then!")
2a46da701dde Uploaded
fubar
parents:
diff changeset
669
2a46da701dde Uploaded
fubar
parents:
diff changeset
670 def doNoXMLparam(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
671 """filter style package - stdin to stdout"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
672 if len(self.infiles) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
673 alab = self.infiles[0]["label"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
674 if len(alab) == 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
675 alab = self.infiles[0]["infilename"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
676 max1s = (
2a46da701dde Uploaded
fubar
parents:
diff changeset
677 "Maximum one input if parampass is 0 but multiple input files supplied - %s"
2a46da701dde Uploaded
fubar
parents:
diff changeset
678 % str(self.infiles)
2a46da701dde Uploaded
fubar
parents:
diff changeset
679 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
680 assert len(self.infiles) == 1, max1s
2a46da701dde Uploaded
fubar
parents:
diff changeset
681 newname = self.infiles[0]["infilename"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
682 aninput = gxtp.DataParam(
2a46da701dde Uploaded
fubar
parents:
diff changeset
683 newname,
2a46da701dde Uploaded
fubar
parents:
diff changeset
684 optional=False,
2a46da701dde Uploaded
fubar
parents:
diff changeset
685 label=alab,
2a46da701dde Uploaded
fubar
parents:
diff changeset
686 help=self.infiles[0]["help"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
687 format=self.infiles[0]["format"],
2a46da701dde Uploaded
fubar
parents:
diff changeset
688 multiple=False,
2a46da701dde Uploaded
fubar
parents:
diff changeset
689 num_dashes=0,
2a46da701dde Uploaded
fubar
parents:
diff changeset
690 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
691 aninput.command_line_override = "< $%s" % newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
692 aninput.positional = True
2a46da701dde Uploaded
fubar
parents:
diff changeset
693 self.tinputs.append(aninput)
2a46da701dde Uploaded
fubar
parents:
diff changeset
694 tp = gxtp.TestParam(name=newname, value="%s_sample" % newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
695 self.testparam.append(tp)
2a46da701dde Uploaded
fubar
parents:
diff changeset
696 if len(self.outfiles) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
697 newname = self.outfiles[0]["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
698 newfmt = self.outfiles[0]["format"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
699 anout = gxtp.OutputData(newname, format=newfmt, num_dashes=0)
2a46da701dde Uploaded
fubar
parents:
diff changeset
700 anout.command_line_override = "> $%s" % newname
2a46da701dde Uploaded
fubar
parents:
diff changeset
701 anout.positional = self.is_positional
2a46da701dde Uploaded
fubar
parents:
diff changeset
702 self.toutputs.append(anout)
2a46da701dde Uploaded
fubar
parents:
diff changeset
703 tp = gxtp.TestOutput(name=newname, value="%s_sample" % newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
704 self.testparam.append(tp)
2a46da701dde Uploaded
fubar
parents:
diff changeset
705
2a46da701dde Uploaded
fubar
parents:
diff changeset
706 def makeXML(self): # noqa
2a46da701dde Uploaded
fubar
parents:
diff changeset
707 """
2a46da701dde Uploaded
fubar
parents:
diff changeset
708 Create a Galaxy xml tool wrapper for the new script
2a46da701dde Uploaded
fubar
parents:
diff changeset
709 Uses galaxyhtml
2a46da701dde Uploaded
fubar
parents:
diff changeset
710 Hmmm. How to get the command line into correct order...
2a46da701dde Uploaded
fubar
parents:
diff changeset
711 """
2a46da701dde Uploaded
fubar
parents:
diff changeset
712 if self.command_override:
2a46da701dde Uploaded
fubar
parents:
diff changeset
713 self.newtool.command_override = self.command_override # config file
2a46da701dde Uploaded
fubar
parents:
diff changeset
714 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
715 self.newtool.command_override = self.xmlcl
2a46da701dde Uploaded
fubar
parents:
diff changeset
716 cite = gxtp.Citations()
2a46da701dde Uploaded
fubar
parents:
diff changeset
717 acite = gxtp.Citation(type="doi", value="10.1093/bioinformatics/bts573")
2a46da701dde Uploaded
fubar
parents:
diff changeset
718 cite.append(acite)
2a46da701dde Uploaded
fubar
parents:
diff changeset
719 self.newtool.citations = cite
2a46da701dde Uploaded
fubar
parents:
diff changeset
720 safertext = ""
2a46da701dde Uploaded
fubar
parents:
diff changeset
721 if self.args.help_text:
2a46da701dde Uploaded
fubar
parents:
diff changeset
722 helptext = open(self.args.help_text, "r").readlines()
2a46da701dde Uploaded
fubar
parents:
diff changeset
723 safertext = "\n".join([cheetah_escape(x) for x in helptext])
2a46da701dde Uploaded
fubar
parents:
diff changeset
724 if len(safertext.strip()) == 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
725 safertext = (
2a46da701dde Uploaded
fubar
parents:
diff changeset
726 "Ask the tool author (%s) to rebuild with help text please\n"
2a46da701dde Uploaded
fubar
parents:
diff changeset
727 % (self.args.user_email)
2a46da701dde Uploaded
fubar
parents:
diff changeset
728 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
729 if self.args.script_path:
2a46da701dde Uploaded
fubar
parents:
diff changeset
730 if len(safertext) > 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
731 safertext = safertext + "\n\n------\n" # transition allowed!
2a46da701dde Uploaded
fubar
parents:
diff changeset
732 scr = [x for x in self.spacedScript if x.strip() > ""]
2a46da701dde Uploaded
fubar
parents:
diff changeset
733 scr.insert(0, "\n\nScript::\n")
2a46da701dde Uploaded
fubar
parents:
diff changeset
734 if len(scr) > 300:
2a46da701dde Uploaded
fubar
parents:
diff changeset
735 scr = (
2a46da701dde Uploaded
fubar
parents:
diff changeset
736 scr[:100]
2a46da701dde Uploaded
fubar
parents:
diff changeset
737 + [" >300 lines - stuff deleted", " ......"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
738 + scr[-100:]
2a46da701dde Uploaded
fubar
parents:
diff changeset
739 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
740 scr.append("\n")
2a46da701dde Uploaded
fubar
parents:
diff changeset
741 safertext = safertext + "\n".join(scr)
2a46da701dde Uploaded
fubar
parents:
diff changeset
742 self.newtool.help = safertext
2a46da701dde Uploaded
fubar
parents:
diff changeset
743 self.newtool.version_command = f'echo "{self.args.tool_version}"'
2a46da701dde Uploaded
fubar
parents:
diff changeset
744 std = gxtp.Stdios()
2a46da701dde Uploaded
fubar
parents:
diff changeset
745 std1 = gxtp.Stdio()
2a46da701dde Uploaded
fubar
parents:
diff changeset
746 std.append(std1)
2a46da701dde Uploaded
fubar
parents:
diff changeset
747 self.newtool.stdios = std
2a46da701dde Uploaded
fubar
parents:
diff changeset
748 requirements = gxtp.Requirements()
2a46da701dde Uploaded
fubar
parents:
diff changeset
749 if self.args.packages:
2a46da701dde Uploaded
fubar
parents:
diff changeset
750 try:
2a46da701dde Uploaded
fubar
parents:
diff changeset
751 for d in self.args.packages.split(","):
2a46da701dde Uploaded
fubar
parents:
diff changeset
752 ver = ""
2a46da701dde Uploaded
fubar
parents:
diff changeset
753 d = d.replace("==", ":")
2a46da701dde Uploaded
fubar
parents:
diff changeset
754 d = d.replace("=", ":")
2a46da701dde Uploaded
fubar
parents:
diff changeset
755 if ":" in d:
2a46da701dde Uploaded
fubar
parents:
diff changeset
756 packg, ver = d.split(":")
2a46da701dde Uploaded
fubar
parents:
diff changeset
757 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
758 packg = d
2a46da701dde Uploaded
fubar
parents:
diff changeset
759 requirements.append(
2a46da701dde Uploaded
fubar
parents:
diff changeset
760 gxtp.Requirement("package", packg.strip(), ver.strip())
2a46da701dde Uploaded
fubar
parents:
diff changeset
761 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
762 except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
763 print('### malformed packages string supplied - cannot parse =',self.args.packages)
2a46da701dde Uploaded
fubar
parents:
diff changeset
764 sys.exit(2)
2a46da701dde Uploaded
fubar
parents:
diff changeset
765 self.newtool.requirements = requirements
2a46da701dde Uploaded
fubar
parents:
diff changeset
766 if self.args.parampass == "0":
2a46da701dde Uploaded
fubar
parents:
diff changeset
767 self.doNoXMLparam()
2a46da701dde Uploaded
fubar
parents:
diff changeset
768 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
769 self.doXMLparam()
2a46da701dde Uploaded
fubar
parents:
diff changeset
770 self.newtool.outputs = self.toutputs
2a46da701dde Uploaded
fubar
parents:
diff changeset
771 self.newtool.inputs = self.tinputs
2a46da701dde Uploaded
fubar
parents:
diff changeset
772 if self.args.script_path:
2a46da701dde Uploaded
fubar
parents:
diff changeset
773 configfiles = gxtp.Configfiles()
2a46da701dde Uploaded
fubar
parents:
diff changeset
774 configfiles.append(
2a46da701dde Uploaded
fubar
parents:
diff changeset
775 gxtp.Configfile(name="runme", text="\n".join(self.escapedScript))
2a46da701dde Uploaded
fubar
parents:
diff changeset
776 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
777 self.newtool.configfiles = configfiles
2a46da701dde Uploaded
fubar
parents:
diff changeset
778 tests = gxtp.Tests()
2a46da701dde Uploaded
fubar
parents:
diff changeset
779 test_a = gxtp.Test()
2a46da701dde Uploaded
fubar
parents:
diff changeset
780 for tp in self.testparam:
2a46da701dde Uploaded
fubar
parents:
diff changeset
781 test_a.append(tp)
2a46da701dde Uploaded
fubar
parents:
diff changeset
782 tests.append(test_a)
2a46da701dde Uploaded
fubar
parents:
diff changeset
783 self.newtool.tests = tests
2a46da701dde Uploaded
fubar
parents:
diff changeset
784 self.newtool.add_comment(
2a46da701dde Uploaded
fubar
parents:
diff changeset
785 "Created by %s at %s using the Galaxy Tool Factory."
2a46da701dde Uploaded
fubar
parents:
diff changeset
786 % (self.args.user_email, timenow())
2a46da701dde Uploaded
fubar
parents:
diff changeset
787 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
788 self.newtool.add_comment("Source in git at: %s" % (toolFactoryURL))
2a46da701dde Uploaded
fubar
parents:
diff changeset
789 exml0 = self.newtool.export()
2a46da701dde Uploaded
fubar
parents:
diff changeset
790 exml = exml0.replace(FAKEEXE, "") # temporary work around until PR accepted
2a46da701dde Uploaded
fubar
parents:
diff changeset
791 if (
2a46da701dde Uploaded
fubar
parents:
diff changeset
792 self.test_override
2a46da701dde Uploaded
fubar
parents:
diff changeset
793 ): # cannot do this inside galaxyxml as it expects lxml objects for tests
2a46da701dde Uploaded
fubar
parents:
diff changeset
794 part1 = exml.split("<tests>")[0]
2a46da701dde Uploaded
fubar
parents:
diff changeset
795 part2 = exml.split("</tests>")[1]
2a46da701dde Uploaded
fubar
parents:
diff changeset
796 fixed = "%s\n%s\n%s" % (part1, "\n".join(self.test_override), part2)
2a46da701dde Uploaded
fubar
parents:
diff changeset
797 exml = fixed
2a46da701dde Uploaded
fubar
parents:
diff changeset
798 # exml = exml.replace('range="1:"', 'range="1000:"')
2a46da701dde Uploaded
fubar
parents:
diff changeset
799 xf = open("%s.xml" % self.tool_name, "w")
2a46da701dde Uploaded
fubar
parents:
diff changeset
800 xf.write(exml)
2a46da701dde Uploaded
fubar
parents:
diff changeset
801 xf.write("\n")
2a46da701dde Uploaded
fubar
parents:
diff changeset
802 xf.close()
2a46da701dde Uploaded
fubar
parents:
diff changeset
803 # ready for the tarball
2a46da701dde Uploaded
fubar
parents:
diff changeset
804
2a46da701dde Uploaded
fubar
parents:
diff changeset
805 def writeShedyml(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
806 """for planemo"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
807 yuser = self.args.user_email.split("@")[0]
2a46da701dde Uploaded
fubar
parents:
diff changeset
808 yfname = os.path.join(self.tooloutdir, ".shed.yml")
2a46da701dde Uploaded
fubar
parents:
diff changeset
809 yamlf = open(yfname, "w")
2a46da701dde Uploaded
fubar
parents:
diff changeset
810 odict = {
2a46da701dde Uploaded
fubar
parents:
diff changeset
811 "name": self.tool_name,
2a46da701dde Uploaded
fubar
parents:
diff changeset
812 "owner": yuser,
2a46da701dde Uploaded
fubar
parents:
diff changeset
813 "type": "unrestricted",
2a46da701dde Uploaded
fubar
parents:
diff changeset
814 "description": self.args.tool_desc,
2a46da701dde Uploaded
fubar
parents:
diff changeset
815 "synopsis": self.args.tool_desc,
2a46da701dde Uploaded
fubar
parents:
diff changeset
816 "category": "TF Generated Tools",
2a46da701dde Uploaded
fubar
parents:
diff changeset
817 }
2a46da701dde Uploaded
fubar
parents:
diff changeset
818 yaml.dump(odict, yamlf, allow_unicode=True)
2a46da701dde Uploaded
fubar
parents:
diff changeset
819 yamlf.close()
2a46da701dde Uploaded
fubar
parents:
diff changeset
820
2a46da701dde Uploaded
fubar
parents:
diff changeset
821 def makeTool(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
822 """write xmls and input samples into place"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
823 if self.args.parampass == 0:
2a46da701dde Uploaded
fubar
parents:
diff changeset
824 self.doNoXMLparam()
2a46da701dde Uploaded
fubar
parents:
diff changeset
825 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
826 self.makeXML()
2a46da701dde Uploaded
fubar
parents:
diff changeset
827 if self.args.script_path:
2a46da701dde Uploaded
fubar
parents:
diff changeset
828 stname = os.path.join(self.tooloutdir, self.sfile)
2a46da701dde Uploaded
fubar
parents:
diff changeset
829 if not os.path.exists(stname):
2a46da701dde Uploaded
fubar
parents:
diff changeset
830 shutil.copyfile(self.sfile, stname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
831 xreal = "%s.xml" % self.tool_name
2a46da701dde Uploaded
fubar
parents:
diff changeset
832 xout = os.path.join(self.tooloutdir, xreal)
2a46da701dde Uploaded
fubar
parents:
diff changeset
833 shutil.copyfile(xreal, xout)
2a46da701dde Uploaded
fubar
parents:
diff changeset
834 for p in self.infiles:
2a46da701dde Uploaded
fubar
parents:
diff changeset
835 pth = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
836 dest = os.path.join(self.testdir, "%s_sample" % p["infilename"])
2a46da701dde Uploaded
fubar
parents:
diff changeset
837 shutil.copyfile(pth, dest)
2a46da701dde Uploaded
fubar
parents:
diff changeset
838 dest = os.path.join(self.repdir, "%s_sample.%s" % (p["infilename"],p["format"]))
2a46da701dde Uploaded
fubar
parents:
diff changeset
839 shutil.copyfile(pth, dest)
2a46da701dde Uploaded
fubar
parents:
diff changeset
840
2a46da701dde Uploaded
fubar
parents:
diff changeset
841 def makeToolTar(self, report_fail=False):
2a46da701dde Uploaded
fubar
parents:
diff changeset
842 """move outputs into test-data and prepare the tarball"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
843 excludeme = "_planemo_test_report.html"
2a46da701dde Uploaded
fubar
parents:
diff changeset
844
2a46da701dde Uploaded
fubar
parents:
diff changeset
845 def exclude_function(tarinfo):
2a46da701dde Uploaded
fubar
parents:
diff changeset
846 filename = tarinfo.name
2a46da701dde Uploaded
fubar
parents:
diff changeset
847 return None if filename.endswith(excludeme) else tarinfo
2a46da701dde Uploaded
fubar
parents:
diff changeset
848
2a46da701dde Uploaded
fubar
parents:
diff changeset
849 for p in self.outfiles:
2a46da701dde Uploaded
fubar
parents:
diff changeset
850 oname = p["name"]
2a46da701dde Uploaded
fubar
parents:
diff changeset
851 tdest = os.path.join(self.testdir, "%s_sample" % oname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
852 src = os.path.join(self.testdir, oname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
853 if not os.path.isfile(tdest):
2a46da701dde Uploaded
fubar
parents:
diff changeset
854 if os.path.isfile(src):
2a46da701dde Uploaded
fubar
parents:
diff changeset
855 shutil.copyfile(src, tdest)
2a46da701dde Uploaded
fubar
parents:
diff changeset
856 dest = os.path.join(self.repdir, "%s.sample" % (oname))
2a46da701dde Uploaded
fubar
parents:
diff changeset
857 shutil.copyfile(src, dest)
2a46da701dde Uploaded
fubar
parents:
diff changeset
858 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
859 if report_fail:
2a46da701dde Uploaded
fubar
parents:
diff changeset
860 print(
2a46da701dde Uploaded
fubar
parents:
diff changeset
861 "###Tool may have failed - output file %s not found in testdir after planemo run %s."
2a46da701dde Uploaded
fubar
parents:
diff changeset
862 % (tdest, self.testdir)
2a46da701dde Uploaded
fubar
parents:
diff changeset
863 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
864 tf = tarfile.open(self.newtarpath, "w:gz")
2a46da701dde Uploaded
fubar
parents:
diff changeset
865 tf.add(
2a46da701dde Uploaded
fubar
parents:
diff changeset
866 name=self.tooloutdir,
2a46da701dde Uploaded
fubar
parents:
diff changeset
867 arcname=self.tool_name,
2a46da701dde Uploaded
fubar
parents:
diff changeset
868 filter=exclude_function,
2a46da701dde Uploaded
fubar
parents:
diff changeset
869 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
870 tf.close()
2a46da701dde Uploaded
fubar
parents:
diff changeset
871 shutil.copyfile(self.newtarpath, self.args.new_tool)
2a46da701dde Uploaded
fubar
parents:
diff changeset
872
2a46da701dde Uploaded
fubar
parents:
diff changeset
873 def moveRunOutputs(self):
2a46da701dde Uploaded
fubar
parents:
diff changeset
874 """need to move planemo or run outputs into toolfactory collection"""
2a46da701dde Uploaded
fubar
parents:
diff changeset
875 with os.scandir(self.tooloutdir) as outs:
2a46da701dde Uploaded
fubar
parents:
diff changeset
876 for entry in outs:
2a46da701dde Uploaded
fubar
parents:
diff changeset
877 if not entry.is_file():
2a46da701dde Uploaded
fubar
parents:
diff changeset
878 continue
2a46da701dde Uploaded
fubar
parents:
diff changeset
879 if not entry.name.endswith('.html'):
2a46da701dde Uploaded
fubar
parents:
diff changeset
880 _, ext = os.path.splitext(entry.name)
2a46da701dde Uploaded
fubar
parents:
diff changeset
881 newname = f"{entry.name.replace('.','_')}.txt"
2a46da701dde Uploaded
fubar
parents:
diff changeset
882 dest = os.path.join(self.repdir, newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
883 src = os.path.join(self.tooloutdir, entry.name)
2a46da701dde Uploaded
fubar
parents:
diff changeset
884 shutil.copyfile(src, dest)
2a46da701dde Uploaded
fubar
parents:
diff changeset
885 if self.args.include_tests:
2a46da701dde Uploaded
fubar
parents:
diff changeset
886 with os.scandir(self.testdir) as outs:
2a46da701dde Uploaded
fubar
parents:
diff changeset
887 for entry in outs:
2a46da701dde Uploaded
fubar
parents:
diff changeset
888 if (not entry.is_file()) or entry.name.endswith(
2a46da701dde Uploaded
fubar
parents:
diff changeset
889 "_planemo_test_report.html"
2a46da701dde Uploaded
fubar
parents:
diff changeset
890 ):
2a46da701dde Uploaded
fubar
parents:
diff changeset
891 continue
2a46da701dde Uploaded
fubar
parents:
diff changeset
892 if "." in entry.name:
2a46da701dde Uploaded
fubar
parents:
diff changeset
893 _, ext = os.path.splitext(entry.name)
2a46da701dde Uploaded
fubar
parents:
diff changeset
894 if ext in [".tgz", ".json"]:
2a46da701dde Uploaded
fubar
parents:
diff changeset
895 continue
2a46da701dde Uploaded
fubar
parents:
diff changeset
896 if ext in [".yml", ".xml", ".yaml"]:
2a46da701dde Uploaded
fubar
parents:
diff changeset
897 newname = f"{entry.name.replace('.','_')}.txt"
2a46da701dde Uploaded
fubar
parents:
diff changeset
898 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
899 newname = entry.name
2a46da701dde Uploaded
fubar
parents:
diff changeset
900 else:
2a46da701dde Uploaded
fubar
parents:
diff changeset
901 newname = f"{entry.name}.txt"
2a46da701dde Uploaded
fubar
parents:
diff changeset
902 dest = os.path.join(self.repdir, newname)
2a46da701dde Uploaded
fubar
parents:
diff changeset
903 src = os.path.join(self.testdir, entry.name)
2a46da701dde Uploaded
fubar
parents:
diff changeset
904 shutil.copyfile(src, dest)
2a46da701dde Uploaded
fubar
parents:
diff changeset
905
2a46da701dde Uploaded
fubar
parents:
diff changeset
906
2a46da701dde Uploaded
fubar
parents:
diff changeset
907 def main():
2a46da701dde Uploaded
fubar
parents:
diff changeset
908 """
2a46da701dde Uploaded
fubar
parents:
diff changeset
909 This is a Galaxy wrapper.
2a46da701dde Uploaded
fubar
parents:
diff changeset
910 It expects to be called by a special purpose tool.xml
2a46da701dde Uploaded
fubar
parents:
diff changeset
911
2a46da701dde Uploaded
fubar
parents:
diff changeset
912 """
2a46da701dde Uploaded
fubar
parents:
diff changeset
913 parser = argparse.ArgumentParser()
2a46da701dde Uploaded
fubar
parents:
diff changeset
914 a = parser.add_argument
2a46da701dde Uploaded
fubar
parents:
diff changeset
915 a("--script_path", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
916 a("--history_test", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
917 a("--cl_user_suffix", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
918 a("--sysexe", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
919 a("--packages", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
920 a("--tool_name", default="newtool")
2a46da701dde Uploaded
fubar
parents:
diff changeset
921 a("--tool_dir", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
922 a("--input_files", default=[], action="append")
2a46da701dde Uploaded
fubar
parents:
diff changeset
923 a("--output_files", default=[], action="append")
2a46da701dde Uploaded
fubar
parents:
diff changeset
924 a("--user_email", default="Unknown")
2a46da701dde Uploaded
fubar
parents:
diff changeset
925 a("--bad_user", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
926 a("--help_text", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
927 a("--tool_desc", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
928 a("--tool_version", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
929 a("--citations", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
930 a("--command_override", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
931 a("--test_override", default=None)
2a46da701dde Uploaded
fubar
parents:
diff changeset
932 a("--additional_parameters", action="append", default=[])
2a46da701dde Uploaded
fubar
parents:
diff changeset
933 a("--selecttext_parameters", action="append", default=[])
2a46da701dde Uploaded
fubar
parents:
diff changeset
934 a("--edit_additional_parameters", action="store_true", default=False)
2a46da701dde Uploaded
fubar
parents:
diff changeset
935 a("--parampass", default="positional")
2a46da701dde Uploaded
fubar
parents:
diff changeset
936 a("--tfout", default="./tfout")
2a46da701dde Uploaded
fubar
parents:
diff changeset
937 a("--new_tool", default="new_tool")
2a46da701dde Uploaded
fubar
parents:
diff changeset
938 a("--galaxy_root", default="/galaxy-central")
2a46da701dde Uploaded
fubar
parents:
diff changeset
939 a("--galaxy_venv", default="/galaxy_venv")
2a46da701dde Uploaded
fubar
parents:
diff changeset
940 a("--collection", action="append", default=[])
2a46da701dde Uploaded
fubar
parents:
diff changeset
941 a("--include_tests", default=False, action="store_true")
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
942 a("--admin_only", default=False, action="store_true")
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
943 a("--install", default=False, action="store_true")
2a46da701dde Uploaded
fubar
parents:
diff changeset
944 a("--run_test", default=False, action="store_true")
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
945 a("--local_tools", default='tools') # relative to $__root_dir__
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
946 a("--tool_conf_path", default='config/tool_conf.xml') # relative to $__root_dir__
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
947 a("--galaxy_url", default="http://localhost:8080")
2a46da701dde Uploaded
fubar
parents:
diff changeset
948 a("--toolshed_url", default="http://localhost:9009")
2a46da701dde Uploaded
fubar
parents:
diff changeset
949 # make sure this is identical to tool_sheds_conf.xml
2a46da701dde Uploaded
fubar
parents:
diff changeset
950 # localhost != 127.0.0.1 so validation fails
2a46da701dde Uploaded
fubar
parents:
diff changeset
951 a("--toolshed_api_key", default="fakekey")
2a46da701dde Uploaded
fubar
parents:
diff changeset
952 a("--galaxy_api_key", default="8993d65865e6d6d1773c2c34a1cc207d")
2a46da701dde Uploaded
fubar
parents:
diff changeset
953 args = parser.parse_args()
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
954 if args.admin_only:
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
955 assert not args.bad_user, (
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
956 'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy \
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
957 admin adds %s to "admin_users" in the galaxy.yml Galaxy configuration file'
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
958 % (args.bad_user, args.bad_user)
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
959 )
2a46da701dde Uploaded
fubar
parents:
diff changeset
960 assert args.tool_name, "## Tool Factory expects a tool name - eg --tool_name=DESeq"
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
961 r = Tool_Factory(args)
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
962 r.writeShedyml()
2a46da701dde Uploaded
fubar
parents:
diff changeset
963 r.makeTool()
2a46da701dde Uploaded
fubar
parents:
diff changeset
964 r.makeToolTar()
2a46da701dde Uploaded
fubar
parents:
diff changeset
965 if args.install:
2a46da701dde Uploaded
fubar
parents:
diff changeset
966 #try:
6
efefe43f23c8 Uploaded
fubar
parents: 5
diff changeset
967 tcu = Tool_Conf_Updater(args=args, tool_dir=args.local_tools,
5
e2c8c2fa192d Uploaded
fubar
parents: 4
diff changeset
968 new_tool_archive_path=r.newtarpath, tool_conf_path=args.tool_conf_path,
4
2a46da701dde Uploaded
fubar
parents:
diff changeset
969 new_tool_name=r.tool_name)
2a46da701dde Uploaded
fubar
parents:
diff changeset
970 #except Exception:
2a46da701dde Uploaded
fubar
parents:
diff changeset
971 # print("### Unable to install the new tool. Are you sure you have all the required special settings?")
2a46da701dde Uploaded
fubar
parents:
diff changeset
972
2a46da701dde Uploaded
fubar
parents:
diff changeset
973 if __name__ == "__main__":
2a46da701dde Uploaded
fubar
parents:
diff changeset
974 main()
2a46da701dde Uploaded
fubar
parents:
diff changeset
975