Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c41490c authored by Bernhard Rosenkränzer's avatar Bernhard Rosenkränzer Committed by Sami Tolvanen
Browse files

Allow building with Python 3.x



Allow the scripts to run with both python 2.x and 3.x

Bug: 27498078
Bug: 22914603
Change-Id: I911118bcf370d09bdb2fb46afa21af64257f1ffb
Signed-off-by: default avatarBernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
(cherry pick from commit c434cf82)
parent 8a1d0a44
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ from argparse import ArgumentParser, FileType, Action
from os import fstat
from struct import pack
from hashlib import sha1
import sys

def filesize(f):
    if f is None:
@@ -133,8 +134,10 @@ def main():
    img_id = write_header(args)
    write_data(args)
    if args.id:
        print('0x' + ''.join('{:02x}'.format(ord(c)) for c in img_id))

        if isinstance(img_id, str):
            # Python 2's struct.pack returns a string, but py3 returns bytes.
            img_id = [ord(x) for x in img_id]
        print('0x' + ''.join('{:02x}'.format(c) for c in img_id))

if __name__ == '__main__':
    main()
+5 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#
# pylint: disable=bad-indentation,bad-continuation

from __future__ import print_function
import os
import re
import sys
@@ -72,11 +73,11 @@ with open(sys.argv[1], 'r') as f:
        ff_list.append(name)

def Dump(struct_name, values):
  print 'static struct label %s[] = {' % (struct_name)
  print('static struct label %s[] = {' % (struct_name))
  for value in values:
    print '    LABEL(%s),' % (value)
  print '    LABEL_END,'
  print '};'
    print('    LABEL(%s),' % (value))
  print('    LABEL_END,')
  print('};')

Dump("input_prop_labels", input_prop_list)
Dump("ev_labels", ev_list)