diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-03-22 18:25:18 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-03-22 18:25:18 +0300 |
commit | e5eed21a6bf9d8ab36f72d51c3d9f6fad02e795e (patch) | |
tree | bebca8e4390819a0dd8c6dc9999fafa1b63ebe57 /build_files/buildbot/master_unpack.py | |
parent | 636ceed094635ab80867d062377d9a8e6ddacfcb (diff) |
Buildbot master tweaks: use generic builder for scons win32, unpack fixes.
Diffstat (limited to 'build_files/buildbot/master_unpack.py')
-rw-r--r-- | build_files/buildbot/master_unpack.py | 94 |
1 files changed, 48 insertions, 46 deletions
diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index 2c2bc1898b2..70c8b4c3b0b 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -26,59 +26,59 @@ import zipfile # extension stripping def strip_extension(filename): - extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] + extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] - for ext in extensions: - if filename.endswith(ext): - filename = filename[:-len(ext)] + for ext in extensions: + if filename.endswith(ext): + filename = filename[:-len(ext)] - return filename + return filename # extract platform from package name def get_platform(filename): - # name is blender-version-platform.extension. we want to get the - # platform out, but there may be some variations, so we fiddle a - # bit to handle current and hopefully future names - filename = strip_extension(filename) - filename = strip_extension(filename) + # name is blender-version-platform.extension. we want to get the + # platform out, but there may be some variations, so we fiddle a + # bit to handle current and hopefully future names + filename = strip_extension(filename) + filename = strip_extension(filename) - tokens = filename.split("-") - platforms = ['osx', 'mac', 'bsd', 'win', 'linux', 'source', 'irix', 'solaris'] - platform_tokens = [] - found = False + tokens = filename.split("-") + platforms = ['osx', 'mac', 'bsd', 'win', 'linux', 'source', 'irix', 'solaris'] + platform_tokens = [] + found = False - for i, token in enumerate(tokens): - if not found: - for platform in platforms: - if token.lower().find(platform) != -1: - found = True + for i, token in enumerate(tokens): + if not found: + for platform in platforms: + if token.lower().find(platform) != -1: + found = True - if found: - platform_tokens += [token] + if found: + platform_tokens += [token] - return '-'.join(platform_tokens) + return '-'.join(platform_tokens) # get filename if len(sys.argv) < 2: - sys.stderr.write("Not enough arguments, expecting file to unpack\n") - sys.exit(1) + sys.stderr.write("Not enough arguments, expecting file to unpack\n") + sys.exit(1) filename = sys.argv[1] # open zip file if not os.path.exists(filename): - sys.stderr.write("File " + filename + " not found.\n") - sys.exit(1) + sys.stderr.write("File " + filename + " not found.\n") + sys.exit(1) try: - z = zipfile.ZipFile(filename, "r") + z = zipfile.ZipFile(filename, "r") except Exception, ex: - sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') + sys.exit(1) if len(z.namelist()) != 1: - sys.stderr.write("Expected on file in " + filename + ".") - sys.exit(1) + sys.stderr.write("Expected on file in " + filename + ".") + sys.exit(1) package = z.namelist()[0] packagename = os.path.basename(package) @@ -87,31 +87,33 @@ packagename = os.path.basename(package) platform = get_platform(packagename) if platform == '': - sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') - sys.exit(1) + sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') + sys.exit(1) # extract dir = 'public_html/download' try: - zf = z.open(package) - f = file(os.path.join(dir, packagename), "wb") + zf = z.open(package) + f = file(os.path.join(dir, packagename), "wb") - shutil.copyfileobj(zf, f) + shutil.copyfileobj(zf, f) - zf.close() - z.close() + zf.close() + z.close() + + os.remove(filename) except Exception, ex: - sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') + sys.exit(1) # remove other files from the same platform try: - for f in os.listdir(dir): - if f.lower().find(platform.lower()) != -1: - if f != packagename: - os.remove(os.path.join(dir, f)) + for f in os.listdir(dir): + if f.lower().find(platform.lower()) != -1: + if f != packagename: + os.remove(os.path.join(dir, f)) except Exception, ex: - sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') + sys.exit(1) |