diff toolfactory/rgToolFactory2.py @ 66:bc1977b1f7b5 draft

Uploaded
author fubar
date Wed, 11 Nov 2020 04:35:24 +0000
parents ed1ecd161295
children 2cb06a59d84b
line wrap: on
line diff
--- a/toolfactory/rgToolFactory2.py	Tue Nov 10 23:53:32 2020 +0000
+++ b/toolfactory/rgToolFactory2.py	Wed Nov 11 04:35:24 2020 +0000
@@ -745,8 +745,8 @@
                   [--homepage_url=<Homepage for tool.>]
                   [--long_description=<long description>]
                   [--category=<category name>]*
-        
-        
+
+
         planemo shed_update --check_diff --shed_target testtoolshed
         """
         if os.path.exists(self.tlog):
@@ -760,7 +760,7 @@
         tout.write(f'############names={rnames} rids={rids}')
         cat = 'ToolFactory generated tools'
         if self.args.tool_name not in rnames:
-            cll = ["planemo", "shed_create", "--shed_target", "local", 
+            cll = ["planemo", "shed_create", "--shed_target", "local",
             "--owner","fubar","--name",
             self.args.tool_name,"--shed_key",
             self.args.toolshed_api_key,]
@@ -838,6 +838,7 @@
                 "--galaxy_root",
                 self.args.galaxy_root,
                 "--update_test_data",
+                "--docker",
                 xreal,
             ]
             p = subprocess.run(
@@ -845,7 +846,7 @@
                 )
         else:
             cll = ["planemo", "test", "--galaxy_root",
-                self.args.galaxy_root,
+                self.args.galaxy_root, "--docker",
                 xreal,]
             p = subprocess.run(
                     cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout
@@ -893,6 +894,11 @@
     def makeToolTar(self):
         """ move outputs into test-data and prepare the tarball
         """
+        excludeme = "tool_test_output"
+        def exclude_function(tarinfo):
+           filename = tarinfo.name
+           return None if filename.startswith(excludeme)  or os.path.splitext(filename)[1].startswith(excludeme) else tarinfo
+
         for p in self.outfiles:
             src = p[ONAMEPOS]
             if os.path.isfile(src):
@@ -907,7 +913,7 @@
                 )
         self.newtarpath = "toolfactory_%s.tgz" % self.tool_name
         tf = tarfile.open(self.newtarpath, "w:gz")
-        tf.add(name=self.tooloutdir, arcname=self.tool_name)
+        tf.add(name=self.tooloutdir, arcname=self.tool_name, filter=exclude_function)
         tf.close()
         shutil.copyfile(self.newtarpath, self.args.new_tool)
 
@@ -926,8 +932,6 @@
                 dest = os.path.join(self.repdir, ofn)
                 src = os.path.join(self.tooloutdir, entry.name)
                 shutil.copyfile(src, dest)
-                if entry.name.startswith('tool_test_output'):
-                    os.unlink(src)
 
 
 def main():
@@ -987,15 +991,20 @@
     r = ScriptRunner(args)
     r.writeShedyml()
     r.makeTool()
-    retcode = r.planemo_test(genoutputs=True)  # this fails :( - see PR
-    r.moveRunOutputs()
-    r.makeToolTar()
-    retcode = r.planemo_test(genoutputs=False)
-    r.moveRunOutputs()
-    if args.make_Tool == "gentestinstall":
-        retcode = r.planemo_shedload() #r.shedLoad()
-        print(f'planemo_shedload returned {retcode}')
-        r.eph_galaxy_load()
+    if args.make_Tool == "generate":
+        retcode = r.run()
+        r.moveRunOutputs()
+        r.makeToolTar()
+    else:
+        retcode = r.planemo_test(genoutputs=True)  # this fails :( - see PR
+        r.moveRunOutputs()
+        r.makeToolTar()
+        retcode = r.planemo_test(genoutputs=False)
+        r.moveRunOutputs()
+        if args.make_Tool == "gentestinstall":
+            retcode = r.planemo_shedload() #r.shedLoad()
+            print(f'planemo_shedload returned {retcode}')
+            r.eph_galaxy_load()