def export_as_pdf(self, widget, data=None):
if self.texlive_installed == False:
args = [('pdflatex', '-version'), ('xelatex', '-version'), ('lualatex', '-version')]
for c, o in args:
inst = True
try: args = (c, o) subprocess.Popen(args) self.latex_engine = c break
except OSError: inst = False
The idea is pretty simple: we just call possible converters (tex to pdf) and if Popen fails it raises OSError which means no such file, i.e. Texlive is not installed or is not in PATH
By default Pandoc uses pdflatex, so it can be actually simplier — without loop, but probably for custom installations (from sources) it might be useful, I'm not sure though.
Note that '-version' option is used just to avoid interactive mode which provided by those tools
I cannot try this on other dists, pity, but on Ubuntu 12.04 with UW from trunk it seems work.
> I used the module apt only to detect if someone already has some sort of texlive installed
How about this:
<...>
latex_engine = ''
args.append( "-o%s.pdf" % basename)
args.append( "--latex- engine= %s" % self.latex_engine)
if export_type == "pdf":
<...>
def export_as_pdf(self, widget, data=None): installed == False:
args = (c, o)
subprocess. Popen(args)
self. latex_engine = c
break
inst = False
if self.texlive_
args = [('pdflatex', '-version'), ('xelatex', '-version'), ('lualatex', '-version')]
for c, o in args:
inst = True
try:
except OSError:
The idea is pretty simple: we just call possible converters (tex to pdf) and if Popen fails it raises OSError which means no such file, i.e. Texlive is not installed or is not in PATH
By default Pandoc uses pdflatex, so it can be actually simplier — without loop, but probably for custom installations (from sources) it might be useful, I'm not sure though.
Note that '-version' option is used just to avoid interactive mode which provided by those tools
I cannot try this on other dists, pity, but on Ubuntu 12.04 with UW from trunk it seems work.