annotate LightTools/release.py @ 46:a379bce1aeb1

Rename map.py to build.py; Add release script
author koryspansel
date Thu, 22 Sep 2011 14:35:35 -0700
parents
children 81d413160824
rev   line source
46
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
1 #
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
2 # release
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
3 #
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
4
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
5 from os.path import join, isdir, isfile, dirname, basename, normpath
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
6
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
7 import tempfile
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
8 import os
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
9 import sys
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
10 import shutil
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
11 import zipfile
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
12 import datetime
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
13
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
14 def relative_walk(path):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
15 for root, folders, files in os.walk(path):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
16 for filename in files:
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
17 yield join(root, filename)[len(path)+1:]
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
18
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
19 def release_project(root, location, project, target=None, build='Build'):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
20 if target:
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
21 executable = join(root, project, 'bin', target, project + '.exe')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
22
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
23 else:
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
24 executable = join(root, project, 'bin', 'release', project + '.exe')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
25 if not isfile(executable):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
26 executable = join(root, project, 'bin', 'debug', project + '.exe')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
27
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
28 if not isfile(executable):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
29 raise Exception('Error: Could not locate executable')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
30
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
31 data = join(root, 'data')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
32
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
33 if not isdir(data):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
34 raise Exception('Error: Could not locate data folder')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
35
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
36 if isdir(build):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
37 shutil.rmtree(build, True)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
38
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
39 os.makedirs(build)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
40
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
41 shutil.copyfile(executable, join(build, basename(executable)))
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
42
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
43 for filename in relative_walk(data):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
44 filepath = join(build, filename)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
45
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
46 if not isdir(dirname(filepath)):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
47 os.makedirs(dirname(filepath))
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
48
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
49 shutil.copyfile(join(data, filename), filepath)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
50
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
51 if not isdir(location):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
52 os.makedirs(location)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
53
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
54 current_date = datetime.datetime.now()
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
55 suffix = current_date.strftime('%Y%m%d%I%M%p')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
56 print suffix
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
57
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
58 with zipfile.ZipFile(join(location, project + '.zip'), 'w') as handle:
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
59 for filename in relative_walk(build):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
60 handle.write(join(build, filename), filename)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
61
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
62 if __name__ == '__main__':
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
63 root = normpath(join(dirname(sys.argv[0]), '..'))
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
64
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
65 release_project(root, '..\Release', 'LightClone')