def run_makeindex(self): """ Run makeindex on the texfile """ Out.write("Running makeindex %s\n" % self._basename) makeindex_command = \ self.options['makeindexbin'].replace('%', self._basename) try: makeindexprocess = subprocess.Popen( \ makeindex_command + " 2>&1" , \ shell=True, \ cwd=os.getcwd(), \ env=os.environ, \ stdout=subprocess.PIPE, \ stdin=open(os.devnull) ) parser = CompilerOutputPrinter(makeindexprocess.stdout) fatal, error, warning = parser.parseStream() while True: time.sleep(1) exitcode = makeindexprocess.poll() if exitcode is not None: break print "Waiting for makeindex to finish" if exitcode != 0: Out.write("'%s' returned with error (exit code %s).\n" \ % (makeindex_command, exitcode), VERB_WARN) return False #Failure return True except OSError, data: Out.write("makeindex failed to run:\n", VERB_WARN) Out.write(data + "\n", VERB_WARN)
def run_bibtex(self): """ Run bibtex on the texfile """ Out.write("Running bibtex %s\n" % self._basename) bibtex_command = \ self.options['bibtexbin'].replace('%', self._basename) try: bibtexprocess = subprocess.Popen( \ bibtex_command + " 2>&1", \ shell=True, \ cwd=os.getcwd(), \ env=os.environ, \ stdout=subprocess.PIPE, \ stdin=open(os.devnull) ) parser = CompilerOutputPrinter(bibtexprocess.stdout) fatal, error, warning = parser.parseStream() # TODO: print out fatal, error, warning (for all the parsers, not # just this one) while True: time.sleep(1) exitcode = bibtexprocess.poll() if exitcode is not None: break Out.write("Waiting for bibtex to finish.\n", VERB_DEBUG) if exitcode != 0: Out.write("bibtex returned with error (exit code %s).\n" \ % exitcode, VERB_WARN) return False #Failure return True except OSError, data: Out.write("bibtex failed to run:\n", VERB_WARN) Out.write(data + "\n", VERB_WARN)
def run_latex(self): """ This runs pdflatex (or whatever is given as texcompiler). If dvi is set, it is assumed that the compiler produced a dvi file, which is then converted to pdf via 'dvipdf'. """ Out.write("Running %s %s on %s\n" % (self.options['texcompiler'], self.options['compileroptions'], self._basename + ".tex")) try: latexprocess = subprocess.Popen( \ self.options['texcompiler'] + " " \ + self.options['compileroptions'] + " " \ + self._basename + " 2>&1", \ shell=True, \ cwd=os.getcwd(), \ env=os.environ, \ stdout=subprocess.PIPE, \ stdin=open(os.devnull) ) parser = CompilerOutputPrinter(latexprocess.stdout) fatal, error, warning = parser.parseStream() while True: time.sleep(1) exitcode = latexprocess.poll() if exitcode is not None: break print "Waiting for %s to finish" \ % self.options['texcompiler'] if exitcode != 0: Out.write(self._basename + \ ".tex failed to compile (exit code %s).\n" \ % exitcode, VERB_WARN) return False #Failure except OSError, data: Out.write(self._basename + ".tex failed to compile:\n", VERB_WARN) Out.write(data + "\n", VERB_WARN) return False # Failure
def run_extracompiler(self): """ Run the compiler set in the extracompiler attribute """ if self.options['extracompiler'] is not None: self.options['extracompiler'] = \ self.options['extracompiler'].strip() else: self.options['extracompiler'] = '' extracompiler = self.options['extracompiler'] if extracompiler != '': extracompiler = extracompiler.replace("%", self._basename) try: Out.write("Running extracompiler '%s'\n" % extracompiler) extracompilerprocess = subprocess.Popen( \ extracompiler + " 2>&1" , \ shell=True, \ cwd=os.getcwd(), \ env=os.environ, \ stdout=subprocess.PIPE, \ stdin=open(os.devnull) ) parser = \ CompilerOutputPrinter(extracompilerprocess.stdout) fatal, error, warning = parser.parseStream() while True: time.sleep(1) exitcode = extracompilerprocess.poll() if exitcode is not None: break print "Waiting for '%s' to finish" % extracompiler if exitcode != 0: Out.write("'%s' returned with error (exit code %s).\n" \ % (extracompiler, exitcode), VERB_WARN) return False #Failure return True except OSError, data: Out.write("'%s' failed to run:\n" % extracompiler, VERB_WARN) Out.write(data + "\n", VERB_WARN)