annotate home/ross/galaxy/tools/tool_makers/toolfactory/rgToolFactory2.py @ 47:e95d9fe5ab50 draft

adding tests and local installation
author fubar
date Sun, 23 Aug 2020 21:02:03 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
1 #!/usr/bin/env python
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
2 # rgToolFactory.py
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
3 # see https://github.com/fubar2/toolfactory
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
4 #
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
5 # copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
6 #
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
7 # all rights reserved
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
8 # Licensed under the LGPL
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
9 # suggestions for improvement and bug fixes welcome at https://github.com/fubar2/toolfactory
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
10 #
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
11 # July 2020: BCC was fun and I feel like rip van winkle after 5 years.
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
12 # Decided to
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
13 # 1. Fix the toolfactory so it works - done for simplest case
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
14 # 2. Fix planemo so the toolfactory function works
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
15 # 3. Rewrite bits using galaxyxml functions where that makes sense - done
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
16 #
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
17 # removed all the old complications including making the new tool use this same script
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
18 # galaxyxml now generates the tool xml https://github.com/hexylena/galaxyxml
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
19 # No support for automatic HTML file creation from arbitrary outputs
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
20 # essential problem is to create two command lines - one for the tool xml and a different
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
21 # one to run the executable with the supplied test data and settings
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
22 # Be simpler to write the tool, then run it with planemo and soak up the test outputs.
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
23
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
24
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
25
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
26 import argparse
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
27 import logging
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
28 import os
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
29 import re
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
30 import shutil
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
31 import subprocess
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
32 import sys
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
33 import tarfile
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
34 import tempfile
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
35 import time
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
36
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
37 import galaxyxml.tool as gxt
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
38 import galaxyxml.tool.parameters as gxtp
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
39
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
40 import lxml
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
41
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
42 import yaml
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
43
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
44 myversion = "V2.1 July 2020"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
45 verbose = True
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
46 debug = True
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
47 toolFactoryURL = "https://github.com/fubar2/toolfactory"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
48 ourdelim = "~~~"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
49
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
50 # --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
51 # ~~~$input_help"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
52 IPATHPOS = 0
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
53 ICLPOS = 1
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
54 IFMTPOS = 2
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
55 ILABPOS = 3
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
56 IHELPOS = 4
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
57 IOCLPOS = 5
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
58
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
59 # --output_files "$otab.history_name~~~$otab.history_format~~~$otab.CL
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
60 ONAMEPOS = 0
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
61 OFMTPOS = 1
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
62 OCLPOS = 2
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
63 OOCLPOS = 3
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
64
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
65 # --additional_parameters="$i.param_name~~~$i.param_value~~~
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
66 # $i.param_label~~~$i.param_help~~~$i.param_type~~~$i.CL~~~i$.param_CLoverride"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
67 ANAMEPOS = 0
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
68 AVALPOS = 1
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
69 ALABPOS = 2
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
70 AHELPPOS = 3
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
71 ATYPEPOS = 4
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
72 ACLPOS = 5
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
73 AOVERPOS = 6
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
74 AOCLPOS = 7
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
75
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
76
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
77 foo = len(lxml.__version__)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
78 # fug you, flake8. Say my name!
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
79
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
80 def timenow():
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
81 """return current time as a string
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
82 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
83 return time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(time.time()))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
84
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
85
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
86 def quote_non_numeric(s):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
87 """return a prequoted string for non-numerics
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
88 useful for perl and Rscript parameter passing?
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
89 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
90 try:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
91 _ = float(s)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
92 return s
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
93 except ValueError:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
94 return '"%s"' % s
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
95
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
96
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
97 html_escape_table = {"&": "&amp;", ">": "&gt;", "<": "&lt;", "$": r"\$"}
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
98
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
99
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
100 def html_escape(text):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
101 """Produce entities within text."""
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
102 return "".join(html_escape_table.get(c, c) for c in text)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
103
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
104
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
105 def html_unescape(text):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
106 """Revert entities within text. Multiple character targets so use replace"""
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
107 t = text.replace("&amp;", "&")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
108 t = t.replace("&gt;", ">")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
109 t = t.replace("&lt;", "<")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
110 t = t.replace("\\$", "$")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
111 return t
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
112
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
113
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
114 def parse_citations(citations_text):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
115 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
116 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
117 citations = [c for c in citations_text.split("**ENTRY**") if c.strip()]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
118 citation_tuples = []
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
119 for citation in citations:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
120 if citation.startswith("doi"):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
121 citation_tuples.append(("doi", citation[len("doi") :].strip()))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
122 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
123 citation_tuples.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
124 ("bibtex", citation[len("bibtex") :].strip())
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
125 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
126 return citation_tuples
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
127
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
128
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
129 class ScriptRunner:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
130 """Wrapper for an arbitrary script
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
131 uses galaxyxml
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
132
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
133 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
134
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
135 def __init__(self, args=None):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
136 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
137 prepare command line cl for running the tool here
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
138 and prepare elements needed for galaxyxml tool generation
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
139 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
140
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
141 self.infiles = [x.split(ourdelim) for x in args.input_files]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
142 self.outfiles = [x.split(ourdelim) for x in args.output_files]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
143 self.addpar = [x.split(ourdelim) for x in args.additional_parameters]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
144 self.args = args
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
145 self.cleanuppar()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
146 self.lastclredirect = None
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
147 self.lastxclredirect = None
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
148 self.cl = []
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
149 self.xmlcl = []
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
150 self.is_positional = self.args.parampass == "positional"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
151 aCL = self.cl.append
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
152 assert args.parampass in [
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
153 "0",
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
154 "argparse",
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
155 "positional",
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
156 ], 'Parameter passing in args.parampass must be "0","positional" or "argparse"'
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
157 self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
158 self.tool_id = self.tool_name
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
159 if self.args.interpreter_name:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
160 exe = "$runMe"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
161 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
162 exe = self.args.exe_package
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
163 assert (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
164 exe is not None
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
165 ), "No interpeter or executable passed in - nothing to run so cannot build"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
166 self.tool = gxt.Tool(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
167 self.args.tool_name,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
168 self.tool_id,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
169 self.args.tool_version,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
170 self.args.tool_desc,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
171 exe,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
172 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
173 self.tooloutdir = "tfout"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
174 self.repdir = "TF_run_report_tempdir"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
175 self.testdir = os.path.join(self.tooloutdir, "test-data")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
176 if not os.path.exists(self.tooloutdir):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
177 os.mkdir(self.tooloutdir)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
178 if not os.path.exists(self.testdir):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
179 os.mkdir(self.testdir) # make tests directory
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
180 if not os.path.exists(self.repdir):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
181 os.mkdir(self.repdir)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
182 self.tinputs = gxtp.Inputs()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
183 self.toutputs = gxtp.Outputs()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
184 self.testparam = []
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
185 if (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
186 self.args.runmode == "Executable" or self.args.runmode == "system"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
187 ):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
188 if len(self.args.cl_override) > 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
189 for x in self.args.cl_override.split(' '):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
190 aCL(x)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
191 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
192 aCL(self.args.exe_package) # this little CL will just run
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
193 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
194 self.prepScript()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
195 aCL(self.args.interpreter_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
196 aCL(self.sfile)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
197
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
198 self.elog = "%s_error_log.txt" % self.tool_name
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
199 self.tlog = "%s_runner_log.txt" % self.tool_name
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
200
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
201 if self.args.parampass == "0":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
202 self.clsimple()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
203 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
204 clsuffix = []
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
205 xclsuffix = []
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
206 for i, p in enumerate(self.infiles):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
207 if p[IOCLPOS] == "STDIN":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
208 appendme = [
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
209 p[IOCLPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
210 p[ICLPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
211 p[IPATHPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
212 "< %s" % p[IPATHPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
213 ]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
214 xappendme = [
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
215 p[IOCLPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
216 p[ICLPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
217 p[IPATHPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
218 "< $%s" % p[ICLPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
219 ]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
220 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
221 appendme = [p[IOCLPOS], p[ICLPOS], p[IPATHPOS], ""]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
222 xappendme = [p[IOCLPOS], p[ICLPOS], "$%s" % p[ICLPOS], ""]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
223 clsuffix.append(appendme)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
224 xclsuffix.append(xappendme)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
225 # print('##infile i=%d, appendme=%s' % (i,appendme))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
226 for i, p in enumerate(self.outfiles):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
227 if p[OOCLPOS] == "STDOUT":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
228 self.lastclredirect = [">", p[ONAMEPOS]]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
229 self.lastxclredirect = [">", "$%s" % p[OCLPOS]]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
230 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
231 clsuffix.append([p[OOCLPOS], p[OCLPOS], p[ONAMEPOS], ""])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
232 xclsuffix.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
233 [p[OOCLPOS], p[OCLPOS], "$%s" % p[ONAMEPOS], ""]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
234 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
235 for p in self.addpar:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
236 clsuffix.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
237 [p[AOCLPOS], p[ACLPOS], p[AVALPOS], p[AOVERPOS]]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
238 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
239 xclsuffix.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
240 [p[AOCLPOS], p[ACLPOS], '"$%s"' % p[ANAMEPOS], p[AOVERPOS]]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
241 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
242 clsuffix.sort()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
243 xclsuffix.sort()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
244 self.xclsuffix = xclsuffix
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
245 self.clsuffix = clsuffix
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
246 if self.args.parampass == "positional":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
247 self.clpositional()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
248 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
249 self.clargparse()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
250
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
251 def prepScript(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
252 rx = open(self.args.script_path, "r").readlines()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
253 rx = [x.rstrip() for x in rx]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
254 rxcheck = [x.strip() for x in rx if x.strip() > ""]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
255 assert len(rxcheck) > 0, "Supplied script is empty. Cannot run"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
256 self.script = "\n".join(rx)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
257 fhandle, self.sfile = tempfile.mkstemp(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
258 prefix=self.tool_name, suffix="_%s" % (self.args.interpreter_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
259 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
260 tscript = open(self.sfile, "w")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
261 tscript.write(self.script)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
262 tscript.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
263 self.indentedScript = " %s" % "\n".join(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
264 [" %s" % html_escape(x) for x in rx]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
265 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
266 self.escapedScript = "%s" % "\n".join(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
267 [" %s" % html_escape(x) for x in rx]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
268 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
269 art = "%s.%s" % (self.tool_name, self.args.interpreter_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
270 artifact = open(art, "wb")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
271 if self.args.interpreter_name == "python":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
272 artifact.write(bytes("#!/usr/bin/env python\n", "utf8"))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
273 artifact.write(bytes(self.script, "utf8"))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
274 artifact.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
275
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
276 def cleanuppar(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
277 """ positional parameters are complicated by their numeric ordinal"""
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
278 for i, p in enumerate(self.infiles):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
279 if self.args.parampass == "positional":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
280 assert p[ICLPOS].isdigit(), (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
281 "Positional parameters must be ordinal integers - got %s for %s"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
282 % (p[ICLPOS], p[ILABPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
283 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
284 p.append(p[ICLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
285 if p[ICLPOS].isdigit() or self.args.parampass == "0":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
286 scl = "input%d" % (i + 1)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
287 p[ICLPOS] = scl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
288 self.infiles[i] = p
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
289 for i, p in enumerate(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
290 self.outfiles
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
291 ): # trying to automagically gather using extensions
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
292 if self.args.parampass == "positional" and p[OCLPOS] != "STDOUT":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
293 assert p[OCLPOS].isdigit(), (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
294 "Positional parameters must be ordinal integers - got %s for %s"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
295 % (p[OCLPOS], p[ONAMEPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
296 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
297 p.append(p[OCLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
298 if p[OCLPOS].isdigit() or p[OCLPOS] == "STDOUT":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
299 scl = p[ONAMEPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
300 p[OCLPOS] = scl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
301 self.outfiles[i] = p
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
302 for i, p in enumerate(self.addpar):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
303 if self.args.parampass == "positional":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
304 assert p[ACLPOS].isdigit(), (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
305 "Positional parameters must be ordinal integers - got %s for %s"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
306 % (p[ACLPOS], p[ANAMEPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
307 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
308 p.append(p[ACLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
309 if p[ACLPOS].isdigit():
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
310 scl = "input%s" % p[ACLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
311 p[ACLPOS] = scl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
312 self.addpar[i] = p
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
313
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
314 def clsimple(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
315 """ no parameters - uses < and > for i/o
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
316 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
317 aCL = self.cl.append
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
318 aCL("<")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
319 aCL(self.infiles[0][IPATHPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
320 aCL(">")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
321 aCL(self.outfiles[0][OCLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
322 aXCL = self.xmlcl.append
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
323 aXCL("<")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
324 aXCL("$%s" % self.infiles[0][ICLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
325 aXCL(">")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
326 aXCL("$%s" % self.outfiles[0][ONAMEPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
327
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
328 def clpositional(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
329 # inputs in order then params
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
330 aCL = self.cl.append
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
331 for (o_v, k, v, koverride) in self.clsuffix:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
332 if " " in v:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
333 aCL("%s" % v)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
334 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
335 aCL(v)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
336 aXCL = self.xmlcl.append
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
337 for (o_v, k, v, koverride) in self.xclsuffix:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
338 aXCL(v)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
339 if self.lastxclredirect:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
340 aXCL(self.lastxclredirect[0])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
341 aXCL(self.lastxclredirect[1])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
342
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
343 def clargparse(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
344 """ argparse style
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
345 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
346 aCL = self.cl.append
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
347 aXCL = self.xmlcl.append
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
348 # inputs then params in argparse named form
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
349 for (o_v, k, v, koverride) in self.xclsuffix:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
350 if koverride > "":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
351 k = koverride
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
352 elif len(k.strip()) == 1:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
353 k = "-%s" % k
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
354 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
355 k = "--%s" % k
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
356 aXCL(k)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
357 aXCL(v)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
358 for (o_v, k, v, koverride) in self.clsuffix:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
359 if koverride > "":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
360 k = koverride
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
361 elif len(k.strip()) == 1:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
362 k = "-%s" % k
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
363 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
364 k = "--%s" % k
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
365 aCL(k)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
366 aCL(v)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
367
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
368 def getNdash(self, newname):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
369 if self.is_positional:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
370 ndash = 0
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
371 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
372 ndash = 2
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
373 if len(newname) < 2:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
374 ndash = 1
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
375 return ndash
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
376
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
377 def doXMLparam(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
378 """flake8 made me do this..."""
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
379 for p in self.outfiles:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
380 newname, newfmt, newcl, oldcl = p
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
381 ndash = self.getNdash(newcl)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
382 aparm = gxtp.OutputData(newcl, format=newfmt, num_dashes=ndash)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
383 aparm.positional = self.is_positional
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
384 if self.is_positional:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
385 if oldcl == "STDOUT":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
386 aparm.positional = 9999999
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
387 aparm.command_line_override = "> $%s" % newcl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
388 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
389 aparm.positional = int(oldcl)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
390 aparm.command_line_override = "$%s" % newcl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
391 self.toutputs.append(aparm)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
392 tp = gxtp.TestOutput(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
393 name=newcl, value="%s_sample" % newcl, format=newfmt
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
394 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
395 self.testparam.append(tp)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
396 for p in self.infiles:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
397 newname = p[ICLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
398 newfmt = p[IFMTPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
399 ndash = self.getNdash(newname)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
400 if not len(p[ILABPOS]) > 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
401 alab = p[ICLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
402 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
403 alab = p[ILABPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
404 aninput = gxtp.DataParam(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
405 newname,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
406 optional=False,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
407 label=alab,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
408 help=p[IHELPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
409 format=newfmt,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
410 multiple=False,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
411 num_dashes=ndash,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
412 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
413 aninput.positional = self.is_positional
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
414 self.tinputs.append(aninput)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
415 tparm = gxtp.TestParam(name=newname, value="%s_sample" % newname)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
416 self.testparam.append(tparm)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
417 for p in self.addpar:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
418 newname, newval, newlabel, newhelp, newtype, newcl, override, oldcl = p
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
419 if not len(newlabel) > 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
420 newlabel = newname
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
421 ndash = self.getNdash(newname)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
422 if newtype == "text":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
423 aparm = gxtp.TextParam(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
424 newname,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
425 label=newlabel,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
426 help=newhelp,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
427 value=newval,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
428 num_dashes=ndash,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
429 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
430 elif newtype == "integer":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
431 aparm = gxtp.IntegerParam(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
432 newname,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
433 label=newname,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
434 help=newhelp,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
435 value=newval,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
436 num_dashes=ndash,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
437 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
438 elif newtype == "float":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
439 aparm = gxtp.FloatParam(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
440 newname,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
441 label=newname,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
442 help=newhelp,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
443 value=newval,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
444 num_dashes=ndash,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
445 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
446 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
447 raise ValueError(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
448 'Unrecognised parameter type "%s" for\
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
449 additional parameter %s in makeXML'
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
450 % (newtype, newname)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
451 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
452 aparm.positional = self.is_positional
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
453 if self.is_positional:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
454 aninput.positional = int(oldcl)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
455 self.tinputs.append(aparm)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
456 self.tparm = gxtp.TestParam(newname, value=newval)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
457 self.testparam.append(tparm)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
458
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
459 def doNoXMLparam(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
460 alab = self.infiles[0][ILABPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
461 if len(alab) == 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
462 alab = self.infiles[0][ICLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
463 max1s = (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
464 "Maximum one input if parampass is 0 - more than one input files supplied - %s"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
465 % str(self.infiles)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
466 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
467 assert len(self.infiles) == 1, max1s
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
468 newname = self.infiles[0][ICLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
469 aninput = gxtp.DataParam(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
470 newname,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
471 optional=False,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
472 label=alab,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
473 help=self.infiles[0][IHELPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
474 format=self.infiles[0][IFMTPOS],
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
475 multiple=False,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
476 num_dashes=0,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
477 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
478 aninput.command_line_override = "< $%s" % newname
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
479 aninput.positional = self.is_positional
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
480 self.tinputs.append(aninput)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
481 tp = gxtp.TestParam(name=newname, value="%s_sample" % newname)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
482 self.testparam.append(tp)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
483 newname = self.outfiles[0][OCLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
484 newfmt = self.outfiles[0][OFMTPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
485 anout = gxtp.OutputData(newname, format=newfmt, num_dashes=0)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
486 anout.command_line_override = "> $%s" % newname
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
487 anout.positional = self.is_positional
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
488 self.toutputs.append(anout)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
489 tp = gxtp.TestOutput(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
490 name=newname, value="%s_sample" % newname, format=newfmt
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
491 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
492 self.testparam.append(tp)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
493
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
494 def makeXML(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
495 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
496 Create a Galaxy xml tool wrapper for the new script
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
497 Uses galaxyhtml
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
498 Hmmm. How to get the command line into correct order...
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
499 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
500 if self.args.cl_override:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
501 self.tool.command_line_override = self.args.cl_override.split(' ') + self.xmlcl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
502 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
503 self.tool.command_line_override = self.xmlcl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
504 if self.args.interpreter_name:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
505 self.tool.interpreter = self.args.interpreter_name
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
506 if self.args.help_text:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
507 helptext = open(self.args.help_text, "r").readlines()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
508 helptext = [html_escape(x) for x in helptext]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
509 self.tool.help = "".join([x for x in helptext])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
510 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
511 self.tool.help = (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
512 "Please ask the tool author (%s) for help \
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
513 as none was supplied at tool generation\n"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
514 % (self.args.user_email)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
515 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
516 self.tool.version_command = None # do not want
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
517 requirements = gxtp.Requirements()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
518
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
519 if self.args.interpreter_name:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
520 if self.args.dependencies:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
521 for d in self.args.dependencies.split(','):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
522 requirements.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
523 gxtp.Requirement(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
524 "package", d, ""
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
525 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
526 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
527 if self.args.interpreter_name == "python":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
528 requirements.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
529 gxtp.Requirement(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
530 "package", "python", self.args.interpreter_version
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
531 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
532 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
533 elif self.args.interpreter_name not in ["bash", "sh"]:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
534 requirements.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
535 gxtp.Requirement(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
536 "package",
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
537 self.args.interpreter_name,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
538 self.args.interpreter_version,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
539 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
540 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
541 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
542 if self.args.exe_package and self.args.parampass != "system":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
543 requirements.append(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
544 gxtp.Requirement(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
545 "package",
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
546 self.args.exe_package,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
547 self.args.exe_package_version,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
548 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
549 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
550 self.tool.requirements = requirements
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
551 if self.args.parampass == "0":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
552 self.doNoXMLparam()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
553 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
554 self.doXMLparam()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
555 self.tool.outputs = self.toutputs
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
556 self.tool.inputs = self.tinputs
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
557 if self.args.runmode not in ["Executable", "system"]:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
558 configfiles = gxtp.Configfiles()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
559 configfiles.append(gxtp.Configfile(name="runMe", text=self.script))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
560 self.tool.configfiles = configfiles
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
561 tests = gxtp.Tests()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
562 test_a = gxtp.Test()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
563 for tp in self.testparam:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
564 test_a.append(tp)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
565 tests.append(test_a)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
566 self.tool.tests = tests
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
567 self.tool.add_comment(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
568 "Created by %s at %s using the Galaxy Tool Factory."
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
569 % (self.args.user_email, timenow())
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
570 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
571 self.tool.add_comment("Source in git at: %s" % (toolFactoryURL))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
572 self.tool.add_comment(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
573 "Cite: Creating re-usable tools from scripts doi: \
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
574 10.1093/bioinformatics/bts573"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
575 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
576 exml = self.tool.export()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
577 xf = open('%s.xml' % self.tool_name, "w")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
578 xf.write(exml)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
579 xf.write("\n")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
580 xf.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
581 # ready for the tarball
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
582
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
583 def makeTooltar(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
584 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
585 a tool is a gz tarball with eg
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
586 /toolname/tool.xml /toolname/tool.py /toolname/test-data/test1_in.foo ...
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
587 NOTE names for test inputs and outputs are munged here so must
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
588 correspond to actual input and output names used on the generated cl
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
589 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
590 retval = self.run()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
591 if retval:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
592 sys.stderr.write(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
593 "## Run failed. Cannot build yet. Please fix and retry"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
594 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
595 sys.exit(1)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
596 self.makeXML()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
597 for p in self.infiles:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
598 pth = p[IPATHPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
599 dest = os.path.join(self.testdir, "%s_sample" % p[ICLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
600 shutil.copyfile(pth, dest)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
601 for p in self.outfiles:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
602 pth = p[OCLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
603 if p[OOCLPOS] == "STDOUT" or self.args.parampass == "0":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
604 pth = p[ONAMEPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
605 dest = os.path.join(self.testdir, "%s_sample" % p[ONAMEPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
606 shutil.copyfile(pth, dest)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
607 dest = os.path.join(self.tooloutdir, p[ONAMEPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
608 shutil.copyfile(pth, dest)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
609 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
610 pth = p[OCLPOS]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
611 dest = os.path.join(self.testdir, "%s_sample" % p[OCLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
612 shutil.copyfile(pth, dest)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
613 dest = os.path.join(self.tooloutdir, p[OCLPOS])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
614 shutil.copyfile(pth, dest)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
615 if os.path.exists(self.tlog) and os.stat(self.tlog).st_size > 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
616 shutil.copyfile(self.tlog, os.path.join(self.tooloutdir, "test1_log_outfiletxt"))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
617 if self.args.runmode not in ["Executable", "system"]:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
618 stname = os.path.join(self.tooloutdir, "%s" % (self.sfile))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
619 if not os.path.exists(stname):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
620 shutil.copyfile(self.sfile, stname)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
621 xreal = '%s.xml' % self.tool_name
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
622 xout = os.path.join(self.tooloutdir,xreal)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
623 shutil.copyfile(xreal, xout)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
624 self.newtarpath = "toolfactory_%s.tgz" % self.tool_name
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
625 tf = tarfile.open(self.newtarpath, "w:gz")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
626 tf.add(name=self.tooloutdir, arcname=self.tool_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
627 tf.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
628 shutil.copyfile(self.newtarpath, self.args.new_tool)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
629 shutil.copyfile(xreal,"tool_xml.txt")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
630 repoutnames = [x[OCLPOS] for x in self.outfiles]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
631 with os.scandir('.') as outs:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
632 for entry in outs:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
633 if entry.name.endswith('.tgz') or not entry.is_file():
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
634 continue
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
635 if entry.name in repoutnames:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
636 if '.' in entry.name:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
637 ofne = os.path.splitext(entry.name)[1]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
638 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
639 ofne = '.txt'
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
640 ofn = '%s%s' % (entry.name.replace('.','_'),ofne)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
641 shutil.copyfile(entry.name,os.path.join(self.repdir,ofn))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
642 elif entry.name == "%s.xml" % self.tool_name:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
643 shutil.copyfile(entry.name,os.path.join(self.repdir,"new_tool_xml.xml"))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
644 return retval
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
645
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
646 def run(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
647 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
648
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
649 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
650 s = "run cl=%s" % str(self.cl)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
651
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
652 logging.debug(s)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
653 scl = " ".join(self.cl)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
654 err = None
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
655 if self.args.parampass != "0":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
656 ste = open(self.elog, "wb")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
657 if self.lastclredirect:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
658 sto = open(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
659 self.lastclredirect[1], "wb"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
660 ) # is name of an output file
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
661 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
662 sto = open(self.tlog, "wb")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
663 sto.write(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
664 bytes(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
665 "## Executing Toolfactory generated command line = %s\n"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
666 % scl,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
667 "utf8",
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
668 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
669 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
670 sto.flush()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
671 p = subprocess.run(self.cl, shell=False, stdout=sto, stderr=ste)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
672 sto.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
673 ste.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
674 tmp_stderr = open(self.elog, "rb")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
675 err = ""
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
676 buffsize = 1048576
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
677 try:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
678 while True:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
679 err += str(tmp_stderr.read(buffsize))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
680 if not err or len(err) % buffsize != 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
681 break
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
682 except OverflowError:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
683 pass
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
684 tmp_stderr.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
685 retval = p.returncode
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
686 else: # work around special case of simple scripts that take stdin and write to stdout
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
687 sti = open(self.infiles[0][IPATHPOS], "rb")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
688 sto = open(self.outfiles[0][ONAMEPOS], "wb")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
689 # must use shell to redirect
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
690 p = subprocess.run(self.cl, shell=False, stdout=sto, stdin=sti)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
691 retval = p.returncode
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
692 sto.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
693 sti.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
694 if os.path.isfile(self.tlog) and os.stat(self.tlog).st_size == 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
695 os.unlink(self.tlog)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
696 if os.path.isfile(self.elog) and os.stat(self.elog).st_size == 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
697 os.unlink(self.elog)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
698 if retval != 0 and err: # problem
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
699 sys.stderr.write(err)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
700 logging.debug("run done")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
701 return retval
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
702
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
703 def install_load(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
704 testres = self.planemo_test()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
705 if testres == 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
706 self.planemo_shedload()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
707 self,eph_galaxy_load()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
708 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
709 stderr.write('Planemo test failed - tool %s was not installed' % self.args.tool_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
710
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
711
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
712 def planemo_shedload(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
713 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
714 planemo shed_create --shed_target testtoolshed
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
715 planemo shed_update --check_diff --shed_target testtoolshed
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
716 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
717 cll = ['planemo', 'shed_create', '--shed_target','local']
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
718 p = subprocess.run(cll, shell=False,cwd=self.tooloutdir )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
719 if p.returncode != 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
720 print('Repository %s exists' % self.args.tool_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
721 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
722 print('initiated %s' % self.args.tool_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
723 cll = ['planemo', 'shed_upload', '--shed_target','local','-r','--owner','fubar',
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
724 '--name',self.args.tool_name,'--shed_key',self.args.toolshed_api_key,'--tar',self.newtarpath]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
725 p = subprocess.run(cll, shell=False,cwd=self.tooloutdir)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
726 print('Ran',' '.join(cll),'got',p.returncode)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
727 return p.returncode
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
728
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
729
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
730 def planemo_test(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
731 """planemo is a requirement so is available
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
732 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
733 cll = ['planemo', 'test', '--galaxy_root', self.args.galaxy_root,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
734 self.args.tool_name]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
735 p = subprocess.run(cll, shell=False)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
736 ols = os.listdir('.')
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
737 for fn in ols:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
738 if '.' in fn:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
739 ofne = os.path.splitext(fn)[1]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
740 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
741 ofne = '.txt'
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
742 ofn = '%s%s' % (fn.replace('.','_'),ofne)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
743 shutil.copyfile(fn,os.path.join(self.repdir,ofn))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
744 return p.returncode
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
745
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
746
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
747 def eph_galaxy_load(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
748 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
749 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
750 cll = ['shed-tools', 'install', '-g', self.args.galaxy_url, '--latest',
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
751 '-a', self.args.galaxy_api_key , '--name', self.args.tool_name, '--owner','fubar',
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
752 '--toolshed', self.args.toolshed_url,
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
753 '--section_label','Generated Tools','--install_tool_dependencies',]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
754 print('running\n',' '.join(cll))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
755 p = subprocess.run(cll, shell=False)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
756 if p.returncode != 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
757 print('Repository %s installation returned %d' % (self.args.tool_name,p.retcode))
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
758 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
759 print('installed %s' % self.args.tool_name)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
760 return p.returncode
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
761
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
762 def writeShedyml(self):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
763 yuser = self.args.user_email.split('@')[0]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
764 yfname = os.path.join(self.tooloutdir,'.shed.yml')
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
765 yamlf = open(yfname, 'w')
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
766 odict = {'name':self.tool_name,'owner':yuser,'type':'unrestricted','description':self.args.tool_desc}
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
767 yaml.dump(odict, yamlf, allow_unicode=True)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
768 yamlf.close()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
769
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
770 def main():
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
771 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
772 This is a Galaxy wrapper. It expects to be called by a special purpose tool.xml as:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
773 <command interpreter="python">rgBaseScriptWrapper.py --script_path "$scriptPath" --tool_name "foo" --interpreter "Rscript"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
774 </command>
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
775 """
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
776 parser = argparse.ArgumentParser()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
777 a = parser.add_argument
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
778 a("--script_path", default="")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
779 a("--dependencies", default="")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
780 a("--cl_override", default="")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
781 a("--tool_name", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
782 a("--interpreter_name", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
783 a("--interpreter_version", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
784 a("--exe_package", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
785 a("--exe_package_version", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
786 a("--input_files", default=[], action="append")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
787 a("--output_files", default=[], action="append")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
788 a("--user_email", default="Unknown")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
789 a("--bad_user", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
790 a("--make_Tool", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
791 a("--help_text", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
792 a("--tool_desc", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
793 a("--tool_version", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
794 a("--citations", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
795 a("--additional_parameters", action="append", default=[])
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
796 a("--edit_additional_parameters", action="store_true", default=False)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
797 a("--parampass", default="positional")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
798 a("--tfout", default="./tfout")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
799 a("--new_tool", default="new_tool")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
800 a("--runmode", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
801 a("--galaxy_url", default="http://localhost")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
802 a("--galaxy_api_key", default='fakekey')
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
803 a("--toolshed_url", default="http://localhost:9009")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
804 a("--toolshed_api_key", default=None)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
805 a("--planemo_test", default="yes")
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
806
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
807 args = parser.parse_args()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
808 assert not args.bad_user, (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
809 'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file'
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
810 % (args.bad_user, args.bad_user)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
811 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
812 assert (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
813 args.tool_name
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
814 ), "## Tool Factory expects a tool name - eg --tool_name=DESeq"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
815 assert (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
816 args.interpreter_name or args.exe_package
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
817 ), "## Tool Factory wrapper expects an interpreter or an executable package"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
818 assert args.exe_package or (
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
819 len(args.script_path) > 0 and os.path.isfile(args.script_path)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
820 ), "## Tool Factory wrapper expects a script path - eg --script_path=foo.R if no executable"
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
821 args.input_files = [
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
822 x.replace('"', "").replace("'", "") for x in args.input_files
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
823 ]
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
824 # remove quotes we need to deal with spaces in CL params
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
825 for i, x in enumerate(args.additional_parameters):
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
826 args.additional_parameters[i] = args.additional_parameters[i].replace(
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
827 '"', ""
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
828 )
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
829 r = ScriptRunner(args)
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
830 if args.make_Tool:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
831 r.writeShedyml()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
832 retcode = r.makeTooltar()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
833 if retcode == 0:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
834 if args.planemo_test == "yes":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
835 r.install_load()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
836 else:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
837 retcode = r.run()
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
838 # if retcode:
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
839 # sys.exit(retcode) # indicate failure to job runner
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
840
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
841
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
842 if __name__ == "__main__":
e95d9fe5ab50 adding tests and local installation
fubar
parents:
diff changeset
843 main()