source: trunk/anuga_core/documentation/user_manual/update_anuga_user_manual.py @ 7951

Last change on this file since 7951 was 7951, checked in by habili, 14 years ago

Manual updated to reflect changes in 1.2.0

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