mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
scripts: Make mkdtboimg.py compatible with python3
There are a few changes needed to run mkdtboimg.py with python3. -No more implicit conversion between char and byte. -xrange was renamed to range in python3 -floor division must be done with the '//' operator Bug: 166496956 Test: ./mkdtboimg_testdata.sh Test: atest FirmwareDtboVerification Change-Id: I8b9b97b7b9f31768cc133f37d0144420cb1a0e81 Signed-off-by: Forenche <prahul2003@gmail.com> Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This commit is contained in:
parent
22d2a0c96f
commit
193a96fb45
@ -244,7 +244,7 @@ class Dtbo(object):
|
||||
Tree table entries and update the DTBO header.
|
||||
"""
|
||||
|
||||
self.__metadata = array('c', ' ' * self.__metadata_size)
|
||||
self.__metadata = array('b', b' ' * self.__metadata_size)
|
||||
metadata_offset = self.header_size
|
||||
for dt_entry in self.__dt_entries:
|
||||
self._update_dt_entry_header(dt_entry, metadata_offset)
|
||||
@ -290,7 +290,7 @@ class Dtbo(object):
|
||||
if self.__dt_entries:
|
||||
raise ValueError('DTBO DT entries can be added only once')
|
||||
|
||||
offset = self.dt_entries_offset / 4
|
||||
offset = self.dt_entries_offset // 4
|
||||
params = {}
|
||||
params['dt_file'] = None
|
||||
for i in range(0, self.dt_entry_count):
|
||||
@ -465,7 +465,7 @@ class Dtbo(object):
|
||||
dt_offset = (self.header_size +
|
||||
dt_entry_count * self.dt_entry_size)
|
||||
|
||||
dt_entry_buf = ""
|
||||
dt_entry_buf = b""
|
||||
for dt_entry in dt_entries:
|
||||
if not isinstance(dt_entry, DtEntry):
|
||||
raise ValueError('Adding invalid DT entry object to DTBO')
|
||||
@ -612,7 +612,7 @@ def parse_dt_entries(global_args, arg_list):
|
||||
raise ValueError('Input DT images must be provided')
|
||||
|
||||
total_images = len(img_file_idx)
|
||||
for idx in xrange(total_images):
|
||||
for idx in range(total_images):
|
||||
start_idx = img_file_idx[idx]
|
||||
if idx == total_images - 1:
|
||||
argv = arg_list[start_idx:]
|
||||
@ -769,7 +769,7 @@ def parse_dump_cmd_args(arglist):
|
||||
|
||||
parser = argparse.ArgumentParser(prog='dump')
|
||||
parser.add_argument('--output', '-o', nargs='?',
|
||||
type=argparse.FileType('wb'),
|
||||
type=argparse.FileType('w'),
|
||||
dest='outfile',
|
||||
default=stdout)
|
||||
parser.add_argument('--dtb', '-b', nargs='?', type=str,
|
||||
@ -789,7 +789,7 @@ def parse_config_create_cmd_args(arglist):
|
||||
"""
|
||||
parser = argparse.ArgumentParser(prog='cfg_create')
|
||||
parser.add_argument('conf_file', nargs='?',
|
||||
type=argparse.FileType('rb'),
|
||||
type=argparse.FileType('r'),
|
||||
default=None)
|
||||
cwd = os.getcwd()
|
||||
parser.add_argument('--dtb-dir', '-d', nargs='?', type=str,
|
||||
|
Loading…
x
Reference in New Issue
Block a user