source: anuga_core/documentation/user_manual/update_anuga_user_manual.py @ 5051

Last change on this file since 5051 was 5051, checked in by ole, 15 years ago

More license files and cleanup in user manual area

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/usr/bin/env python
2
3"""Update, compile and create PDF and HTML from LaTeX file
4
5Usage:
6    python update_anuga_user_manual.py <options>
7   
8Options:
9    --no_html: Skip automatic generation of html version
10   
11
12
13This script can for example be run from a cronjob:
14
15  crontab -e
16
17with content like
18
19SHELL=/bin/sh
20PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:~/bin
21PYTHONPATH=.:/home/ole/inundation/anuga_core/source:/home/ole/lib/python/site-packages:
22
23# m h dom mon dow command
24  32 6,10,14,18,22  *   *   *  ~/inundation/anuga_core/documentation/user_manual/update_anuga_user_manual.py > ~/inundation/anuga_core/documentation/user_manual/update_anuga.log
25  #
26   
27
28Check function of crontab by reading mail using e.g. mutt   
29   
30   
31Note UNIX only
32 
33"""
34
35from os import system, chdir
36from os.path import expanduser
37from anuga.utilities.system_tools import get_revision_number
38from anuga.config import major_revision
39from sys import argv
40
41
42anugapath = expanduser('~/inundation/anuga_core/documentation/user_manual')
43texfiles = ['anuga_user_manual', 'anuga_installation_guide']
44
45chdir(anugapath) # Move to location of LaTeX files
46system('svn update') # Update from svn
47
48
49do_html = True       
50if len(argv) > 1:
51    if argv[1] == '--no_html':
52        do_html = False
53    else:
54        msg = 'Unknown option: %s' %argv[1]
55        raise Exception(msg)
56
57# Update version info
58fid = open('version.tex')
59lines = []
60for line in fid.readlines():
61    if line.startswith('\\release'):
62        line = '\\release{%s\\_%d}\n' %(major_revision,
63                                       get_revision_number())
64    lines.append(line)
65fid.close()
66
67fid = open('version.tex', 'w')
68fid.writelines(lines)
69fid.close()
70
71print 'Updated version info:'
72for line in lines:   
73    print line.strip()
74
75for texfile in texfiles:
76    print 'Processing %s' %texfile
77    # Compile with LaTeX, makeindex etc
78    for i in range(3):
79        #system('latex --interaction=nonstopmode %s.tex' %texfile)
80        system('pdflatex --interaction=nonstopmode %s.tex' %texfile)
81        system('makeindex %s.idx' %texfile)
82        system('makeindex mod%s.idx' %texfile)
83        system('bibtex %s' %texfile)   
84
85    # Create pdf file
86    #system('dvips %s -o %s.ps' %((texfile,)*2))   
87    #system('ps2pdf %s.ps' %texfile)   
88     
89    # Create html pages
90    if do_html is True:
91        system('latex2html %s' %texfile)
92    else:
93        print 'Skipping html version for %s as requested' %texfile
94
95# Clean-up
96system('/bin/rm version.tex')
97system('svn update') # Restore version file
98
99
100# Print
101print 'User manual compiled'
102
103print 'Major revision:', major_revision
104print 'Build:', get_revision_number()
105system('date')
106
Note: See TracBrowser for help on using the repository browser.