# HG changeset patch # User fubar # Date 1419031358 18000 # Node ID ef0297b352d8986765baacfdff048fad7067a342 # Parent 42637d352d09bb7c65adecf001217a93007acba1 Uploaded diff -r 42637d352d09 -r ef0297b352d8 rgToolFactory.py --- a/rgToolFactory.py Fri Dec 19 17:03:32 2014 -0500 +++ b/rgToolFactory.py Fri Dec 19 18:22:38 2014 -0500 @@ -153,12 +153,14 @@ self.html = [] a = self.cl.append a(opts.interpreter) - if self.treatbashSpecial and opts.interpreter in ['bash','sh']: - a(self.sfile) - else: - a('-') # stdin - a(opts.input_tab) - a(opts.output_tab) + # cannot use pipe input on test - change so always eg Rscript myscript.R + #if self.treatbashSpecial and opts.interpreter in ['bash','sh']: + # a(self.sfile) + #else: + # a('-') # stdin + #a(opts.input_tab) + #a(opts.output_tab) + a(self.sfile) self.outFormats = 'tabular' # TODO make this an option at tool generation time self.inputFormats = 'tabular' # TODO make this an option at tool generation time self.test1Input = '%s_test1_input.xls' % self.toolname @@ -538,14 +540,52 @@ htmlf.close() self.html = html - def run(self): """ scripts must be small enough not to fill the pipe! """ my_env = os.environ.copy() if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']: - retval = self.runBash(pth) + retval = self.runBash() + else: + if self.opts.output_dir: + ste = open(self.elog,'w') + sto = open(self.tlog,'w') + sto.write('## Toolfactory running %s as %s script\n' % (self.toolname,self.opts.interpreter)) + sto.flush() + p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=ste,cwd=self.opts.output_dir,env=my_env) + else: + p = subprocess.Popen(self.cl,shell=False,cwd=self.opts.output_dir,env=my_env) + # p.stdin.write(self.script) + #print >> p.stdin, self.script + #p.stdin.close() + retval = p.wait() + if self.opts.output_dir: + sto.close() + ste.close() + # get stderr, allowing for case where it's very large + tmp_stderr = open( self.elog, 'rb' ) + stderr = '' + try: + while True: + stderr += tmp_stderr.read( buffsize ) + if not stderr or len( stderr ) % buffsize != 0: + break + except OverflowError: + pass + tmp_stderr.close() + if self.opts.make_HTML: + self.makeHtml() + return retval + + def old_run(self): + """ + can't use pipe as stdin on test. go figure + scripts must be small enough not to fill the pipe! + """ + my_env = os.environ.copy() + if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']: + retval = self.runBash() else: if self.opts.output_dir: ste = open(self.elog,'w')