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