Mercurial > repos > fubar > tool_factory_2
comparison toolfactory/rgToolFactory2.py @ 111:223b78754735 draft
Uploaded
author | fubar |
---|---|
date | Sun, 29 Nov 2020 07:51:53 +0000 |
parents | ab2474035f81 |
children | 5509dc4c1cf2 |
comparison
equal
deleted
inserted
replaced
110:ab2474035f81 | 111:223b78754735 |
---|---|
61 ALOT = 10000000 # srsly. command or test overrides use read() so just in case | 61 ALOT = 10000000 # srsly. command or test overrides use read() so just in case |
62 STDIOXML = """<stdio> | 62 STDIOXML = """<stdio> |
63 <exit_code range="100:" level="debug" description="shite happens" /> | 63 <exit_code range="100:" level="debug" description="shite happens" /> |
64 </stdio>""" | 64 </stdio>""" |
65 | 65 |
66 # --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label | 66 # --input_files="$intab.input_files~~~$intab.input_CL~~~$intab.input_formats\ |
67 # ~~~$input_help" | 67 #~~~$intab.input_label~~~$intab.input_help" |
68 IPATHPOS = 0 | 68 IPATHPOS = 0 |
69 ICLPOS = 1 | 69 ICLPOS = 1 |
70 IFMTPOS = 2 | 70 IFMTPOS = 2 |
71 ILABPOS = 3 | 71 ILABPOS = 3 |
72 IHELPOS = 4 | 72 IHELPOS = 4 |
261 appendme = [p[IOCLPOS], p[ICLPOS], p[IPATHPOS], ""] | 261 appendme = [p[IOCLPOS], p[ICLPOS], p[IPATHPOS], ""] |
262 xappendme = [p[IOCLPOS], p[ICLPOS], "$%s" % p[ICLPOS], ""] | 262 xappendme = [p[IOCLPOS], p[ICLPOS], "$%s" % p[ICLPOS], ""] |
263 clsuffix.append(appendme) | 263 clsuffix.append(appendme) |
264 xclsuffix.append(xappendme) | 264 xclsuffix.append(xappendme) |
265 for i, p in enumerate(self.outfiles): | 265 for i, p in enumerate(self.outfiles): |
266 if p[OOCLPOS] == "STDOUT": | 266 if p[OCLPOS] == "STDOUT": |
267 self.lastclredirect = [">", p[ONAMEPOS]] | 267 self.lastclredirect = [">", p[ONAMEPOS]] |
268 self.lastxclredirect = [">", "$%s" % p[OCLPOS]] | 268 self.lastxclredirect = [">", "$%s" % p[OCLPOS]] |
269 else: | 269 else: |
270 clsuffix.append([p[OOCLPOS], p[OCLPOS], p[ONAMEPOS], ""]) | 270 clsuffix.append([p[OOCLPOS], p[OCLPOS], p[ONAMEPOS], ""]) |
271 xclsuffix.append([p[OOCLPOS], p[OCLPOS], "$%s" % p[ONAMEPOS], ""]) | 271 xclsuffix.append([p[OOCLPOS], p[OCLPOS], "$%s" % p[ONAMEPOS], ""]) |
294 ) | 294 ) |
295 tscript = open(self.sfile, "w") | 295 tscript = open(self.sfile, "w") |
296 tscript.write(self.script) | 296 tscript.write(self.script) |
297 tscript.close() | 297 tscript.close() |
298 self.escapedScript = [cheetah_escape(x) for x in rx] | 298 self.escapedScript = [cheetah_escape(x) for x in rx] |
299 self.spacedScript = [f" {x}" for x in self.escapedScript] | 299 self.spacedScript = [f" {x}" for x in rx] |
300 art = "%s.%s" % (self.tool_name, self.executeme) | 300 art = "%s.%s" % (self.tool_name, self.executeme) |
301 artifact = open(art, "wb") | 301 artifact = open(art, "wb") |
302 artifact.write(bytes('\n'.join(self.escapedScript),'utf8')) | 302 artifact.write(bytes('\n'.join(self.escapedScript),'utf8')) |
303 artifact.close() | 303 artifact.close() |
304 | 304 |
305 def cleanuppar(self): | 305 def cleanuppar(self): |
306 """ positional parameters are complicated by their numeric ordinal""" | 306 """ positional parameters are complicated by their numeric ordinal""" |
307 for i, p in enumerate(self.infiles): | 307 for i, p in enumerate(self.infiles): |
308 infp = copy.copy(p) | |
308 if self.args.parampass == "positional": | 309 if self.args.parampass == "positional": |
309 assert p[ | 310 assert infp[ |
310 ICLPOS | 311 ICLPOS |
311 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % ( | 312 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % ( |
312 p[ICLPOS], | 313 infp[ICLPOS], |
313 p[ILABPOS], | 314 infp[ILABPOS], |
314 ) | 315 ) |
315 p.append(p[ICLPOS]) | 316 icl = infp[ICLPOS] |
316 if p[ICLPOS].isdigit() or self.args.parampass == "0": | 317 infp.append(icl) |
318 if infp[ICLPOS].isdigit() or self.args.parampass == "0": | |
317 scl = "input%d" % (i + 1) | 319 scl = "input%d" % (i + 1) |
318 p[ICLPOS] = scl | 320 infp[ICLPOS] = scl |
319 self.infiles[i] = p | 321 self.infiles[i] = infp |
320 for i, p in enumerate( | 322 for i, p in enumerate( |
321 self.outfiles | 323 self.outfiles |
322 ): # trying to automagically gather using extensions | 324 ): |
323 if self.args.parampass == "positional" and p[OCLPOS] != "STDOUT": | 325 if self.args.parampass == "positional" and p[OCLPOS] != "STDOUT": |
324 assert p[ | 326 assert p[ |
325 OCLPOS | 327 OCLPOS |
326 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % ( | 328 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % ( |
327 p[OCLPOS], | 329 p[OCLPOS], |
328 p[ONAMEPOS], | 330 p[ONAMEPOS], |
329 ) | 331 ) |
330 p.append(p[OCLPOS]) | 332 p.append(p[OCLPOS]) # keep copy |
331 if p[OCLPOS].isdigit() or p[OCLPOS] == "STDOUT": | 333 if p[OCLPOS].isdigit() or p[OCLPOS] == "STDOUT": |
332 scl = p[ONAMEPOS] | 334 scl = p[ONAMEPOS] |
333 p[OCLPOS] = scl | 335 p[OCLPOS] = scl |
334 self.outfiles[i] = p | 336 self.outfiles[i] = p |
335 for i, p in enumerate(self.addpar): | 337 for i, p in enumerate(self.addpar): |
410 ndash = 1 | 412 ndash = 1 |
411 return ndash | 413 return ndash |
412 | 414 |
413 def doXMLparam(self): | 415 def doXMLparam(self): |
414 """flake8 made me do this...""" | 416 """flake8 made me do this...""" |
415 for p in self.outfiles: | 417 for p in self.outfiles: # --output_files "$otab.history_name~~~$otab.history_format~~~$otab.history_CL~~~$otab.history_test" |
416 newname, newfmt, newcl, test, oldcl = p | 418 newname, newfmt, newcl, test, oldcl = p |
417 test = test.strip() | 419 test = test.strip() |
418 ndash = self.getNdash(newcl) | 420 ndash = self.getNdash(newcl) |
419 aparm = gxtp.OutputData(newcl, format=newfmt, num_dashes=ndash) | 421 aparm = gxtp.OutputData(name=newname, format=newfmt, num_dashes=ndash, label=newcl) |
420 aparm.positional = self.is_positional | 422 aparm.positional = self.is_positional |
421 if self.is_positional: | 423 if self.is_positional: |
422 if oldcl == "STDOUT": | 424 if oldcl == "STDOUT": |
423 aparm.positional = 9999999 | 425 aparm.positional = 9999999 |
424 aparm.command_line_override = "> $%s" % newcl | 426 aparm.command_line_override = "> $%s" % newname |
425 else: | 427 else: |
426 aparm.positional = int(oldcl) | 428 aparm.positional = int(oldcl) |
427 aparm.command_line_override = "$%s" % newcl | 429 aparm.command_line_override = "$%s" % newname |
428 self.toutputs.append(aparm) | 430 self.toutputs.append(aparm) |
429 ld = None | 431 ld = None |
430 if test.strip() > "": | 432 if test.strip() > "": |
431 if test.startswith("diff"): | 433 if test.startswith("diff"): |
432 c = "diff" | 434 c = "diff" |
580 scr = ( | 582 scr = ( |
581 scr[:100] | 583 scr[:100] |
582 + [">300 lines - stuff deleted", "......"] | 584 + [">300 lines - stuff deleted", "......"] |
583 + scr[-100:] | 585 + scr[-100:] |
584 ) | 586 ) |
585 scr.append('\n------\n') | 587 scr.append('\n') |
586 safertext = safertext + "\n".join(scr) | 588 safertext = safertext + "\n".join(scr) |
587 self.newtool.help = safertext | 589 self.newtool.help = safertext |
588 else: | 590 else: |
589 self.newtool.help = ( | 591 self.newtool.help = ( |
590 "Please ask the tool author (%s) for help \ | 592 "Please ask the tool author (%s) for help \ |
841 remote_repository_url=self.args.toolshed_url, | 843 remote_repository_url=self.args.toolshed_url, |
842 homepage_url=None, | 844 homepage_url=None, |
843 category_ids=catID, | 845 category_ids=catID, |
844 ) | 846 ) |
845 tid = res.get("id", None) | 847 tid = res.get("id", None) |
848 sto.write(f"#####create_repository {self.args.tool_name} tid={tid} res={res}\n") | |
846 else: | 849 else: |
847 i = rnames.index(self.tool_name) | 850 i = rnames.index(self.tool_name) |
848 tid = rids[i] | 851 tid = rids[i] |
849 try: | 852 try: |
850 res = ts.repositories.update_repository( | 853 res = ts.repositories.update_repository( |
851 id=tid, tar_ball_path=self.newtarpath, commit_message=None | 854 id=tid, tar_ball_path=self.newtarpath, commit_message=None |
852 ) | 855 ) |
853 sto.write(f"#####update res={res}\n") | 856 sto.write(f"#####update res id {id} ={res}\n") |
854 except ConnectionError: | 857 except ConnectionError: |
855 sto.write( | 858 sto.write( |
856 "Probably no change to repository - bioblend shed upload failed\n" | 859 "Is the toolshed running and the API key correct? Bioblend shed upload failed\n" |
857 ) | 860 ) |
858 sto.close() | 861 sto.close() |
859 | 862 |
860 def eph_galaxy_load(self): | 863 def eph_galaxy_load(self): |
861 """load the new tool from the local toolshed after planemo uploads it""" | 864 """load the new tool from the local toolshed after planemo uploads it""" |