Reviewed all *inter*Foam tutorials
[foam-extend-3.0.git] / bin / foamBuildTarball.py
blobcddc9e800830929fc5e4c98c2ba555d9f09e2031
1 #! /usr/bin/python
3 import sys,re
4 from os import path
5 from subprocess import Popen,PIPE,call
6 import tarfile
8 if len(sys.argv)!=2:
9 print "Error: SVN-Url is needed"
10 sys.exit(-1)
12 url=sys.argv[1]
14 name=path.basename(url[:-1])
16 p=Popen(["svn","info",url],stdin=PIPE, stdout=PIPE, close_fds=True)
18 (child_stdout, child_stdin) = (p.stdout, p.stdin)
20 revision=-1
22 for l in child_stdout.readlines():
23 m=re.compile("Last Changed Rev: (.+)").match(l)
24 if m!=None:
25 revision=int(m.group(1))
27 if revision<0:
28 print "Invalid URL or stuff"
29 sys.exit(-1)
31 fullname="%s.r%d" % (name,revision)
33 print "Generating",fullname
35 retcode=call(["svn","export",url,fullname])
36 if retcode!=0:
37 print "Problem. Returncode",retcode
38 sys.exit(-1)
40 print "Tarring ...."
41 tar=tarfile.open(fullname+".tgz","w:gz")
42 tar.add(fullname,arcname=name)
43 tar.close()
44 print "Removing directory"
45 retcode=call(["rm","-rf",fullname])
46 print "Finished"