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