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

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

Fiddling with layout of user guide.

  • 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
60print 'Moving to', docpath
61chdir(docpath) # Move to location of LaTeX files
62system('svn update') # Update from svn
63
64
65do_html = True       
66if len(argv) > 1:
67    if argv[1] == '--no_html':
68        do_html = False
69    else:
70        msg = 'Unknown option: %s' %argv[1]
71        raise Exception(msg)
72
73# Update version info
74fid = open('version.tex')
75lines = []
76for line in fid.readlines():
77    if line.startswith('\\release'):
78        try:
79            line = '\\release{%s\\_%d}\n' %(major_revision,
80                                            get_revision_number())
81        except:
82            line = '\\release{%s}\n' %(major_revision)
83           
84    lines.append(line)
85fid.close()
86
87fid = open('version.tex', 'w')
88fid.writelines(lines)
89fid.close()
90
91print 'Updated version info:'
92for line in lines:   
93    print line.strip()
94
95for texfile in texfiles:
96    print 'Processing %s' %texfile
97    # Compile with LaTeX, makeindex etc
98    for i in range(3):
99        #system('latex --interaction=nonstopmode %s.tex' %texfile)
100        system('pdflatex --interaction=nonstopmode -file-line-error %s.tex' %texfile)
101        system('makeindex %s.idx' %texfile)
102        system('makeindex mod%s.idx' %texfile)
103        system('bibtex %s' %texfile)   
104
105    # Create pdf file
106    #system('dvips %s -o %s.ps' %((texfile,)*2))   
107    #system('ps2pdf %s.ps' %texfile)   
108     
109    # Create html pages
110    if do_html is True:
111        system('latex2html %s' %texfile)
112    else:
113        print 'Skipping html version for %s as requested' %texfile
114
115# Clean-up
116system('/bin/rm version.tex')
117system('svn update') # Restore version file
118
119
120# Print
121print 'User manual compiled'
122
123print 'Major revision:', major_revision
124print 'Build:', get_revision_number()
125system('date')
126
Note: See TracBrowser for help on using the repository browser.