annotate LightTools/release.py @ 75:57c0ce406a68 tip

Add main menu
author koryspansel <koryspansel@bendbroadband.com>
date Tue, 18 Oct 2011 17:08:17 -0700
parents 48705dc6e568
children
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')
49
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
32 extern = join(root, 'extern')
46
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
33
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
34 if not isdir(data):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
35 raise Exception('Error: Could not locate data folder')
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
36
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
37 if isdir(build):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
38 shutil.rmtree(build, True)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
39
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
40 os.makedirs(build)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
41
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
42 shutil.copyfile(executable, join(build, basename(executable)))
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
43
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
44 for filename in relative_walk(data):
49
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
45 filepath = join(build, 'Data', filename)
46
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
46
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
47 if not isdir(dirname(filepath)):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
48 os.makedirs(dirname(filepath))
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
49
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
50 shutil.copyfile(join(data, filename), filepath)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
51
49
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
52 for filename in relative_walk(extern):
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
53 filepath = join(build, filename)
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
54
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
55 if not isdir(dirname(filepath)):
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
56 os.makedirs(dirname(filepath))
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
57
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
58 shutil.copyfile(join(extern, filename), filepath)
48705dc6e568 Fix window issues; Start on GuiRenderContext
koryspansel
parents: 47
diff changeset
59
46
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
60 if not isdir(location):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
61 os.makedirs(location)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
62
47
81d413160824 Added a release
koryspansel
parents: 46
diff changeset
63 with zipfile.ZipFile(join(location, project + datetime.datetime.now().strftime('%Y%m%d%I%M%p') + '.zip'), 'w') as handle:
46
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
64 for filename in relative_walk(build):
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
65 handle.write(join(build, filename), filename)
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
66
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
67 if __name__ == '__main__':
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
68 root = normpath(join(dirname(sys.argv[0]), '..'))
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
69
a379bce1aeb1 Rename map.py to build.py; Add release script
koryspansel
parents:
diff changeset
70 release_project(root, '..\Release', 'LightClone')