5 import shutil, os, sys, subprocess, tempfile, tarfile, glob, ConfigParser
6 pathjoin = os.path.join
9 tmpout = tempfile.TemporaryFile()
10 subprocess.Popen(['yui-compressor', path], stdout=tmpout).communicate()
12 with open(path, 'w') as output:
13 output.write(tmpout.read())
16 tmpdir = tempfile.mkdtemp()
18 # copy scripts OpenLayers.js
19 for path in glob.glob('public/js/*.js'):
20 shutil.copy(path, tmpdir)
23 subprocess.call(['python', 'buildUncompressed.py',
24 pathjoin(os.getcwd(), "scripts/syj"), pathjoin(tmpdir, "OpenLayers.js")],
25 cwd = 'public/openlayers/openlayers/build')
27 config = ConfigParser.ConfigParser()
28 os.makedirs(pathjoin(__BUILD__, 'public/js'))
29 config.readfp(open('application/configs/medias.ini'))
30 for key, value in config.items('production'):
31 if key.startswith('scripts.'):
32 outpath = pathjoin(__BUILD__, 'public/js/' + key[len('scripts.'):] + '.js')
33 with open(outpath, 'w') as output:
34 for inpath in map(lambda p: pathjoin(tmpdir, p.strip() + '.js'), value.split(',')):
35 with open(inpath) as f:
36 output.write(f.read())
40 def install(source, target):
44 if os.path.isdir(source):
47 buildtarget = pathjoin(__BUILD__, target)
48 parentdir = os.path.normpath(pathjoin(buildtarget, '..'))
49 if not os.path.isdir(parentdir):
50 os.makedirs(parentdir)
51 shutil.copytree(source, buildtarget)
53 elif os.path.exists(source):
55 target = os.path.dirname(source)
56 buildtarget = os.path.normpath(pathjoin(__BUILD__, target))
57 if not os.path.isdir(buildtarget):
58 os.makedirs(buildtarget)
59 shutil.copy(source, buildtarget)
62 for item in glob.glob(source):
66 if os.path.isdir(__BUILD__):
67 shutil.rmtree(__BUILD__, False)
71 for path in glob.glob('public/css/*.css'):
73 compress(pathjoin(__BUILD__, 'public/css', os.path.basename(path)))
75 with open("scripts/syj.install") as f:
77 line = line.split('#')[0].strip()
81 parts = line.split(' ')
89 install(source, target)
91 print "creating syj.tar.gz"
92 targz = tarfile.open("build/syj.tar.gz", "w:gz")
93 for path in glob.glob(pathjoin(__BUILD__, '*')):