diff Resources/EmbedResources.py @ 55:601ee9b7f2c7

fixes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Sep 2012 12:19:42 +0200
parents e1a3ae0dadf3
children 71c4a4abe90b
line wrap: on
line diff
--- a/Resources/EmbedResources.py	Mon Sep 10 15:23:20 2012 +0200
+++ b/Resources/EmbedResources.py	Tue Sep 11 12:19:42 2012 +0200
@@ -142,6 +142,8 @@
 ## Write the resource content in the .cpp source
 #####################################################################
 
+PYTHON_MAJOR_VERSION = sys.version_info[0]
+
 def WriteResource(cpp, item):
     cpp.write('    static const uint8_t resource%dBuffer[] = {' % item['Index'])
 
@@ -152,16 +154,21 @@
     # http://stackoverflow.com/a/1035360
     pos = 0
     for b in content:
+        if PYTHON_MAJOR_VERSION == 2:
+            c = ord(b[0])
+        else:
+            c = b
+
         if pos > 0:
             cpp.write(', ')
 
         if (pos % 16) == 0:
             cpp.write('\n    ')
 
-        if ord(b[0]) < 0:
+        if c < 0:
             raise Exception("Internal error")
 
-        cpp.write("0x%02x" % ord(b[0]))
+        cpp.write("0x%02x" % c)
         pos += 1
 
     cpp.write('  };\n')