def build(self, version): project = version.project os.chdir(project.conf_dir(version.slug)) if project.use_virtualenv and project.whitelisted: latex_results = run('%s -b latex -d _build/doctrees . _build/latex' % project.venv_bin(version=version.slug, bin='sphinx-build')) else: latex_results = run('sphinx-build -b latex ' '-d _build/doctrees . _build/latex') if latex_results[0] == 0: os.chdir('_build/latex') tex_globs = glob('*.tex') if tex_globs: tex_file = tex_globs[0] else: return False pdf_results = run('pdflatex -interaction=nonstopmode %s' % tex_file) pdf_match = pdf_re.search(pdf_results[1]) if pdf_match: to_path = os.path.join(settings.MEDIA_ROOT, 'pdf', project.slug, version.slug) from_file = os.path.join(os.getcwd(), "*.pdf") to_file = os.path.join(to_path, '%s.pdf' % project.slug) if getattr(settings, "MULTIPLE_APP_SERVERS", None): copy_file_to_app_servers(from_file, to_file) else: if not os.path.exists(to_path): os.makedirs(to_path) run('mv -f %s %s' % (from_file, to_file)) else: print "PDF Building failed. Moving on." return latex_results
def move(self, version): project = version.project outputted_path = os.path.join(project.conf_dir(version.slug), '_build', 'epub') to_path = os.path.join(settings.MEDIA_ROOT, 'epub', project.slug, version.slug) from_file = os.path.join(outputted_path, "*.epub") to_file = os.path.join(to_path, "%s.epub" % project.slug) if getattr(settings, "MULTIPLE_APP_SERVERS", None): copy_file_to_app_servers(from_file, to_file) else: if not os.path.exists(to_path): os.makedirs(to_path) run('mv -f %s %s' % (from_file, to_file))