source: create_distribution.py @ 4931

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

Factored the data_audit skeleton out as a separate script.
More to come

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