forked from DIRACGrid/-obsolete-DIRACWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirac-postInstall.py
executable file
·66 lines (57 loc) · 2.01 KB
/
dirac-postInstall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File : dirac-postInstall.py
# Author : Ricardo Graciani
########################################################################
__RCSID__ = "$Id$"
import os
import sys
import urllib2
import zipfile
basedir = sys.path[0]
dataDir = os.path.join( basedir, 'data', 'production' )
if not os.path.isdir( dataDir ):
os.makedirs( dataDir, mode = 0777 )
publicDir = os.path.join( basedir, 'dirac', 'public' )
jsTarballsDir = os.path.join( basedir, 'tarballs', 'js' )
for comp in ['ext', 'yui']:
print "Deploying %s" % comp
tarName = os.path.join( jsTarballsDir, '%s.tar.bz2' % comp )
if not os.path.isdir( os.path.join( publicDir, comp ) ):
if os.system( 'tar xjf %s -C %s' % ( tarName, publicDir ) ):
sys.exit( 1 )
tarName = os.path.join( basedir, 'tarballs', 'images', 'flags.tar.gz' )
if os.system( 'tar xzf %s -C %s' % ( tarName, os.path.join( publicDir, 'images' ) ) ):
sys.exit( 1 )
downDir = os.path.join( basedir, "tarballs", "down" )
if not os.path.isdir( downDir ):
os.makedirs( downDir )
#Get Ext 4.0
extFilePath = os.path.join( downDir, "ext-4.0.0-gpl.zip" )
if not os.path.isfile( extFilePath ):
print "Downloading ExtJS4..."
try:
remFile = urllib2.urlopen( "http://extjs.cachefly.net/ext-4.0.0-gpl.zip", "rb" )
except Exception, excp:
print "Cannot download extjs 4!", excp
sys.exit( 1 )
locFile = open( extFilePath, "wb" )
remData = remFile.read( 1024 * 1024 )
spinner = "|/-=-\\"
count = 0
while remData:
print "%s\r" % spinner[count % len( spinner )],
sys.stdout.flush()
locFile.write( remData )
remData = remFile.read( 1024 * 1024 )
count += 1
locFile.close()
remFile.close()
print "Installing ExtJS 4"
zFile = zipfile.ZipFile( extFilePath )
zFile.extractall( publicDir )
locationPath = os.path.join( publicDir, "ext4" )
if os.path.isdir( locationPath ):
shutil.rmtree( locationPath )
os.rename( os.path.join( publicDir, "ext-4.0.0" ), locationPath )