Mercurial > LightClone
view LightTools/release.py @ 53:8cefb65577cc
Clean up world states
author | koryspansel |
---|---|
date | Fri, 30 Sep 2011 15:23:16 -0700 |
parents | 48705dc6e568 |
children |
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') extern = join(root, 'extern') 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, 'Data', filename) if not isdir(dirname(filepath)): os.makedirs(dirname(filepath)) shutil.copyfile(join(data, filename), filepath) for filename in relative_walk(extern): filepath = join(build, filename) if not isdir(dirname(filepath)): os.makedirs(dirname(filepath)) shutil.copyfile(join(extern, 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')