1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | """Update, compile and create PDF and HTML from LaTeX file |
---|
4 | |
---|
5 | Usage: |
---|
6 | python update_anuga_user_manual.py <options> |
---|
7 | |
---|
8 | Options: |
---|
9 | --no_html: Skip automatic generation of html version |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | This script can for example be run from a cronjob: |
---|
14 | |
---|
15 | crontab -e |
---|
16 | |
---|
17 | with content |
---|
18 | |
---|
19 | SHELL=/bin/sh |
---|
20 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:~/bin |
---|
21 | |
---|
22 | # m h dom mon dow command |
---|
23 | 42 * * * * ~/inundation/anuga_core/documentation/user_manual/update_anuga_user_manual.py > ~/inundation/anuga_core/documentation/user_manual/update_anuga.log |
---|
24 | # |
---|
25 | |
---|
26 | |
---|
27 | Note UNIX only |
---|
28 | |
---|
29 | """ |
---|
30 | |
---|
31 | from os import system, chdir |
---|
32 | from os.path import expanduser |
---|
33 | from anuga.abstract_2d_finite_volumes.util import get_revision_number |
---|
34 | from sys import argv |
---|
35 | |
---|
36 | |
---|
37 | anugapath = expanduser('~/inundation/anuga_core/documentation/user_manual') |
---|
38 | texfiles = ['anuga_user_manual', 'anuga_installation_guide'] |
---|
39 | |
---|
40 | chdir(anugapath) # Move to location of LaTeX files |
---|
41 | system('svn update') # Update from svn |
---|
42 | |
---|
43 | |
---|
44 | do_html = True |
---|
45 | if len(argv) > 1: |
---|
46 | if argv[1] == '--no_html': |
---|
47 | do_html = False |
---|
48 | else: |
---|
49 | msg = 'Unknown option: %s' %argv[1] |
---|
50 | raise Exception(msg) |
---|
51 | |
---|
52 | for texfile in texfiles: |
---|
53 | print 'Processing %s' %texfile |
---|
54 | # Compile with LaTeX, makeindex etc |
---|
55 | for i in range(3): |
---|
56 | #system('latex --interaction=nonstopmode %s.tex' %texfile) |
---|
57 | system('pdflatex --interaction=nonstopmode %s.tex' %texfile) |
---|
58 | system('makeindex %s.idx' %texfile) |
---|
59 | system('makeindex mod%s.idx' %texfile) |
---|
60 | system('bibtex %s' %texfile) |
---|
61 | |
---|
62 | # Create pdf file |
---|
63 | #system('dvips %s -o %s.ps' %((texfile,)*2)) |
---|
64 | #system('ps2pdf %s.ps' %texfile) |
---|
65 | |
---|
66 | # Create html pages |
---|
67 | if do_html is True: |
---|
68 | system('latex2html %s' %texfile) |
---|
69 | else: |
---|
70 | print 'Skipping html version for %s as requested' %texfile |
---|
71 | |
---|