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

Last change on this file since 7828 was 7189, checked in by rwilson, 15 years ago

Changes to the user manual.

  • Property svn:executable set to *
File size: 3.3 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 major_revision
44from sys import argv
45
46# Determine absolute path for user manual
47
48# Path for ANUGA
49anugapath = get_pathname_from_package('anuga')
50
51# Strip trailing source/anuga of path
52basepath = split(split(anugapath)[0])[0]
53
54# Add local path to user_manual
55docpath = join(join(basepath, 'documentation'), 'user_manual')
56texfiles = ['anuga_user_manual', 
57            'anuga_installation_guide',
58            'anuga_whats_new',
59            'anuga_internal_tools']
60
61print 'Moving to', docpath
62chdir(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        try:
80            line = '\\release{%s\\_%d}\n' %(major_revision,
81                                            get_revision_number())
82        except:
83            line = '\\release{%s}\n' %(major_revision)
84           
85    lines.append(line)
86fid.close()
87
88fid = open('version.tex', 'w')
89fid.writelines(lines)
90fid.close()
91
92print 'Updated version info:'
93for line in lines:   
94    print line.strip()
95
96for texfile in texfiles:
97    print 'Processing %s' %texfile
98    # Compile with LaTeX, makeindex etc
99    for i in range(3):
100        #system('latex --interaction=nonstopmode %s.tex' %texfile)
101        system('pdflatex --interaction=nonstopmode -file-line-error %s.tex' %texfile)
102        system('makeindex %s.idx' %texfile)
103        system('makeindex mod%s.idx' %texfile)
104        system('bibtex %s' %texfile)   
105
106    # Create pdf file
107    #system('dvips %s -o %s.ps' %((texfile,)*2))   
108    #system('ps2pdf %s.ps' %texfile)   
109     
110    # Create html pages
111    if do_html is True:
112        system('latex2html %s' %texfile)
113    else:
114        print 'Skipping html version for %s as requested' %texfile
115
116# Clean-up
117system('/bin/rm version.tex')
118system('svn update') # Restore version file
119
120
121# Print
122print 'User manual compiled'
123
124print 'Major revision:', major_revision
125print 'Build:', get_revision_number()
126system('date')
127
Note: See TracBrowser for help on using the repository browser.