Mercurial > repos > fubar > toolfactory_gtn
annotate toolfactory/rgToolFactory2.py @ 2:b65ec4f387b9 draft
Uploaded
author | fubar |
---|---|
date | Sun, 18 Apr 2021 04:42:15 +0000 |
parents | 2fc9b11bbdba |
children | c4f192ec521c |
rev | line source |
---|---|
0
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1 # replace with shebang for biocontainer |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
2 # see https://github.com/fubar2/toolfactory |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
3 # |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
4 # copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
5 # |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
6 # all rights reserved |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
7 # Licensed under the LGPL |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
8 # suggestions for improvement and bug fixes welcome at |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
9 # https://github.com/fubar2/toolfactory |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
10 # |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
11 # July 2020: BCC was fun and I feel like rip van winkle after 5 years. |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
12 # Decided to |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
13 # 1. Fix the toolfactory so it works - done for simplest case |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
14 # 2. Fix planemo so the toolfactory function works |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
15 # 3. Rewrite bits using galaxyxml functions where that makes sense - done |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
16 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
17 import argparse |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
18 import copy |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
19 import json |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
20 import logging |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
21 import os |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
22 import re |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
23 import shlex |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
24 import shutil |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
25 import subprocess |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
26 import sys |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
27 import tarfile |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
28 import tempfile |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
29 import time |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
30 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
31 from bioblend import ConnectionError |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
32 from bioblend import toolshed |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
33 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
34 import galaxyxml.tool as gxt |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
35 import galaxyxml.tool.parameters as gxtp |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
36 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
37 import lxml |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
38 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
39 import yaml |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
40 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
41 myversion = "V2.2 February 2021" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
42 verbose = True |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
43 debug = True |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
44 toolFactoryURL = "https://github.com/fubar2/toolfactory" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
45 foo = len(lxml.__version__) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
46 FAKEEXE = "~~~REMOVE~~~ME~~~" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
47 # need this until a PR/version bump to fix galaxyxml prepending the exe even |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
48 # with override. |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
49 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
50 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
51 def timenow(): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
52 """return current time as a string""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
53 return time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(time.time())) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
54 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
55 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
56 cheetah_escape_table = {"$": "\\$", "#": "\\#"} |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
57 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
58 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
59 def cheetah_escape(text): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
60 """Produce entities within text.""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
61 return "".join([cheetah_escape_table.get(c, c) for c in text]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
62 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
63 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
64 def parse_citations(citations_text): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
65 """""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
66 citations = [c for c in citations_text.split("**ENTRY**") if c.strip()] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
67 citation_tuples = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
68 for citation in citations: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
69 if citation.startswith("doi"): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
70 citation_tuples.append(("doi", citation[len("doi") :].strip())) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
71 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
72 citation_tuples.append(("bibtex", citation[len("bibtex") :].strip())) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
73 return citation_tuples |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
74 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
75 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
76 class ScriptRunner: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
77 """Wrapper for an arbitrary script |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
78 uses galaxyxml |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
79 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
80 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
81 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
82 def __init__(self, args=None): # noqa |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
83 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
84 prepare command line cl for running the tool here |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
85 and prepare elements needed for galaxyxml tool generation |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
86 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
87 self.ourcwd = os.getcwd() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
88 self.collections = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
89 if len(args.collection) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
90 try: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
91 self.collections = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
92 json.loads(x) for x in args.collection if len(x.strip()) > 1 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
93 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
94 except Exception: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
95 print( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
96 f"--collections parameter {str(args.collection)} is malformed - should be a dictionary" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
97 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
98 try: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
99 self.infiles = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
100 json.loads(x) for x in args.input_files if len(x.strip()) > 1 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
101 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
102 except Exception: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
103 print( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
104 f"--input_files parameter {str(args.input_files)} is malformed - should be a dictionary" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
105 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
106 try: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
107 self.outfiles = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
108 json.loads(x) for x in args.output_files if len(x.strip()) > 1 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
109 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
110 except Exception: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
111 print( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
112 f"--output_files parameter {args.output_files} is malformed - should be a dictionary" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
113 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
114 try: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
115 self.addpar = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
116 json.loads(x) for x in args.additional_parameters if len(x.strip()) > 1 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
117 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
118 except Exception: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
119 print( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
120 f"--additional_parameters {args.additional_parameters} is malformed - should be a dictionary" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
121 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
122 try: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
123 self.selpar = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
124 json.loads(x) for x in args.selecttext_parameters if len(x.strip()) > 1 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
125 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
126 except Exception: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
127 print( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
128 f"--selecttext_parameters {args.selecttext_parameters} is malformed - should be a dictionary" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
129 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
130 self.args = args |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
131 self.cleanuppar() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
132 self.lastclredirect = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
133 self.lastxclredirect = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
134 self.cl = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
135 self.xmlcl = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
136 self.is_positional = self.args.parampass == "positional" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
137 if self.args.sysexe: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
138 if ' ' in self.args.sysexe: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
139 self.executeme = self.args.sysexe.split(' ') |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
140 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
141 self.executeme = [self.args.sysexe, ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
142 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
143 if self.args.packages: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
144 self.executeme = [self.args.packages.split(",")[0].split(":")[0].strip(), ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
145 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
146 self.executeme = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
147 aCL = self.cl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
148 aXCL = self.xmlcl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
149 assert args.parampass in [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
150 "0", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
151 "argparse", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
152 "positional", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
153 ], 'args.parampass must be "0","positional" or "argparse"' |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
154 self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
155 self.tool_id = self.tool_name |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
156 self.newtool = gxt.Tool( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
157 self.tool_name, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
158 self.tool_id, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
159 self.args.tool_version, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
160 self.args.tool_desc, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
161 FAKEEXE, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
162 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
163 self.newtarpath = "%s_toolshed.gz" % self.tool_name |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
164 self.tooloutdir = "./tfout" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
165 self.repdir = "./TF_run_report_tempdir" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
166 self.testdir = os.path.join(self.tooloutdir, "test-data") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
167 if not os.path.exists(self.tooloutdir): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
168 os.mkdir(self.tooloutdir) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
169 if not os.path.exists(self.testdir): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
170 os.mkdir(self.testdir) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
171 if not os.path.exists(self.repdir): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
172 os.mkdir(self.repdir) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
173 self.tinputs = gxtp.Inputs() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
174 self.toutputs = gxtp.Outputs() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
175 self.testparam = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
176 if self.args.script_path: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
177 self.prepScript() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
178 if self.args.command_override: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
179 scos = open(self.args.command_override, "r").readlines() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
180 self.command_override = [x.rstrip() for x in scos] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
181 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
182 self.command_override = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
183 if self.args.test_override: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
184 stos = open(self.args.test_override, "r").readlines() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
185 self.test_override = [x.rstrip() for x in stos] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
186 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
187 self.test_override = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
188 if self.args.script_path: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
189 for ex in self.executeme: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
190 aCL(ex) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
191 aXCL(ex) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
192 aCL(self.sfile) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
193 aXCL("$runme") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
194 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
195 for ex in self.executeme: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
196 aCL(ex) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
197 aXCL(ex) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
198 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
199 self.elog = os.path.join(self.repdir, "%s_error_log.txt" % self.tool_name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
200 self.tlog = os.path.join(self.repdir, "%s_runner_log.txt" % self.tool_name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
201 if self.args.parampass == "0": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
202 self.clsimple() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
203 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
204 if self.args.parampass == "positional": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
205 self.prepclpos() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
206 self.clpositional() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
207 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
208 self.prepargp() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
209 self.clargparse() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
210 if self.args.cl_suffix: # DIY CL end |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
211 clp = shlex.split(self.args.cl_suffix) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
212 for c in clp: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
213 aCL(c) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
214 aXCL(c) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
215 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
216 def clsimple(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
217 """no parameters or repeats - uses < and > for i/o""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
218 aCL = self.cl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
219 aXCL = self.xmlcl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
220 if len(self.infiles) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
221 aCL("<") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
222 aCL(self.infiles[0]["infilename"]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
223 aXCL("<") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
224 aXCL("$%s" % self.infiles[0]["infilename"]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
225 if len(self.outfiles) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
226 aCL(">") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
227 aCL(self.outfiles[0]["name"]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
228 aXCL(">") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
229 aXCL("$%s" % self.outfiles[0]["name"]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
230 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
231 def prepargp(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
232 clsuffix = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
233 xclsuffix = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
234 for i, p in enumerate(self.infiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
235 nam = p["infilename"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
236 if p["origCL"].strip().upper() == "STDIN": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
237 appendme = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
238 nam, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
239 nam, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
240 "< %s" % nam, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
241 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
242 xappendme = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
243 nam, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
244 nam, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
245 "< $%s" % nam, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
246 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
247 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
248 rep = p["repeat"] == "1" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
249 over = "" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
250 if rep: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
251 over = f'#for $rep in $R_{nam}:\n--{nam} "$rep.{nam}"\n#end for' |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
252 appendme = [p["CL"], p["CL"], ""] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
253 xappendme = [p["CL"], "$%s" % p["CL"], over] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
254 clsuffix.append(appendme) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
255 xclsuffix.append(xappendme) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
256 for i, p in enumerate(self.outfiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
257 if p["origCL"].strip().upper() == "STDOUT": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
258 self.lastclredirect = [">", p["name"]] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
259 self.lastxclredirect = [">", "$%s" % p["name"]] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
260 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
261 clsuffix.append([p["name"], p["name"], ""]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
262 xclsuffix.append([p["name"], "$%s" % p["name"], ""]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
263 for p in self.addpar: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
264 nam = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
265 rep = p["repeat"] == "1" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
266 if rep: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
267 over = f'#for $rep in $R_{nam}:\n--{nam} "$rep.{nam}"\n#end for' |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
268 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
269 over = p["override"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
270 clsuffix.append([p["CL"], nam, over]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
271 xclsuffix.append([p["CL"], nam, over]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
272 for p in self.selpar: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
273 clsuffix.append([p["CL"], p["name"], p["override"]]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
274 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
275 self.xclsuffix = xclsuffix |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
276 self.clsuffix = clsuffix |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
277 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
278 def prepclpos(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
279 clsuffix = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
280 xclsuffix = [] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
281 for i, p in enumerate(self.infiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
282 if p["origCL"].strip().upper() == "STDIN": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
283 appendme = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
284 "999", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
285 p["infilename"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
286 "< $%s" % p["infilename"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
287 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
288 xappendme = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
289 "999", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
290 p["infilename"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
291 "< $%s" % p["infilename"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
292 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
293 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
294 appendme = [p["CL"], p["infilename"], ""] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
295 xappendme = [p["CL"], "$%s" % p["infilename"], ""] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
296 clsuffix.append(appendme) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
297 xclsuffix.append(xappendme) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
298 for i, p in enumerate(self.outfiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
299 if p["origCL"].strip().upper() == "STDOUT": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
300 self.lastclredirect = [">", p["name"]] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
301 self.lastxclredirect = [">", "$%s" % p["name"]] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
302 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
303 clsuffix.append([p["CL"], p["name"], ""]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
304 xclsuffix.append([p["CL"], "$%s" % p["name"], ""]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
305 for p in self.addpar: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
306 nam = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
307 rep = p["repeat"] == "1" # repeats make NO sense |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
308 if rep: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
309 print(f'### warning. Repeats for {nam} ignored - not permitted in positional parameter command lines!') |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
310 over = p["override"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
311 clsuffix.append([p["CL"], nam, over]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
312 xclsuffix.append([p["CL"], '"$%s"' % nam, over]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
313 for p in self.selpar: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
314 clsuffix.append([p["CL"], p["name"], p["override"]]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
315 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
316 clsuffix.sort() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
317 xclsuffix.sort() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
318 self.xclsuffix = xclsuffix |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
319 self.clsuffix = clsuffix |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
320 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
321 def prepScript(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
322 rx = open(self.args.script_path, "r").readlines() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
323 rx = [x.rstrip() for x in rx] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
324 rxcheck = [x.strip() for x in rx if x.strip() > ""] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
325 assert len(rxcheck) > 0, "Supplied script is empty. Cannot run" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
326 self.script = "\n".join(rx) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
327 fhandle, self.sfile = tempfile.mkstemp( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
328 prefix=self.tool_name, suffix="_%s" % (self.executeme[0]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
329 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
330 tscript = open(self.sfile, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
331 tscript.write(self.script) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
332 tscript.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
333 self.escapedScript = [cheetah_escape(x) for x in rx] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
334 self.spacedScript = [f" {x}" for x in rx if x.strip() > ""] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
335 art = "%s.%s" % (self.tool_name, self.executeme[0]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
336 artifact = open(art, "wb") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
337 artifact.write(bytes("\n".join(self.escapedScript), "utf8")) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
338 artifact.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
339 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
340 def cleanuppar(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
341 """ positional parameters are complicated by their numeric ordinal""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
342 if self.args.parampass == "positional": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
343 for i, p in enumerate(self.infiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
344 assert ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
345 p["CL"].isdigit() or p["CL"].strip().upper() == "STDIN" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
346 ), "Positional parameters must be ordinal integers - got %s for %s" % ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
347 p["CL"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
348 p["label"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
349 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
350 for i, p in enumerate(self.outfiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
351 assert ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
352 p["CL"].isdigit() or p["CL"].strip().upper() == "STDOUT" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
353 ), "Positional parameters must be ordinal integers - got %s for %s" % ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
354 p["CL"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
355 p["name"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
356 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
357 for i, p in enumerate(self.addpar): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
358 assert p[ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
359 "CL" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
360 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
361 p["CL"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
362 p["name"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
363 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
364 for i, p in enumerate(self.infiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
365 infp = copy.copy(p) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
366 infp["origCL"] = infp["CL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
367 if self.args.parampass in ["positional", "0"]: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
368 infp["infilename"] = infp["label"].replace(" ", "_") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
369 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
370 infp["infilename"] = infp["CL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
371 self.infiles[i] = infp |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
372 for i, p in enumerate(self.outfiles): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
373 p["origCL"] = p["CL"] # keep copy |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
374 self.outfiles[i] = p |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
375 for i, p in enumerate(self.addpar): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
376 p["origCL"] = p["CL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
377 self.addpar[i] = p |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
378 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
379 def clpositional(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
380 # inputs in order then params |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
381 aCL = self.cl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
382 for (k, v, koverride) in self.clsuffix: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
383 if " " in v: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
384 aCL("%s" % v) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
385 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
386 aCL(v) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
387 aXCL = self.xmlcl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
388 for (k, v, koverride) in self.xclsuffix: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
389 aXCL(v) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
390 if self.lastxclredirect: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
391 aXCL(self.lastxclredirect[0]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
392 aXCL(self.lastxclredirect[1]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
393 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
394 def clargparse(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
395 """argparse style""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
396 aCL = self.cl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
397 aXCL = self.xmlcl.append |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
398 # inputs then params in argparse named form |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
399 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
400 for (k, v, koverride) in self.xclsuffix: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
401 if koverride > "": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
402 k = koverride |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
403 aXCL(k) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
404 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
405 if len(k.strip()) == 1: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
406 k = "-%s" % k |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
407 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
408 k = "--%s" % k |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
409 aXCL(k) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
410 aXCL(v) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
411 for (k, v, koverride) in self.clsuffix: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
412 if koverride > "": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
413 k = koverride |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
414 elif len(k.strip()) == 1: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
415 k = "-%s" % k |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
416 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
417 k = "--%s" % k |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
418 aCL(k) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
419 aCL(v) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
420 if self.lastxclredirect: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
421 aXCL(self.lastxclredirect[0]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
422 aXCL(self.lastxclredirect[1]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
423 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
424 def getNdash(self, newname): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
425 if self.is_positional: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
426 ndash = 0 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
427 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
428 ndash = 2 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
429 if len(newname) < 2: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
430 ndash = 1 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
431 return ndash |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
432 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
433 def doXMLparam(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
434 """Add all needed elements to tool""" # noqa |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
435 for p in self.outfiles: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
436 newname = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
437 newfmt = p["format"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
438 newcl = p["CL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
439 test = p["test"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
440 oldcl = p["origCL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
441 test = test.strip() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
442 ndash = self.getNdash(newcl) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
443 aparm = gxtp.OutputData( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
444 name=newname, format=newfmt, num_dashes=ndash, label=newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
445 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
446 aparm.positional = self.is_positional |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
447 if self.is_positional: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
448 if oldcl.upper() == "STDOUT": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
449 aparm.positional = 9999999 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
450 aparm.command_line_override = "> $%s" % newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
451 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
452 aparm.positional = int(oldcl) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
453 aparm.command_line_override = "$%s" % newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
454 self.toutputs.append(aparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
455 ld = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
456 if test.strip() > "": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
457 if test.startswith("diff"): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
458 c = "diff" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
459 ld = 0 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
460 if test.split(":")[1].isdigit: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
461 ld = int(test.split(":")[1]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
462 tp = gxtp.TestOutput( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
463 name=newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
464 value="%s_sample" % newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
465 compare=c, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
466 lines_diff=ld, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
467 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
468 elif test.startswith("sim_size"): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
469 c = "sim_size" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
470 tn = test.split(":")[1].strip() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
471 if tn > "": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
472 if "." in tn: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
473 delta = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
474 delta_frac = min(1.0, float(tn)) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
475 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
476 delta = int(tn) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
477 delta_frac = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
478 tp = gxtp.TestOutput( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
479 name=newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
480 value="%s_sample" % newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
481 compare=c, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
482 delta=delta, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
483 delta_frac=delta_frac, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
484 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
485 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
486 c = test |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
487 tp = gxtp.TestOutput( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
488 name=newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
489 value="%s_sample" % newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
490 compare=c, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
491 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
492 self.testparam.append(tp) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
493 for p in self.infiles: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
494 newname = p["infilename"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
495 newfmt = p["format"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
496 ndash = self.getNdash(newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
497 reps = p.get("repeat", "0") == "1" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
498 if not len(p["label"]) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
499 alab = p["CL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
500 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
501 alab = p["label"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
502 aninput = gxtp.DataParam( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
503 newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
504 optional=False, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
505 label=alab, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
506 help=p["help"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
507 format=newfmt, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
508 multiple=False, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
509 num_dashes=ndash, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
510 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
511 aninput.positional = self.is_positional |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
512 if self.is_positional: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
513 if p["origCL"].upper() == "STDIN": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
514 aninput.positional = 9999998 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
515 aninput.command_line_override = "> $%s" % newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
516 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
517 aninput.positional = int(p["origCL"]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
518 aninput.command_line_override = "$%s" % newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
519 if reps: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
520 repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {alab} as needed") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
521 repe.append(aninput) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
522 self.tinputs.append(repe) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
523 tparm = gxtp.TestRepeat(name=f"R_{newname}") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
524 tparm2 = gxtp.TestParam(newname, value="%s_sample" % newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
525 tparm.append(tparm2) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
526 self.testparam.append(tparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
527 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
528 self.tinputs.append(aninput) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
529 tparm = gxtp.TestParam(newname, value="%s_sample" % newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
530 self.testparam.append(tparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
531 for p in self.addpar: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
532 newname = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
533 newval = p["value"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
534 newlabel = p["label"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
535 newhelp = p["help"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
536 newtype = p["type"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
537 newcl = p["CL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
538 oldcl = p["origCL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
539 reps = p["repeat"] == "1" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
540 if not len(newlabel) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
541 newlabel = newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
542 ndash = self.getNdash(newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
543 if newtype == "text": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
544 aparm = gxtp.TextParam( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
545 newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
546 label=newlabel, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
547 help=newhelp, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
548 value=newval, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
549 num_dashes=ndash, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
550 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
551 elif newtype == "integer": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
552 aparm = gxtp.IntegerParam( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
553 newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
554 label=newlabel, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
555 help=newhelp, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
556 value=newval, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
557 num_dashes=ndash, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
558 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
559 elif newtype == "float": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
560 aparm = gxtp.FloatParam( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
561 newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
562 label=newlabel, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
563 help=newhelp, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
564 value=newval, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
565 num_dashes=ndash, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
566 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
567 elif newtype == "boolean": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
568 aparm = gxtp.BooleanParam( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
569 newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
570 label=newlabel, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
571 help=newhelp, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
572 value=newval, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
573 num_dashes=ndash, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
574 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
575 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
576 raise ValueError( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
577 'Unrecognised parameter type "%s" for\ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
578 additional parameter %s in makeXML' |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
579 % (newtype, newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
580 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
581 aparm.positional = self.is_positional |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
582 if self.is_positional: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
583 aparm.positional = int(oldcl) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
584 if reps: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
585 repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {newlabel} as needed") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
586 repe.append(aparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
587 self.tinputs.append(repe) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
588 tparm = gxtp.TestRepeat(name=f"R_{newname}") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
589 tparm2 = gxtp.TestParam(newname, value=newval) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
590 tparm.append(tparm2) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
591 self.testparam.append(tparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
592 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
593 self.tinputs.append(aparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
594 tparm = gxtp.TestParam(newname, value=newval) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
595 self.testparam.append(tparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
596 for p in self.selpar: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
597 newname = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
598 newval = p["value"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
599 newlabel = p["label"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
600 newhelp = p["help"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
601 newtype = p["type"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
602 newcl = p["CL"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
603 if not len(newlabel) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
604 newlabel = newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
605 ndash = self.getNdash(newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
606 if newtype == "selecttext": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
607 newtext = p["texts"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
608 aparm = gxtp.SelectParam( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
609 newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
610 label=newlabel, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
611 help=newhelp, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
612 num_dashes=ndash, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
613 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
614 for i in range(len(newval)): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
615 anopt = gxtp.SelectOption( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
616 value=newval[i], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
617 text=newtext[i], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
618 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
619 aparm.append(anopt) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
620 aparm.positional = self.is_positional |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
621 if self.is_positional: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
622 aparm.positional = int(newcl) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
623 self.tinputs.append(aparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
624 tparm = gxtp.TestParam(newname, value=newval) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
625 self.testparam.append(tparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
626 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
627 raise ValueError( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
628 'Unrecognised parameter type "%s" for\ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
629 selecttext parameter %s in makeXML' |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
630 % (newtype, newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
631 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
632 for p in self.collections: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
633 newkind = p["kind"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
634 newname = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
635 newlabel = p["label"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
636 newdisc = p["discover"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
637 collect = gxtp.OutputCollection(newname, label=newlabel, type=newkind) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
638 disc = gxtp.DiscoverDatasets( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
639 pattern=newdisc, directory=f"{newname}", visible="false" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
640 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
641 collect.append(disc) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
642 self.toutputs.append(collect) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
643 try: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
644 tparm = gxtp.TestOutputCollection(newname) # broken until PR merged. |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
645 self.testparam.append(tparm) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
646 except Exception: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
647 print("#### WARNING: Galaxyxml version does not have the PR merged yet - tests for collections must be over-ridden until then!") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
648 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
649 def doNoXMLparam(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
650 """filter style package - stdin to stdout""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
651 if len(self.infiles) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
652 alab = self.infiles[0]["label"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
653 if len(alab) == 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
654 alab = self.infiles[0]["infilename"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
655 max1s = ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
656 "Maximum one input if parampass is 0 but multiple input files supplied - %s" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
657 % str(self.infiles) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
658 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
659 assert len(self.infiles) == 1, max1s |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
660 newname = self.infiles[0]["infilename"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
661 aninput = gxtp.DataParam( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
662 newname, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
663 optional=False, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
664 label=alab, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
665 help=self.infiles[0]["help"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
666 format=self.infiles[0]["format"], |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
667 multiple=False, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
668 num_dashes=0, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
669 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
670 aninput.command_line_override = "< $%s" % newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
671 aninput.positional = True |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
672 self.tinputs.append(aninput) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
673 tp = gxtp.TestParam(name=newname, value="%s_sample" % newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
674 self.testparam.append(tp) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
675 if len(self.outfiles) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
676 newname = self.outfiles[0]["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
677 newfmt = self.outfiles[0]["format"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
678 anout = gxtp.OutputData(newname, format=newfmt, num_dashes=0) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
679 anout.command_line_override = "> $%s" % newname |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
680 anout.positional = self.is_positional |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
681 self.toutputs.append(anout) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
682 tp = gxtp.TestOutput(name=newname, value="%s_sample" % newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
683 self.testparam.append(tp) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
684 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
685 def makeXML(self): # noqa |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
686 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
687 Create a Galaxy xml tool wrapper for the new script |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
688 Uses galaxyhtml |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
689 Hmmm. How to get the command line into correct order... |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
690 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
691 if self.command_override: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
692 self.newtool.command_override = self.command_override # config file |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
693 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
694 self.newtool.command_override = self.xmlcl |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
695 cite = gxtp.Citations() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
696 acite = gxtp.Citation(type="doi", value="10.1093/bioinformatics/bts573") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
697 cite.append(acite) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
698 self.newtool.citations = cite |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
699 safertext = "" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
700 if self.args.help_text: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
701 helptext = open(self.args.help_text, "r").readlines() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
702 safertext = "\n".join([cheetah_escape(x) for x in helptext]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
703 if len(safertext.strip()) == 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
704 safertext = ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
705 "Ask the tool author (%s) to rebuild with help text please\n" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
706 % (self.args.user_email) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
707 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
708 if self.args.script_path: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
709 if len(safertext) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
710 safertext = safertext + "\n\n------\n" # transition allowed! |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
711 scr = [x for x in self.spacedScript if x.strip() > ""] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
712 scr.insert(0, "\n\nScript::\n") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
713 if len(scr) > 300: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
714 scr = ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
715 scr[:100] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
716 + [" >300 lines - stuff deleted", " ......"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
717 + scr[-100:] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
718 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
719 scr.append("\n") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
720 safertext = safertext + "\n".join(scr) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
721 self.newtool.help = safertext |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
722 self.newtool.version_command = f'echo "{self.args.tool_version}"' |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
723 std = gxtp.Stdios() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
724 std1 = gxtp.Stdio() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
725 std.append(std1) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
726 self.newtool.stdios = std |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
727 requirements = gxtp.Requirements() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
728 if self.args.packages: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
729 for d in self.args.packages.split(","): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
730 ver = "" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
731 d = d.replace("==", ":") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
732 d = d.replace("=", ":") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
733 if ":" in d: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
734 packg, ver = d.split(":") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
735 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
736 packg = d |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
737 requirements.append( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
738 gxtp.Requirement("package", packg.strip(), ver.strip()) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
739 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
740 self.newtool.requirements = requirements |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
741 if self.args.parampass == "0": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
742 self.doNoXMLparam() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
743 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
744 self.doXMLparam() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
745 self.newtool.outputs = self.toutputs |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
746 self.newtool.inputs = self.tinputs |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
747 if self.args.script_path: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
748 configfiles = gxtp.Configfiles() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
749 configfiles.append( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
750 gxtp.Configfile(name="runme", text="\n".join(self.escapedScript)) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
751 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
752 self.newtool.configfiles = configfiles |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
753 tests = gxtp.Tests() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
754 test_a = gxtp.Test() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
755 for tp in self.testparam: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
756 test_a.append(tp) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
757 tests.append(test_a) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
758 self.newtool.tests = tests |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
759 self.newtool.add_comment( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
760 "Created by %s at %s using the Galaxy Tool Factory." |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
761 % (self.args.user_email, timenow()) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
762 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
763 self.newtool.add_comment("Source in git at: %s" % (toolFactoryURL)) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
764 exml0 = self.newtool.export() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
765 exml = exml0.replace(FAKEEXE, "") # temporary work around until PR accepted |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
766 if ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
767 self.test_override |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
768 ): # cannot do this inside galaxyxml as it expects lxml objects for tests |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
769 part1 = exml.split("<tests>")[0] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
770 part2 = exml.split("</tests>")[1] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
771 fixed = "%s\n%s\n%s" % (part1, "\n".join(self.test_override), part2) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
772 exml = fixed |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
773 # exml = exml.replace('range="1:"', 'range="1000:"') |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
774 xf = open("%s.xml" % self.tool_name, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
775 xf.write(exml) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
776 xf.write("\n") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
777 xf.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
778 # ready for the tarball |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
779 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
780 def run(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
781 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
782 generate test outputs by running a command line |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
783 won't work if command or test override in play - planemo is the |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
784 easiest way to generate test outputs for that case so is |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
785 automagically selected |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
786 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
787 scl = " ".join(self.cl) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
788 err = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
789 if self.args.parampass != "0": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
790 if os.path.exists(self.elog): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
791 ste = open(self.elog, "a") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
792 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
793 ste = open(self.elog, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
794 if self.lastclredirect: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
795 sto = open(self.lastclredirect[1], "wb") # is name of an output file |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
796 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
797 if os.path.exists(self.tlog): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
798 sto = open(self.tlog, "a") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
799 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
800 sto = open(self.tlog, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
801 sto.write( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
802 "## Executing Toolfactory generated command line = %s\n" % scl |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
803 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
804 sto.flush() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
805 subp = subprocess.run( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
806 self.cl, shell=False, stdout=sto, stderr=ste |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
807 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
808 sto.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
809 ste.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
810 retval = subp.returncode |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
811 else: # work around special case - stdin and write to stdout |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
812 if len(self.infiles) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
813 sti = open(self.infiles[0]["name"], "rb") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
814 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
815 sti = sys.stdin |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
816 if len(self.outfiles) > 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
817 sto = open(self.outfiles[0]["name"], "wb") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
818 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
819 sto = sys.stdout |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
820 subp = subprocess.run( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
821 self.cl, shell=False, stdout=sto, stdin=sti |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
822 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
823 sto.write("## Executing Toolfactory generated command line = %s\n" % scl) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
824 retval = subp.returncode |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
825 sto.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
826 sti.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
827 if os.path.isfile(self.tlog) and os.stat(self.tlog).st_size == 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
828 os.unlink(self.tlog) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
829 if os.path.isfile(self.elog) and os.stat(self.elog).st_size == 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
830 os.unlink(self.elog) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
831 if retval != 0 and err: # problem |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
832 sys.stderr.write(err) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
833 logging.debug("run done") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
834 return retval |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
835 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
836 def shedLoad(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
837 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
838 use bioblend to create new repository |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
839 or update existing |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
840 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
841 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
842 if os.path.exists(self.tlog): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
843 sto = open(self.tlog, "a") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
844 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
845 sto = open(self.tlog, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
846 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
847 ts = toolshed.ToolShedInstance( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
848 url=self.args.toolshed_url, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
849 key=self.args.toolshed_api_key, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
850 verify=False, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
851 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
852 repos = ts.repositories.get_repositories() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
853 rnames = [x.get("name", "?") for x in repos] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
854 rids = [x.get("id", "?") for x in repos] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
855 tfcat = "ToolFactory generated tools" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
856 if self.tool_name not in rnames: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
857 tscat = ts.categories.get_categories() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
858 cnames = [x.get("name", "?").strip() for x in tscat] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
859 cids = [x.get("id", "?") for x in tscat] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
860 catID = None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
861 if tfcat.strip() in cnames: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
862 ci = cnames.index(tfcat) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
863 catID = cids[ci] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
864 res = ts.repositories.create_repository( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
865 name=self.args.tool_name, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
866 synopsis="Synopsis:%s" % self.args.tool_desc, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
867 description=self.args.tool_desc, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
868 type="unrestricted", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
869 remote_repository_url=self.args.toolshed_url, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
870 homepage_url=None, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
871 category_ids=catID, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
872 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
873 tid = res.get("id", None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
874 sto.write(f"#create_repository {self.args.tool_name} tid={tid} res={res}\n") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
875 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
876 i = rnames.index(self.tool_name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
877 tid = rids[i] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
878 try: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
879 res = ts.repositories.update_repository( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
880 id=tid, tar_ball_path=self.newtarpath, commit_message=None |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
881 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
882 sto.write(f"#update res id {id} ={res}\n") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
883 except ConnectionError: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
884 sto.write( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
885 "####### Is the toolshed running and the API key correct? Bioblend shed upload failed\n" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
886 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
887 sto.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
888 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
889 def eph_galaxy_load(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
890 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
891 use ephemeris to load the new tool from the local toolshed after planemo uploads it |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
892 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
893 if os.path.exists(self.tlog): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
894 tout = open(self.tlog, "a") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
895 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
896 tout = open(self.tlog, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
897 cll = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
898 "shed-tools", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
899 "install", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
900 "-g", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
901 self.args.galaxy_url, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
902 "--latest", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
903 "-a", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
904 self.args.galaxy_api_key, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
905 "--name", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
906 self.tool_name, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
907 "--owner", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
908 "fubar", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
909 "--toolshed", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
910 self.args.toolshed_url, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
911 "--section_label", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
912 "ToolFactory", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
913 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
914 tout.write("running\n%s\n" % " ".join(cll)) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
915 subp = subprocess.run( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
916 cll, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
917 cwd=self.ourcwd, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
918 shell=False, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
919 stderr=tout, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
920 stdout=tout, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
921 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
922 tout.write( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
923 "installed %s - got retcode %d\n" % (self.tool_name, subp.returncode) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
924 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
925 tout.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
926 return subp.returncode |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
927 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
928 def writeShedyml(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
929 """for planemo""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
930 yuser = self.args.user_email.split("@")[0] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
931 yfname = os.path.join(self.tooloutdir, ".shed.yml") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
932 yamlf = open(yfname, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
933 odict = { |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
934 "name": self.tool_name, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
935 "owner": yuser, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
936 "type": "unrestricted", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
937 "description": self.args.tool_desc, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
938 "synopsis": self.args.tool_desc, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
939 "category": "TF Generated Tools", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
940 } |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
941 yaml.dump(odict, yamlf, allow_unicode=True) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
942 yamlf.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
943 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
944 def makeTool(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
945 """write xmls and input samples into place""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
946 if self.args.parampass == 0: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
947 self.doNoXMLparam() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
948 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
949 self.makeXML() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
950 if self.args.script_path: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
951 stname = os.path.join(self.tooloutdir, self.sfile) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
952 if not os.path.exists(stname): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
953 shutil.copyfile(self.sfile, stname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
954 xreal = "%s.xml" % self.tool_name |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
955 xout = os.path.join(self.tooloutdir, xreal) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
956 shutil.copyfile(xreal, xout) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
957 for p in self.infiles: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
958 pth = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
959 dest = os.path.join(self.testdir, "%s_sample" % p["infilename"]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
960 shutil.copyfile(pth, dest) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
961 dest = os.path.join(self.repdir, "%s_sample" % p["infilename"]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
962 shutil.copyfile(pth, dest) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
963 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
964 def makeToolTar(self, report_fail=False): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
965 """move outputs into test-data and prepare the tarball""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
966 excludeme = "_planemo_test_report.html" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
967 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
968 def exclude_function(tarinfo): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
969 filename = tarinfo.name |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
970 return None if filename.endswith(excludeme) else tarinfo |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
971 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
972 if os.path.exists(self.tlog): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
973 tout = open(self.tlog, "a") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
974 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
975 tout = open(self.tlog, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
976 for p in self.outfiles: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
977 oname = p["name"] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
978 tdest = os.path.join(self.testdir, "%s_sample" % oname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
979 src = os.path.join(self.testdir, oname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
980 if not os.path.isfile(tdest): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
981 if os.path.isfile(src): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
982 shutil.copyfile(src, tdest) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
983 dest = os.path.join(self.repdir, "%s.sample" % (oname)) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
984 shutil.copyfile(src, dest) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
985 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
986 if report_fail: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
987 tout.write( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
988 "###Tool may have failed - output file %s not found in testdir after planemo run %s." |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
989 % (tdest, self.testdir) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
990 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
991 tf = tarfile.open(self.newtarpath, "w:gz") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
992 tf.add( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
993 name=self.tooloutdir, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
994 arcname=self.tool_name, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
995 filter=exclude_function, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
996 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
997 tf.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
998 shutil.copyfile(self.newtarpath, self.args.new_tool) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
999 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1000 def moveRunOutputs(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1001 """need to move planemo or run outputs into toolfactory collection""" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1002 with os.scandir(self.tooloutdir) as outs: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1003 for entry in outs: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1004 if not entry.is_file(): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1005 continue |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1006 if "." in entry.name: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1007 _, ext = os.path.splitext(entry.name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1008 if ext in [".tgz", ".json"]: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1009 continue |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1010 if ext in [".yml", ".xml", ".yaml"]: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1011 newname = f"{entry.name.replace('.','_')}.txt" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1012 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1013 newname = entry.name |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1014 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1015 newname = f"{entry.name}.txt" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1016 dest = os.path.join(self.repdir, newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1017 src = os.path.join(self.tooloutdir, entry.name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1018 shutil.copyfile(src, dest) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1019 if self.args.include_tests: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1020 with os.scandir(self.testdir) as outs: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1021 for entry in outs: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1022 if (not entry.is_file()) or entry.name.endswith( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1023 "_planemo_test_report.html" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1024 ): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1025 continue |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1026 if "." in entry.name: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1027 _, ext = os.path.splitext(entry.name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1028 if ext in [".tgz", ".json"]: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1029 continue |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1030 if ext in [".yml", ".xml", ".yaml"]: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1031 newname = f"{entry.name.replace('.','_')}.txt" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1032 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1033 newname = entry.name |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1034 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1035 newname = f"{entry.name}.txt" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1036 dest = os.path.join(self.repdir, newname) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1037 src = os.path.join(self.testdir, entry.name) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1038 shutil.copyfile(src, dest) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1039 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1040 def planemo_test_once(self): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1041 """planemo is a requirement so is available for testing but needs a |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1042 different call if in the biocontainer - see above |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1043 and for generating test outputs if command or test overrides are |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1044 supplied test outputs are sent to repdir for display |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1045 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1046 xreal = "%s.xml" % self.tool_name |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1047 tool_test_path = os.path.join( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1048 self.repdir, f"{self.tool_name}_planemo_test_report.html" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1049 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1050 if os.path.exists(self.tlog): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1051 tout = open(self.tlog, "a") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1052 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1053 tout = open(self.tlog, "w") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1054 cll = [ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1055 "planemo", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1056 "test", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1057 "--test_data", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1058 os.path.abspath(self.testdir), |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1059 "--test_output", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1060 os.path.abspath(tool_test_path), |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1061 "--galaxy_root", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1062 self.args.galaxy_root, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1063 "--update_test_data", |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1064 os.path.abspath(xreal), |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1065 ] |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1066 p = subprocess.run( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1067 cll, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1068 shell=False, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1069 cwd=self.tooloutdir, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1070 stderr=tout, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1071 stdout=tout, |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1072 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1073 tout.close() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1074 return p.returncode |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1075 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1076 def main(): |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1077 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1078 This is a Galaxy wrapper. |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1079 It expects to be called by a special purpose tool.xml |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1080 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1081 """ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1082 parser = argparse.ArgumentParser() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1083 a = parser.add_argument |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1084 a("--script_path", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1085 a("--history_test", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1086 a("--cl_suffix", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1087 a("--sysexe", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1088 a("--packages", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1089 a("--tool_name", default="newtool") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1090 a("--tool_dir", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1091 a("--input_files", default=[], action="append") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1092 a("--output_files", default=[], action="append") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1093 a("--user_email", default="Unknown") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1094 a("--bad_user", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1095 a("--make_Tool", default="runonly") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1096 a("--help_text", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1097 a("--tool_desc", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1098 a("--tool_version", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1099 a("--citations", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1100 a("--command_override", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1101 a("--test_override", default=None) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1102 a("--additional_parameters", action="append", default=[]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1103 a("--selecttext_parameters", action="append", default=[]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1104 a("--edit_additional_parameters", action="store_true", default=False) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1105 a("--parampass", default="positional") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1106 a("--tfout", default="./tfout") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1107 a("--new_tool", default="new_tool") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1108 a("--galaxy_url", default="http://localhost:8080") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1109 a("--toolshed_url", default="http://localhost:9009") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1110 # make sure this is identical to tool_sheds_conf.xml |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1111 # localhost != 127.0.0.1 so validation fails |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1112 a("--toolshed_api_key", default="fakekey") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1113 a("--galaxy_api_key", default="fakekey") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1114 a("--galaxy_root", default="/galaxy-central") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1115 a("--galaxy_venv", default="/galaxy_venv") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1116 a("--collection", action="append", default=[]) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1117 a("--include_tests", default=False, action="store_true") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1118 a("--python_version", default="3.9") |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1119 args = parser.parse_args() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1120 assert not args.bad_user, ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1121 'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy \ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1122 admin adds %s to "admin_users" in the galaxy.yml Galaxy configuration file' |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1123 % (args.bad_user, args.bad_user) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1124 ) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1125 assert args.tool_name, "## Tool Factory expects a tool name - eg --tool_name=DESeq" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1126 assert ( |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1127 args.sysexe or args.packages |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1128 ), "## Tool Factory wrapper expects an interpreter \ |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1129 or an executable package in --sysexe or --packages" |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1130 r = ScriptRunner(args) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1131 r.writeShedyml() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1132 r.makeTool() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1133 if args.make_Tool == "generate": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1134 r.run() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1135 r.moveRunOutputs() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1136 r.makeToolTar() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1137 else: |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1138 r.planemo_test_once() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1139 r.moveRunOutputs() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1140 r.makeToolTar(report_fail=True) |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1141 if args.make_Tool == "gentestinstall": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1142 r.shedLoad() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1143 r.eph_galaxy_load() |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1144 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1145 |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1146 if __name__ == "__main__": |
43edf22e8cbc
Toolshed seems cranky on very old metadata. Trying a new repo. Again
fubar
parents:
diff
changeset
|
1147 main() |