From 039bb7812f7c99eda99661fd26182fdb1b7cd900 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Jan 2011 21:02:42 +0000 Subject: bugfix [#25742] blender-thumbnailer.py doesn't work with python 3.1 --- release/bin/blender-thumbnailer.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'release') diff --git a/release/bin/blender-thumbnailer.py b/release/bin/blender-thumbnailer.py index be870560110..16a89d29724 100755 --- a/release/bin/blender-thumbnailer.py +++ b/release/bin/blender-thumbnailer.py @@ -27,18 +27,19 @@ To run automatically with nautilus: import struct + def blend_extract_thumb(path): import os # def MAKE_ID(tag): ord(tag[0])<<24 | ord(tag[1])<<16 | ord(tag[2])<<8 | ord(tag[3]) - REND = 1145980242 # MAKE_ID(b'REND') - TEST = 1414743380 # MAKE_ID(b'TEST') + REND = 1145980242 # MAKE_ID(b'REND') + TEST = 1414743380 # MAKE_ID(b'TEST') blendfile = open(path, 'rb') head = blendfile.read(12) - if head[0:2] == b'\x1f\x8b': # gzip magic + if head[0:2] == b'\x1f\x8b': # gzip magic import gzip blendfile.close() blendfile = gzip.open(path, 'rb') @@ -48,10 +49,10 @@ def blend_extract_thumb(path): blendfile.close() return None, 0, 0 - is_64_bit = (head[7] == b'-') + is_64_bit = (head[7] == b'-'[0]) # true for PPC, false for X86 - is_big_endian = (head[8] == b'V') + is_big_endian = (head[8] == b'V'[0]) # blender pre 2.5 had no thumbs if head[9:11] <= b'24': @@ -66,23 +67,22 @@ def blend_extract_thumb(path): if len(bhead) < sizeof_bhead: return None, 0, 0 - code, length = struct.unpack(int_endian_pair, bhead[0:8]) # 8 == sizeof(int) * 2 + code, length = struct.unpack(int_endian_pair, bhead[0:8]) # 8 == sizeof(int) * 2 if code == REND: blendfile.seek(length, os.SEEK_CUR) else: break - - + if code != TEST: return None, 0, 0 try: - x, y = struct.unpack(int_endian_pair, blendfile.read(8)) # 8 == sizeof(int) * 2 + x, y = struct.unpack(int_endian_pair, blendfile.read(8)) # 8 == sizeof(int) * 2 except struct.error: return None, 0, 0 - length -= 8 # sizeof(int) * 2 + length -= 8 # sizeof(int) * 2 if length != x * y * 4: return None, 0, 0 @@ -122,7 +122,7 @@ if __name__ == '__main__': file_in = sys.argv[-2] buf, width, height = blend_extract_thumb(file_in) - + if buf: file_out = sys.argv[-1] -- cgit v1.2.3