From 0a2be34e9e2bf6e9e9ef023dd36088733007e155 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Tue, 19 Apr 2011 19:14:33 +0200 Subject: make_guides.py: funzione build_pdf (generazione di PDF da LaTeX) --- make_guides.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/make_guides.py b/make_guides.py index d55d8e5..d46ba13 100755 --- a/make_guides.py +++ b/make_guides.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -import argparse, os +import argparse, os, shutil import docutils.core def basename(fname): @@ -85,12 +85,22 @@ def build_pdf(guide): return None except OSError: pass - # DEBUG - print('Building PDF...') if not os.path.isdir(dist_dir): os.mkdir(dist_dir) - fp = open(os.path.join(dist_dir,pdf_name),'w') - fp.close() + os.chdir(build_dir) + try: + if os.system('pdflatex '+tex_name) == 0: + if os.system('pdflatex '+tex_name) == 0: + os.system('pdflatex '+tex_name) + except OSError: + return False + finally: + os.chdir('../../') + try: + shutil.move(os.path.join(build_dir,pdf_name), + os.path.join(dist_dir,pdf_name)) + except IOError: + return False def build_nup_pdf(guide): '''Builds the nup-ed PDF for the guide''' -- cgit v1.2.3