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
RevLine 
[2733]1#!/usr/bin/env python
2
[2736]3"""Update, compile and create PDF and HTML from LaTeX file
4
[3921]5Usage:
6    python update_anuga_user_manual.py <options>
7   
8Options:
9    --no_html: Skip automatic generation of html version
10   
[2736]11
[3921]12
13This script can for example be run from a cronjob:
14
[2736]15  crontab -e
16
[4801]17with content like
[2736]18
19SHELL=/bin/sh
20PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:~/bin
[4801]21PYTHONPATH=.:/home/ole/inundation/anuga_core/source:/home/ole/lib/python/site-packages:
[2736]22
23# m h dom mon dow command
[4801]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   
[2736]27
[4801]28Check function of crontab by reading mail using e.g. mutt   
29   
30   
[2736]31Note UNIX only
32 
33"""
34
[3921]35from os import system, chdir
[5422]36from os.path import expanduser, split, join
37from anuga.utilities.system_tools import get_revision_number, get_pathname_from_package
[5051]38from anuga.config import major_revision
[3921]39from sys import argv
[2733]40
[5422]41# Determine absolute path for user manual
[2733]42
[5422]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')
[5512]51texfiles = ['anuga_user_manual', 
52            'anuga_installation_guide',
53            'anuga_whats_new']
[2733]54
[5422]55print 'Moving to', docpath
56chdir(docpath) # Move to location of LaTeX files
[3921]57system('svn update') # Update from svn
[2733]58
59
[3921]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)
[4786]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
[3107]86for texfile in texfiles:
87    print 'Processing %s' %texfile
88    # Compile with LaTeX, makeindex etc
89    for i in range(3):
[3934]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)   
[3107]95
96    # Create pdf file
[3934]97    #system('dvips %s -o %s.ps' %((texfile,)*2))   
98    #system('ps2pdf %s.ps' %texfile)   
[2733]99     
[3921]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
[2733]105
[4788]106# Clean-up
107system('/bin/rm version.tex')
[4789]108system('svn update') # Restore version file
109
110
111# Print
[4790]112print 'User manual compiled'
[4789]113
[4790]114print 'Major revision:', major_revision
115print 'Build:', get_revision_number()
116system('date')
[4789]117
Note: See TracBrowser for help on using the repository browser.