source: create_distribution.py @ 4939

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

Moved data_audit to utilities

Caching work on Joaquim Luis example

File size: 7.2 KB
Line 
1"""Create a distribution of ANUGA from latest revision
2
3   This script is assumed to be run in the root directory of anuga
4   from a working sandpit connected to svn
5
6   It will create a distribution of ANUGA from the version which is
7   currently checked out.
8
9   To use the latest version run
10
11     svn up
12
13   before running this script. To use a specific revision (2187, say) run
14
15     svn up -r 2187
16
17   first assuming that create_distribution.py (this script) and anything
18   it depends on still work for that revision.
19
20   This script works only on Linux
21"""
22
23from os import sep, system
24from string import join
25from tempfile import mktemp
26from sys import platform, stdout
27from anuga.utilities.system_tools import get_user_name, get_host_name
28from anuga.abstract_2d_finite_volumes.util import get_revision_number
29from anuga.abstract_2d_finite_volumes.util import store_version_info
30from anuga.anuga_config import major_revision
31
32from anuga.utilities.data_audit import identify_data_files
33
34
35if platform == 'win32':
36    msg = 'This script is not written for Windows.'+\
37          'Please run it on a Unix platform'
38    raise Exception, msg
39
40
41# line separator
42lsep = '----------------------------------------------------------------------'
43
44
45# Get svn revision number and create
46# file with version info for release.
47# This will mean that the version currently checked out is
48# the one which will be released.
49
50svn_revision = get_revision_number()
51revision = '%s_%s' %(major_revision, svn_revision)
52print 'Creating ANUGA revision %s' %revision
53
54distro_filename = 'anuga-%s.tgz' %revision
55
56#-----------------------------------
57# Create directory for this release.
58# It will be named like
59#        anuga_release_1.0beta_4824
60#-----------------------------------
61release_dir = '~/anuga_release_%s' %revision
62s = 'mkdir %s' %release_dir
63try:
64    print s   
65    system(s)
66except:
67    pass
68
69#-----------------------------------------------------
70# Create temporary area for svn to export source files
71#-----------------------------------------------------
72distro_dir = mktemp()
73s = 'mkdir %s' %distro_dir
74print s   
75system(s)
76
77#--------------------------------
78# Get the ANUGA core source files
79#--------------------------------
80s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision,
81                                                          distro_dir) 
82print s
83system(s)
84
85# Store file with revision info for use with get_revision_number
86store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
87
88
89#-----------------------------
90# Get validation_files as well
91#-----------------------------
92s = 'mkdir %s/anuga_validation' %distro_dir
93system(s)
94
95s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\
96    %(distro_dir) 
97print s
98system(s)
99
100s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
101    %(distro_dir)
102print s
103system(s)
104
105s = 'svn export anuga_validation/automated_validation_tests %s/anuga_validation/automated_validation_tests'\
106    %(distro_dir) 
107print s
108system(s)
109
110# FIXME: Other validations in here as they appear!
111
112
113#---------------------------
114# Get demos from user manual
115#---------------------------
116s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\
117    %(distro_dir) 
118print s
119system(s)
120
121
122identify_data_files(distro_dir)
123
124
125#------------------
126# Zip everything up
127#------------------
128s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
129print s
130system(s)
131
132#----------------------------
133# Move distro to release area
134#----------------------------
135s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
136print s
137system(s)
138
139#---------
140# Clean up
141#---------
142s = '/bin/rm -rf %s/*' %(distro_dir) 
143print s
144system(s)
145
146
147#-----------------------------
148# Copy and rename anuga_viewer
149#-----------------------------
150s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision)
151print s
152system(s)
153
154#----------------------------
155# Move viewer to release area
156#----------------------------
157s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
158print s
159system(s)
160
161
162
163#----------------------------------------------
164# Compile and bundle up the LaTeX documentation
165#----------------------------------------------
166print
167print lsep
168print 'Preparing User Manual (see update_anuga_user_manual.log)'
169print lsep
170s = 'cd anuga_core/documentation/user_manual;'
171s += 'python update_anuga_user_manual.py --no_html'
172print s
173system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')
174
175release_name = 'anuga_user_manual-%s.pdf' %revision
176s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
177    %(release_dir, release_name)
178print s
179system(s)
180
181release_name = 'anuga_installation_guide-%s.pdf' %revision
182s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name)   
183   
184print s
185system(s)
186
187
188#----------------------------
189# Print list of release files
190#----------------------------
191print 'Done'
192print
193print
194print lsep
195print 'The release files are in %s:' %release_dir
196system('ls -la %s' %release_dir)
197print lsep
198print
199print
200
201
202#-------------------------------------
203# Copy release to various destinations
204#-------------------------------------
205answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]')
206if answer.lower() != 'n':
207   
208    print 'Uploading to sourceforge'
209
210    import os, os.path
211    release_dir = os.path.expanduser(release_dir)
212    os.chdir(release_dir)
213    print 'Reading from', os.getcwd()
214
215
216    from ftplib import FTP
217    ftp = FTP('upload.sourceforge.net')
218    print ftp.login() # Anonymous
219    print ftp.cwd('incoming')
220
221
222    for filename in os.listdir('.'):
223        print 'Uploading %s... ' %filename,
224        stdout.flush()
225
226        fid=open(filename, 'rb')
227        print ftp.storbinary('STOR %s' %filename, fid)
228        fid.close()
229
230    print 'FTP done'
231    print ftp.quit()
232
233    print
234    print lsep
235    print '    ********************* NOTE *************************'
236    print lsep
237    print 'To complete this release you must log into'
238    print 'http://sourceforge.net/projects/anuga as ANUGA admin'
239    print 'and complete the process by selecting File Releases '
240    print 'in the admin menu there.'
241    print lsep
242    print
243    print
244   
245
246
247#----------------------------
248# Throw away code to drop all files into the RAMP download area
249# This is hardwired for Ole but shows how such a thing can be done
250# automatically.
251
252if get_user_name() == 'ole' and get_host_name() == 'nautilus':
253
254
255    answer = raw_input('Do you want to move this to perlite and ANU? Y/N [Y]')
256    if answer.lower() == 'n':
257        import sys; sys.exit()
258
259       
260    #------------------------------
261    print 'Uploading to sourceforge'
262
263
264   
265
266    print 'Attempt to rsync data to perlite and datamining'
267    # Copy to NHIP
268    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
269    print s
270    system(s)
271   
272    #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
273
274
275    # Copy to the ANU
276    #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
277    #print s
278    #system(s)
279   
280   
Note: See TracBrowser for help on using the repository browser.