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

Last change on this file since 4786 was 4786, checked in by ole, 17 years ago

Moved major revision info to anuga_config, updated scripts and made userguide include build number in its header.

  • Property svn:executable set to *
File size: 2.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
18
19SHELL=/bin/sh
20PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:~/bin
21
22# m h dom mon dow command
23  42 *  *   *   *  ~/inundation/anuga_core/documentation/user_manual/update_anuga_user_manual.py > ~/inundation/anuga_core/documentation/user_manual/update_anuga.log
24#
25
26
27Note UNIX only
28 
29"""
30
31from os import system, chdir
32from os.path import expanduser
33from anuga.abstract_2d_finite_volumes.util import get_revision_number
34from anuga.anuga_config import major_revision
35from sys import argv
36
37
38anugapath = expanduser('~/inundation/anuga_core/documentation/user_manual')
39texfiles = ['anuga_user_manual', 'anuga_installation_guide']
40
41chdir(anugapath) # Move to location of LaTeX files
42system('svn update') # Update from svn
43
44
45do_html = True       
46if len(argv) > 1:
47    if argv[1] == '--no_html':
48        do_html = False
49    else:
50        msg = 'Unknown option: %s' %argv[1]
51        raise Exception(msg)
52
53# Update version info
54fid = open('version.tex')
55lines = []
56for line in fid.readlines():
57    if line.startswith('\\release'):
58        line = '\\release{%s\\_%d}\n' %(major_revision,
59                                       get_revision_number())
60    lines.append(line)
61fid.close()
62
63fid = open('version.tex', 'w')
64fid.writelines(lines)
65fid.close()
66
67print 'Updated version info:'
68for line in lines:   
69    print line.strip()
70
71#print 'Major revision', major_revision
72#print 'build', get_revision_number()
73
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
Note: See TracBrowser for help on using the repository browser.