add rough pdf transformation

This commit is contained in:
Frédéric Péters 2013-08-12 14:36:28 +02:00
parent d7be510325
commit bf2d556e4b
1 changed files with 38 additions and 0 deletions

View File

@ -2,8 +2,10 @@
import json
import os
import shutil
import subprocess
import tarfile
import tempfile
import urllib2
import urlparse
@ -74,6 +76,42 @@ def publish_mallard(module, branch, directory):
if html_files:
os.symlink(html_files[0], index_html)
if not os.path.exists('../mal2latex'):
return
temp_dir = tempfile.mkdtemp()
cache_file = os.path.join(temp_dir, '%s.cache' % module)
cmd = ['jhbuild', '-f', jhbuildrc, 'run', 'yelp-build', 'cache', '-o', cache_file]
cmd.extend([os.path.join(help_dir, x) for x in os.listdir(help_dir) if x.endswith('.page')])
subprocess.call(cmd, **kws)
if os.path.exists(cache_file):
latex_file = os.path.join(temp_dir, 'doc-%s.tex' % module)
cmd = ['xsltproc', '-o', latex_file, '../mal2latex/mal2latex.xsl',
cache_file]
subprocess.call(cmd, **kws)
for subdir in ('media', 'figures'):
os.symlink(os.path.join(checkout_dir, 'help', 'fr', subdir),
os.path.join(temp_dir, subdir))
for admon_file in os.listdir('../mal2latex/admon'):
if not admon_file.endswith('.pdf'):
continue
os.symlink(os.path.join(os.path.abspath('../mal2latex'), 'admon', admon_file),
os.path.join(temp_dir, admon_file))
for i in range(3):
cmd = ['pdflatex', '--interaction=nonstopmode',
'-output-directory', temp_dir, latex_file]
subprocess.call(cmd, cwd=temp_dir, **kws)
if not os.path.exists(os.path.join(temp_dir, 'doc-%s.pdf' % module)):
print 'failed to produce pdf for', module
break
else:
fd = file(os.path.join(output_dir, 'doc-%s.pdf' % module), 'w')
fd.write(file(os.path.join(temp_dir, 'doc-%s.pdf' % module)).read())
fd.close()
shutil.rmtree(temp_dir)
def publish_tarball(module):
output_dir = os.path.join(web_directory, module.get('name'), 'stable')