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

Last change on this file since 5422 was 5422, checked in by ole, 16 years ago

Allowed update_anuga_user_manual to work out path automatically using 'get_pathname_from_package'.

  • Property svn:executable set to *
File size: 2.9 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, split, join
37from anuga.utilities.system_tools import get_revision_number, get_pathname_from_package
38from anuga.config import major_revision
39from sys import argv
40
41# Determine absolute path for user manual
42
43# Path for ANUGA
44anugapath = get_pathname_from_package('anuga')
45
46# Strip trailing source/anuga of path
47basepath = split(split(anugapath)[0])[0]
48
49# Add local path to user_manual
50docpath = join(join(basepath, 'documentation'), 'user_manual')
51texfiles = ['anuga_user_manual', 'anuga_installation_guide']
52
53print 'Moving to', docpath
54chdir(docpath) # Move to location of LaTeX files
55system('svn update') # Update from svn
56
57
58do_html = True       
59if len(argv) > 1:
60    if argv[1] == '--no_html':
61        do_html = False
62    else:
63        msg = 'Unknown option: %s' %argv[1]
64        raise Exception(msg)
65
66# Update version info
67fid = open('version.tex')
68lines = []
69for line in fid.readlines():
70    if line.startswith('\\release'):
71        line = '\\release{%s\\_%d}\n' %(major_revision,
72                                       get_revision_number())
73    lines.append(line)
74fid.close()
75
76fid = open('version.tex', 'w')
77fid.writelines(lines)
78fid.close()
79
80print 'Updated version info:'
81for line in lines:   
82    print line.strip()
83
84for texfile in texfiles:
85    print 'Processing %s' %texfile
86    # Compile with LaTeX, makeindex etc
87    for i in range(3):
88        #system('latex --interaction=nonstopmode %s.tex' %texfile)
89        system('pdflatex --interaction=nonstopmode %s.tex' %texfile)
90        system('makeindex %s.idx' %texfile)
91        system('makeindex mod%s.idx' %texfile)
92        system('bibtex %s' %texfile)   
93
94    # Create pdf file
95    #system('dvips %s -o %s.ps' %((texfile,)*2))   
96    #system('ps2pdf %s.ps' %texfile)   
97     
98    # Create html pages
99    if do_html is True:
100        system('latex2html %s' %texfile)
101    else:
102        print 'Skipping html version for %s as requested' %texfile
103
104# Clean-up
105system('/bin/rm version.tex')
106system('svn update') # Restore version file
107
108
109# Print
110print 'User manual compiled'
111
112print 'Major revision:', major_revision
113print 'Build:', get_revision_number()
114system('date')
115
Note: See TracBrowser for help on using the repository browser.