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

Last change on this file since 5512 was 5512, checked in by ole, 16 years ago

added what's new to automatic update

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