Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #4
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)
Beispiel #5
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
Beispiel #6
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
Beispiel #7
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)
Beispiel #8
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
Beispiel #9
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
Beispiel #10
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
Beispiel #11
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
Beispiel #12
0
    def post_compile (self):
        """
        Run makeindex if needed, with appropriate options and environment.
        """
        if not os.path.exists(self.source):
            msg.log(_("strange, there is no %s") % self.source, pkg="index")
            return 0
        if not self.run_needed():
            return 0

        msg.progress(_("processing index %s") % self.source)

        if self.tool == "makeindex":
            cmd = ["makeindex", "-o", self.target] + self.opts
            cmd.extend(["-t", self.transcript])
            if self.style:
                cmd.extend(["-s", self.style])
            cmd.append(self.source)
            path_var = "INDEXSTYLE"

        elif self.tool == "xindy":
            cmd = ["texindy", "--quiet"]
            for opt in self.opts:
                if opt == "-g":
                    if self.lang != "":
                        msg.warn(_("'language' overrides 'order german'"),
                            pkg="index")
                    else:
                        self.lang = "german-din"
                elif opt == "-l":
                    self.modules.append("letter-ordering")
                    msg.warn(_("use 'module letter-ordering' instead of 'order letter'"),
                        pkg="index")
                else:
                    msg.error("unknown option to xindy: %s" % opt, pkg="index")
            for mod in self.modules:
                cmd.extend(["--module", mod])
            if self.lang:
                cmd.extend(["--language", self.lang])
            cmd.append(self.source)
            path_var = "XINDY_SEARCHPATH"

        if self.path != []:
            env = { path_var:
                string.join(self.path + [os.getenv(path_var, "")], ":") }
        else:
            env = {}

        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
        if self.doc.encoding == "utf8" and self.style:
            f = file(self.target, "r")
            error = 0
            for line in f:
                try:
                    line.decode("utf8")
                except:
                    error = 1
                    break
            f.close()
            if error:
                print "here"
                # Retry without style
                msg.log(_("%s on UTF8 failed. Retry...") % self.tool)
                self.style = ""
                self.md5 = None
                return self.post_compile()

        self.doc.must_compile = 1
        return 0
Beispiel #13
0
 def do_tool (self, tool):
     if tool not in ("makeindex", "xindy"):
         msg.error(_("unknown indexing tool '%s'") % tool)
     self.tool = tool