Exemple #1
0
 def run(self):
     msg.progress(_("running %s") % self.cmd[0])
     rc = subprocess.call(self.cmd, stdout=msg.stdout)
     if rc != 0:
         msg.error(_("execution of %s failed") % self.cmd[0])
         return 1
     return 0
Exemple #2
0
 def run(self):
     # FIXME
     if len(self.prods) == 1:
         msg.error(_("%r does not exist") % self.prods[0], **self.loc)
     else:
         msg.error(_("one of %r does not exist") % self.prods, **self.loc)
     return 1
Exemple #3
0
 def __init__ (self, doc, dict):
     self.doc = doc
     lastdep = doc.env.dep_last()
     dvi = lastdep.prods[0]
     root, ext = os.path.splitext(dvi)
     if ext != ".dvi":
         msg.error(_("I can't use dvips when not producing a DVI"))
         sys.exit(2)
     ps = root + ".ps"
     self.dep = Dep(doc, ps, dvi, lastdep)
     doc.env.dep_append(self.dep)
Exemple #4
0
 def run (self):
     cmd = [self.cmdexec]
     msg.progress(_("running %s on %s") % (cmd[0], self.source))
     for opt in self.doc.paper.split():
         cmd.extend(["-t", opt])
     cmd.extend(self.options + ["-o", self.target, self.source])
     msg.debug(" ".join(cmd))
     rc = subprocess.call(cmd, stdout=msg.stdout)
     if rc != 0:
         msg.error(_("%s failed on %s") % (cmd[0], self.source))
         return 1
     return 0
Exemple #5
0
 def compile(self):
     self.must_compile = 0
     cmd = [self.program] + self.opts + [os.path.basename(self.srcfile)]
     msg.log(" ".join(cmd))
     rc = subprocess.call(cmd, stdout=msg.stdout)
     if rc != 0:
         msg.error(_("%s failed") % self.program)
     # Whatever the result is, read the log file
     if self.log.read(self.logfile):
         msg.error(_("Could not run %s.") % self.program)
         return 1
     if self.log.errors():
         return 1
     return rc
Exemple #6
0
 def __init__(self, doc, dict):
     env = doc.env
     ps = env.dep_last().prods[0]
     root, ext = os.path.splitext(ps)
     if ext != ".ps":
         msg.error(_("I can't use ps2pdf when not producing a PS"))
         sys.exit(2)
     pdf = root + ".pdf"
     cmd = ["ps2pdf"]
     for opt in doc.paper.split():
         cmd.append("-sPAPERSIZE=" + opt)
     cmd.extend([ps, pdf])
     dep = DependShell(env, cmd, prods=[pdf], sources={ps: env.dep_last()})
     env.dep_append(dep)
Exemple #7
0
 def run(self):
     """
     This method actually runs BibTeX with the appropriate environment
     variables set.
     """
     msg.progress(_("running BibTeX on %s") % self.base)
     doc = {}
     if len(self.bib_path) != 1:
         os.environ["BIBINPUTS"] = string.join(
             self.bib_path + [os.getenv("BIBINPUTS", "")], ":")
     if len(self.bst_path) != 1:
         os.environ["BSTINPUTS"] = string.join(
             self.bst_path + [os.getenv("BSTINPUTS", "")], ":")
     rc = subprocess.call(["bibtex", self.base], stdout=msg.stdout)
     if rc != 0:
         msg.error(_("There were errors making the bibliography."))
         return 1
     self.run_needed = 0
     self.doc.must_compile = 1
     return 0
Exemple #8
0
    def run(self):
        cmd = self.command()
        msg.debug(" ".join(cmd))

        # Makeindex outputs everything to stderr, even progress messages
        rc = subprocess.call(cmd, stderr=msg.stdout)
        if (rc != 0):
            msg.error(_("could not make index %s") % self.target)
            return 1

        # Beware with UTF-8 encoding, makeindex with headings can be messy
        # because it puts in the headings the first 8bits char of the words
        # under the heading which can be an invalid character in UTF-8
        if (self.style and self.doc.encoding == "utf8"):
            if not (self._index_is_unicode()):
                # Retry without style to avoid headings
                msg.warn(_("makeindex on UTF8 failed. Retry..."))
                self.style = ""
                return self.run()

        return rc
Exemple #9
0
    def run(self):
        self._sanitize_idxfile()
        self._fix_invalid_ranges()
        cmd = self.command()
        msg.debug(" ".join(cmd))

        # Collect the script output, and errors
        logname = join(dirname(self.target), "xindy.log")
        logfile = open(logname, "wb")
        p = Popen(cmd, stdout=logfile, stderr=PIPE)
        errdata = p.communicate()[1]
        if isinstance(errdata, bytes):
            errdata = errdata.decode(sys.getdefaultencoding())
        rc = p.wait()
        if msg.stdout:
            msg.stdout.write(errdata)
        else:
            msg.warn(_(errdata.strip()))
        logfile.close()
        if (rc != 0):
            msg.error(_("could not make index %s") % self.target)
            return 1

        self._detect_invalid_ranges(errdata)

        # Now convert the built index to UTF-8 if required
        if cmd[0] == "texindy" and self.doc.encoding == "utf8":
            if not (self._index_is_unicode()):
                encoding = self._find_index_encoding(logname)
                tmpindex = join(dirname(self.target), "new.ind")
                cmd = [
                    "iconv", "-f", encoding, "-t", "utf8", "-o", tmpindex,
                    self.target
                ]
                msg.debug(" ".join(cmd))
                rc = subprocess.call(cmd)
                if rc == 0: os.rename(tmpindex, self.target)

        return rc
Exemple #10
0
 def do_tool(self, tool):
     if tool not in ("makeindex", "xindy"):
         msg.error(_("unknown indexing tool '%s'") % tool)
     self.tool = tool