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

Last change on this file since 5514 was 5514, checked in by ole, 15 years ago

Updated user manual and create distribution

  • 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 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        line = '\\release{%s\\_%d}\n' %(major_revision,
79                                       get_revision_number())
80    lines.append(line)
81fid.close()
82
83fid = open('version.tex', 'w')
84fid.writelines(lines)
85fid.close()
86
87print 'Updated version info:'
88for line in lines:   
89    print line.strip()
90
91for texfile in texfiles:
92    print 'Processing %s' %texfile
93    # Compile with LaTeX, makeindex etc
94    for i in range(3):
95        #system('latex --interaction=nonstopmode %s.tex' %texfile)
96        system('pdflatex --interaction=nonstopmode %s.tex' %texfile)
97        system('makeindex %s.idx' %texfile)
98        system('makeindex mod%s.idx' %texfile)
99        system('bibtex %s' %texfile)   
100
101    # Create pdf file
102    #system('dvips %s -o %s.ps' %((texfile,)*2))   
103    #system('ps2pdf %s.ps' %texfile)   
104     
105    # Create html pages
106    if do_html is True:
107        system('latex2html %s' %texfile)
108    else:
109        print 'Skipping html version for %s as requested' %texfile
110
111# Clean-up
112system('/bin/rm version.tex')
113system('svn update') # Restore version file
114
115
116# Print
117print 'User manual compiled'
118
119print 'Major revision:', major_revision
120print 'Build:', get_revision_number()
121system('date')
122
Note: See TracBrowser for help on using the repository browser.