Mercurial > repos > fubar > brokenandnotdeletablebyowneroradmin
diff rgToolFactory.py @ 12:d12728e33c3d
Changed to deliver a gz file - requires a new datatypes_conf.xml entry:
<datatype extension="gz" type="galaxy.datatypes.binary:Binary" mimetype="multipart/x-gzip" subclass="True" />
There's some wierd shit going on with filter values and such but it now all appears to be working ok
author | ross lazarus ross.lazarus@gmail.com |
---|---|
date | Sun, 03 Jun 2012 15:39:20 +1000 |
parents | 71f2ac0eee95 |
children | 7725e4ab27e1 |
line wrap: on
line diff
--- a/rgToolFactory.py Sat Jun 02 22:49:40 2012 +1000 +++ b/rgToolFactory.py Sun Jun 03 15:39:20 2012 +1000 @@ -67,28 +67,25 @@ self.pyfile = self.myname # crude but efficient - the cruft won't hurt much self.xmlfile = '%s.xml' % self.toolname self.sfile = '%s.%s' % (self.toolname,opts.interpreter) - if opts.output_dir or self.opts.make_Tool: # may not want these complexities + if opts.output_dir: # may not want these complexities self.tlog = os.path.join(opts.output_dir,"%s_runner.log" % self.toolname) artifactpath = os.path.join(opts.output_dir,'%s_run.script' % self.toolname) artifact = open(artifactpath,'w') artifact.write(self.script) artifact.write('\n') artifact.close() + if opts.make_Tool: # need this code and the user script for the tarball localscript = open(self.sfile,'w') localscript.write(self.script) localscript.close() shutil.copyfile(self.myname,'%s.py' % self.toolname) # for tool and for user - localpy = open('%s.py' % self.toolname,'w') - localpy.write(open(self.myname,'r').read()) self.cl = [] self.html = [] a = self.cl.append a(opts.interpreter) a('-') # use stdin - if opts.input_tab: - a(opts.input_tab) - if opts.output_tab: - a(opts.output_tab) + a(opts.input_tab) + a(opts.output_tab) self.outFormats = 'tabular' # TODO make this an option at tool generation time self.inputFormats = 'tabular' # TODO make this an option at tool generation time @@ -134,7 +131,7 @@ xdict['tooldesc'] = '' xdict['command_outputs'] = '' xdict['outputs'] = '' - if self.opts.input_tab: + if self.opts.input_tab <> 'None': xdict['command_inputs'] = '--input_tab "$input1"' xdict['inputs'] = '<param name="input1" type="data" format="%s" label="Select a suitable input file from your history"/>' % self.inputFormats else: @@ -148,7 +145,7 @@ if self.opts.make_HTML: xdict['command_outputs'] += '--output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes"' xdict['outputs'] += '<data format="html" name="html_file" label="${job_name}.html"/>\n' - if self.opts.output_tab: + if self.opts.output_tab <> 'None': xdict['command_outputs'] += '--output_tab "$tab_file"' xdict['outputs'] += '<data format="%s" name="tab_file" label="${job_name}"/>\n' % self.outFormats xdict['command'] = newCommand % xdict @@ -172,15 +169,16 @@ self.makeXML() tdir = self.toolname os.mkdir(tdir) - if self.opts.input_tab: # we may have test data? + if self.opts.input_tab <> 'None': # we may have test data? testdir = os.path.join(tdir,'test-data') os.mkdir(testdir) # make tests directory shutil.copyfile(self.opts.input_tab,os.path.join(testdir,'test1_in.tab')) - if self.opts.output_tab: + if self.opts.output_tab <> 'None': shutil.copyfile(self.opts.output_tab,os.path.join(testdir,'test1_out.tab')) if self.opts.make_HTML: shutil.copyfile(self.opts.output_html,os.path.join(testdir,'test1_out.html')) - shutil.copyfile(self.opts.tlog,os.path.join(testdir,'test1_out.log')) + if self.opts.output_dir: + shutil.copyfile(self.tlog,os.path.join(testdir,'test1_out.log')) shutil.copyfile(self.xmlfile,os.path.join(tdir,self.xmlfile)) shutil.copyfile(self.pyfile,os.path.join(tdir,'%s.py' % self.toolname)) shutil.copyfile(self.sfile,os.path.join(tdir,self.sfile)) @@ -188,8 +186,8 @@ tar = tarfile.open(tarpath, "w:gz") tar.add(tdir,arcname=self.toolname) tar.close() + shutil.copy(tarpath,self.opts.new_tool) shutil.rmtree(tdir) - self.makeHtml() # call this to return the new gzip inside the autogenerated html file ## TODO: replace with optional direct upload to local toolshed? return retval @@ -294,7 +292,7 @@ def run(self): """ """ - if self.opts.output_dir or self.opts.make_Tool: + if self.opts.output_dir: sto = open(self.tlog,'w') p = subprocess.Popen(' '.join(self.cl),shell=True,stdout=sto,stderr=sto,stdin=subprocess.PIPE,cwd=self.opts.output_dir) else: @@ -302,8 +300,9 @@ p.stdin.write(self.script) p.stdin.close() retval = p.wait() - if self.opts.make_HTML or self.opts.make_Tool: + if self.opts.output_dir: sto.close() + if self.opts.make_HTML: self.makeHtml() return retval @@ -321,14 +320,15 @@ a('--interpreter',default=None) a('--output_dir',default=None) a('--output_html',default=None) - a('--input_tab',default=None) - a('--output_tab',default=None) + a('--input_tab',default="None") + a('--output_tab',default="None") a('--user_email',default=None) a('--bad_user',default=None) a('--make_Tool',default=None) a('--make_HTML',default=None) a('--help_text',default=None) a('--tool_desc',default=None) + a('--new_tool',default=None) opts, args = op.parse_args() assert not opts.bad_user,'%s is NOT authorized to use this tool. Please ask your friendly admin' % opts.bad_user assert opts.tool_name,'## Tool Factory expects a tool name - eg --tool_name=DESeq'