[2733] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
[2736] | 3 | """Update, compile and create PDF and HTML from LaTeX file |
---|
| 4 | |
---|
[3921] | 5 | Usage: |
---|
| 6 | python update_anuga_user_manual.py <options> |
---|
| 7 | |
---|
| 8 | Options: |
---|
| 9 | --no_html: Skip automatic generation of html version |
---|
| 10 | |
---|
[2736] | 11 | |
---|
[3921] | 12 | |
---|
| 13 | This script can for example be run from a cronjob: |
---|
| 14 | |
---|
[2736] | 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 * * * * ~/anuga/documentation/user_manual/update_anuga_user_manual.py > ~/anuga/documentation/user_manual/update_anuga.log |
---|
| 24 | # |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | Note UNIX only |
---|
| 28 | |
---|
| 29 | """ |
---|
| 30 | |
---|
[3921] | 31 | from os import system, chdir |
---|
| 32 | from os.path import expanduser |
---|
[2736] | 33 | |
---|
[3921] | 34 | from sys import argv |
---|
[2733] | 35 | |
---|
| 36 | |
---|
[3921] | 37 | anugapath = expanduser('~/inundation/anuga_core/documentation/user_manual') |
---|
[3107] | 38 | texfiles = ['anuga_user_manual', 'anuga_installation_guide'] |
---|
[2733] | 39 | |
---|
[3921] | 40 | chdir(anugapath) # Move to location of LaTeX files |
---|
| 41 | system('svn update') # Update from svn |
---|
[2733] | 42 | |
---|
| 43 | |
---|
[3921] | 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 | |
---|
[3107] | 52 | for texfile in texfiles: |
---|
| 53 | print 'Processing %s' %texfile |
---|
| 54 | # Compile with LaTeX, makeindex etc |
---|
| 55 | for i in range(3): |
---|
[3934] | 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) |
---|
[3107] | 61 | |
---|
| 62 | # Create pdf file |
---|
[3934] | 63 | #system('dvips %s -o %s.ps' %((texfile,)*2)) |
---|
| 64 | #system('ps2pdf %s.ps' %texfile) |
---|
[2733] | 65 | |
---|
[3921] | 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 |
---|
[2733] | 71 | |
---|