[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34422] trunk/blender/release/bin/ blender-thumbnailer.py: bugfix [#25742] blender-thumbnailer.py doesn' t work with python 3.1
Campbell Barton
ideasman42 at gmail.com
Thu Jan 20 22:02:43 CET 2011
Revision: 34422
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34422
Author: campbellbarton
Date: 2011-01-20 21:02:42 +0000 (Thu, 20 Jan 2011)
Log Message:
-----------
bugfix [#25742] blender-thumbnailer.py doesn't work with python 3.1
Modified Paths:
--------------
trunk/blender/release/bin/blender-thumbnailer.py
Modified: trunk/blender/release/bin/blender-thumbnailer.py
===================================================================
--- trunk/blender/release/bin/blender-thumbnailer.py 2011-01-20 20:51:38 UTC (rev 34421)
+++ trunk/blender/release/bin/blender-thumbnailer.py 2011-01-20 21:02:42 UTC (rev 34422)
@@ -27,18 +27,19 @@
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 @@
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 @@
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 @@
file_in = sys.argv[-2]
buf, width, height = blend_extract_thumb(file_in)
-
+
if buf:
file_out = sys.argv[-1]
More information about the Bf-blender-cvs
mailing list