comparison rgToolFactory2.py @ 4:b85a3b92e9f7 draft

Uploaded
author fubar
date Sun, 11 Jan 2015 23:03:00 -0500
parents d75fd880fce2
children e9c858c8aa6e
comparison
equal deleted inserted replaced
3:d75fd880fce2 4:b85a3b92e9f7
188 self.toolname = re.sub('[^a-zA-Z0-9_]+', '', opts.tool_name) # a sanitizer now does this but.. 188 self.toolname = re.sub('[^a-zA-Z0-9_]+', '', opts.tool_name) # a sanitizer now does this but..
189 self.toolid = self.toolname 189 self.toolid = self.toolname
190 self.myname = sys.argv[0] # get our name because we write ourselves out as a tool later 190 self.myname = sys.argv[0] # get our name because we write ourselves out as a tool later
191 self.pyfile = self.myname # crude but efficient - the cruft won't hurt much 191 self.pyfile = self.myname # crude but efficient - the cruft won't hurt much
192 self.xmlfile = '%s.xml' % self.toolname 192 self.xmlfile = '%s.xml' % self.toolname
193 s = open(self.opts.script_path,'r').readlines() 193 rx = open(self.opts.script_path,'r').readlines()
194 s = [x.rstrip() for x in s] # remove pesky dos line endings if needed 194 rx = [x.rstrip() for x in rx] # remove pesky dos line endings if needed
195 self.script = '\n'.join(s) 195 self.script = '\n'.join(rx)
196 fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname,suffix=".%s" % (opts.interpreter)) 196 fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname,suffix=".%s" % (opts.interpreter))
197 tscript = open(self.sfile,'w') # use self.sfile as script source for Popen 197 tscript = open(self.sfile,'w') # use self.sfile as script source for Popen
198 tscript.write(self.script) 198 tscript.write(self.script)
199 tscript.close() 199 tscript.close()
200 self.indentedScript = '\n'.join([' %s' % html_escape(x) for x in s]) # for restructured text in help 200 self.indentedScript = "<![CDATA[%s]]>" % '\n'.join([' %s' % x for x in rx]) # for restructured text in help
201 self.escapedScript = '\n'.join([html_escape(x) for x in s]) 201 self.escapedScript = "<![CDATA[%s]]>" % self.script)
202 self.elog = os.path.join(self.opts.output_dir,"%s_error.log" % self.toolname) 202 self.elog = os.path.join(self.opts.output_dir,"%s_error.log" % self.toolname)
203 if opts.output_dir: # may not want these complexities 203 if opts.output_dir: # may not want these complexities
204 self.tlog = os.path.join(self.opts.output_dir,"%s_runner.log" % self.toolname) 204 self.tlog = os.path.join(self.opts.output_dir,"%s_runner.log" % self.toolname)
205 art = '%s.%s' % (self.toolname,opts.interpreter) 205 art = '%s.%s' % (self.toolname,opts.interpreter)
206 artpath = os.path.join(self.opts.output_dir,art) # need full path 206 artpath = os.path.join(self.opts.output_dir,art) # need full path