Mercurial > LightClone
view LightTools/release.py @ 47:81d413160824
Added a release
author | koryspansel |
---|---|
date | Thu, 22 Sep 2011 14:38:07 -0700 |
parents | a379bce1aeb1 |
children | 48705dc6e568 |
line wrap: on
line source
# # release # from os.path import join, isdir, isfile, dirname, basename, normpath import tempfile import os import sys import shutil import zipfile import datetime def relative_walk(path): for root, folders, files in os.walk(path): for filename in files: yield join(root, filename)[len(path)+1:] def release_project(root, location, project, target=None, build='Build'): if target: executable = join(root, project, 'bin', target, project + '.exe') else: executable = join(root, project, 'bin', 'release', project + '.exe') if not isfile(executable): executable = join(root, project, 'bin', 'debug', project + '.exe') if not isfile(executable): raise Exception('Error: Could not locate executable') data = join(root, 'data') if not isdir(data): raise Exception('Error: Could not locate data folder') if isdir(build): shutil.rmtree(build, True) os.makedirs(build) shutil.copyfile(executable, join(build, basename(executable))) for filename in relative_walk(data): filepath = join(build, filename) if not isdir(dirname(filepath)): os.makedirs(dirname(filepath)) shutil.copyfile(join(data, filename), filepath) if not isdir(location): os.makedirs(location) with zipfile.ZipFile(join(location, project + datetime.datetime.now().strftime('%Y%m%d%I%M%p') + '.zip'), 'w') as handle: for filename in relative_walk(build): handle.write(join(build, filename), filename) if __name__ == '__main__': root = normpath(join(dirname(sys.argv[0]), '..')) release_project(root, '..\Release', 'LightClone')