mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-22 12:54:37 +00:00
patman: Convert camel case in tout.py
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5e2ab40172
commit
f3385a5b1c
15 changed files with 91 additions and 91 deletions
|
@ -267,7 +267,7 @@ class Bintool:
|
||||||
name = os.path.expanduser(self.name) # Expand paths containing ~
|
name = os.path.expanduser(self.name) # Expand paths containing ~
|
||||||
all_args = (name,) + args
|
all_args = (name,) + args
|
||||||
env = tools.get_env_with_path()
|
env = tools.get_env_with_path()
|
||||||
tout.Detail(f"bintool: {' '.join(all_args)}")
|
tout.detail(f"bintool: {' '.join(all_args)}")
|
||||||
result = command.run_pipe(
|
result = command.run_pipe(
|
||||||
[all_args], capture=True, capture_stderr=True, env=env,
|
[all_args], capture=True, capture_stderr=True, env=env,
|
||||||
raise_on_error=False, binary=binary)
|
raise_on_error=False, binary=binary)
|
||||||
|
@ -278,17 +278,17 @@ class Bintool:
|
||||||
# try to run it (as above) since RunPipe() allows faking the tool's
|
# try to run it (as above) since RunPipe() allows faking the tool's
|
||||||
# output
|
# output
|
||||||
if not any([result.stdout, result.stderr, tools.tool_find(name)]):
|
if not any([result.stdout, result.stderr, tools.tool_find(name)]):
|
||||||
tout.Info(f"bintool '{name}' not found")
|
tout.info(f"bintool '{name}' not found")
|
||||||
return None
|
return None
|
||||||
if raise_on_error:
|
if raise_on_error:
|
||||||
tout.Info(f"bintool '{name}' failed")
|
tout.info(f"bintool '{name}' failed")
|
||||||
raise ValueError("Error %d running '%s': %s" %
|
raise ValueError("Error %d running '%s': %s" %
|
||||||
(result.return_code, ' '.join(all_args),
|
(result.return_code, ' '.join(all_args),
|
||||||
result.stderr or result.stdout))
|
result.stderr or result.stdout))
|
||||||
if result.stdout:
|
if result.stdout:
|
||||||
tout.Debug(result.stdout)
|
tout.debug(result.stdout)
|
||||||
if result.stderr:
|
if result.stderr:
|
||||||
tout.Debug(result.stderr)
|
tout.debug(result.stderr)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def run_cmd(self, *args, binary=False):
|
def run_cmd(self, *args, binary=False):
|
||||||
|
|
|
@ -99,9 +99,9 @@ def _ReadMissingBlobHelp():
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _ShowBlobHelp(path, text):
|
def _ShowBlobHelp(path, text):
|
||||||
tout.Warning('\n%s:' % path)
|
tout.warning('\n%s:' % path)
|
||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
tout.Warning(' %s' % line)
|
tout.warning(' %s' % line)
|
||||||
|
|
||||||
def _ShowHelpForMissingBlobs(missing_list):
|
def _ShowHelpForMissingBlobs(missing_list):
|
||||||
"""Show help for each missing blob to help the user take action
|
"""Show help for each missing blob to help the user take action
|
||||||
|
@ -259,14 +259,14 @@ def ExtractEntries(image_fname, output_fname, outdir, entry_paths,
|
||||||
entry = image.FindEntryPath(entry_paths[0])
|
entry = image.FindEntryPath(entry_paths[0])
|
||||||
data = entry.ReadData(decomp, alt_format)
|
data = entry.ReadData(decomp, alt_format)
|
||||||
tools.write_file(output_fname, data)
|
tools.write_file(output_fname, data)
|
||||||
tout.Notice("Wrote %#x bytes to file '%s'" % (len(data), output_fname))
|
tout.notice("Wrote %#x bytes to file '%s'" % (len(data), output_fname))
|
||||||
return
|
return
|
||||||
|
|
||||||
# Otherwise we will output to a path given by the entry path of each entry.
|
# Otherwise we will output to a path given by the entry path of each entry.
|
||||||
# This means that entries will appear in subdirectories if they are part of
|
# This means that entries will appear in subdirectories if they are part of
|
||||||
# a sub-section.
|
# a sub-section.
|
||||||
einfos = image.GetListEntries(entry_paths)[0]
|
einfos = image.GetListEntries(entry_paths)[0]
|
||||||
tout.Notice('%d entries match and will be written' % len(einfos))
|
tout.notice('%d entries match and will be written' % len(einfos))
|
||||||
for einfo in einfos:
|
for einfo in einfos:
|
||||||
entry = einfo.entry
|
entry = einfo.entry
|
||||||
data = entry.ReadData(decomp, alt_format)
|
data = entry.ReadData(decomp, alt_format)
|
||||||
|
@ -279,7 +279,7 @@ def ExtractEntries(image_fname, output_fname, outdir, entry_paths,
|
||||||
if fname and not os.path.exists(fname):
|
if fname and not os.path.exists(fname):
|
||||||
os.makedirs(fname)
|
os.makedirs(fname)
|
||||||
fname = os.path.join(fname, 'root')
|
fname = os.path.join(fname, 'root')
|
||||||
tout.Notice("Write entry '%s' size %x to '%s'" %
|
tout.notice("Write entry '%s' size %x to '%s'" %
|
||||||
(entry.GetPath(), len(data), fname))
|
(entry.GetPath(), len(data), fname))
|
||||||
tools.write_file(fname, data)
|
tools.write_file(fname, data)
|
||||||
return einfos
|
return einfos
|
||||||
|
@ -328,7 +328,7 @@ def AfterReplace(image, allow_resize, write_map):
|
||||||
of the entries), False to raise an exception
|
of the entries), False to raise an exception
|
||||||
write_map: True to write a map file
|
write_map: True to write a map file
|
||||||
"""
|
"""
|
||||||
tout.Info('Processing image')
|
tout.info('Processing image')
|
||||||
ProcessImage(image, update_fdt=True, write_map=write_map,
|
ProcessImage(image, update_fdt=True, write_map=write_map,
|
||||||
get_contents=False, allow_resize=allow_resize)
|
get_contents=False, allow_resize=allow_resize)
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ def AfterReplace(image, allow_resize, write_map):
|
||||||
def WriteEntryToImage(image, entry, data, do_compress=True, allow_resize=True,
|
def WriteEntryToImage(image, entry, data, do_compress=True, allow_resize=True,
|
||||||
write_map=False):
|
write_map=False):
|
||||||
BeforeReplace(image, allow_resize)
|
BeforeReplace(image, allow_resize)
|
||||||
tout.Info('Writing data to %s' % entry.GetPath())
|
tout.info('Writing data to %s' % entry.GetPath())
|
||||||
ReplaceOneEntry(image, entry, data, do_compress, allow_resize)
|
ReplaceOneEntry(image, entry, data, do_compress, allow_resize)
|
||||||
AfterReplace(image, allow_resize=allow_resize, write_map=write_map)
|
AfterReplace(image, allow_resize=allow_resize, write_map=write_map)
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ def WriteEntry(image_fname, entry_path, data, do_compress=True,
|
||||||
Returns:
|
Returns:
|
||||||
Image object that was updated
|
Image object that was updated
|
||||||
"""
|
"""
|
||||||
tout.Info("Write entry '%s', file '%s'" % (entry_path, image_fname))
|
tout.info("Write entry '%s', file '%s'" % (entry_path, image_fname))
|
||||||
image = Image.FromFile(image_fname)
|
image = Image.FromFile(image_fname)
|
||||||
entry = image.FindEntryPath(entry_path)
|
entry = image.FindEntryPath(entry_path)
|
||||||
WriteEntryToImage(image, entry, data, do_compress=do_compress,
|
WriteEntryToImage(image, entry, data, do_compress=do_compress,
|
||||||
|
@ -399,7 +399,7 @@ def ReplaceEntries(image_fname, input_fname, indir, entry_paths,
|
||||||
raise ValueError('Must specify exactly one entry path to write with -f')
|
raise ValueError('Must specify exactly one entry path to write with -f')
|
||||||
entry = image.FindEntryPath(entry_paths[0])
|
entry = image.FindEntryPath(entry_paths[0])
|
||||||
data = tools.read_file(input_fname)
|
data = tools.read_file(input_fname)
|
||||||
tout.Notice("Read %#x bytes from file '%s'" % (len(data), input_fname))
|
tout.notice("Read %#x bytes from file '%s'" % (len(data), input_fname))
|
||||||
WriteEntryToImage(image, entry, data, do_compress=do_compress,
|
WriteEntryToImage(image, entry, data, do_compress=do_compress,
|
||||||
allow_resize=allow_resize, write_map=write_map)
|
allow_resize=allow_resize, write_map=write_map)
|
||||||
return
|
return
|
||||||
|
@ -408,7 +408,7 @@ def ReplaceEntries(image_fname, input_fname, indir, entry_paths,
|
||||||
# This means that files must appear in subdirectories if they are part of
|
# This means that files must appear in subdirectories if they are part of
|
||||||
# a sub-section.
|
# a sub-section.
|
||||||
einfos = image.GetListEntries(entry_paths)[0]
|
einfos = image.GetListEntries(entry_paths)[0]
|
||||||
tout.Notice("Replacing %d matching entries in image '%s'" %
|
tout.notice("Replacing %d matching entries in image '%s'" %
|
||||||
(len(einfos), image_fname))
|
(len(einfos), image_fname))
|
||||||
|
|
||||||
BeforeReplace(image, allow_resize)
|
BeforeReplace(image, allow_resize)
|
||||||
|
@ -416,19 +416,19 @@ def ReplaceEntries(image_fname, input_fname, indir, entry_paths,
|
||||||
for einfo in einfos:
|
for einfo in einfos:
|
||||||
entry = einfo.entry
|
entry = einfo.entry
|
||||||
if entry.GetEntries():
|
if entry.GetEntries():
|
||||||
tout.Info("Skipping section entry '%s'" % entry.GetPath())
|
tout.info("Skipping section entry '%s'" % entry.GetPath())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
path = entry.GetPath()[1:]
|
path = entry.GetPath()[1:]
|
||||||
fname = os.path.join(indir, path)
|
fname = os.path.join(indir, path)
|
||||||
|
|
||||||
if os.path.exists(fname):
|
if os.path.exists(fname):
|
||||||
tout.Notice("Write entry '%s' from file '%s'" %
|
tout.notice("Write entry '%s' from file '%s'" %
|
||||||
(entry.GetPath(), fname))
|
(entry.GetPath(), fname))
|
||||||
data = tools.read_file(fname)
|
data = tools.read_file(fname)
|
||||||
ReplaceOneEntry(image, entry, data, do_compress, allow_resize)
|
ReplaceOneEntry(image, entry, data, do_compress, allow_resize)
|
||||||
else:
|
else:
|
||||||
tout.Warning("Skipping entry '%s' from missing file '%s'" %
|
tout.warning("Skipping entry '%s' from missing file '%s'" %
|
||||||
(entry.GetPath(), fname))
|
(entry.GetPath(), fname))
|
||||||
|
|
||||||
AfterReplace(image, allow_resize=allow_resize, write_map=write_map)
|
AfterReplace(image, allow_resize=allow_resize, write_map=write_map)
|
||||||
|
@ -488,7 +488,7 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded):
|
||||||
else:
|
else:
|
||||||
skip.append(name)
|
skip.append(name)
|
||||||
images = new_images
|
images = new_images
|
||||||
tout.Notice('Skipping images: %s' % ', '.join(skip))
|
tout.notice('Skipping images: %s' % ', '.join(skip))
|
||||||
|
|
||||||
state.Prepare(images, dtb)
|
state.Prepare(images, dtb)
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True,
|
||||||
if sizes_ok:
|
if sizes_ok:
|
||||||
break
|
break
|
||||||
image.ResetForPack()
|
image.ResetForPack()
|
||||||
tout.Info('Pack completed after %d pass(es)' % (pack_pass + 1))
|
tout.info('Pack completed after %d pass(es)' % (pack_pass + 1))
|
||||||
if not sizes_ok:
|
if not sizes_ok:
|
||||||
image.Raise('Entries changed size after packing (tried %s passes)' %
|
image.Raise('Entries changed size after packing (tried %s passes)' %
|
||||||
passes)
|
passes)
|
||||||
|
@ -585,20 +585,20 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True,
|
||||||
missing_list = []
|
missing_list = []
|
||||||
image.CheckMissing(missing_list)
|
image.CheckMissing(missing_list)
|
||||||
if missing_list:
|
if missing_list:
|
||||||
tout.Warning("Image '%s' is missing external blobs and is non-functional: %s" %
|
tout.warning("Image '%s' is missing external blobs and is non-functional: %s" %
|
||||||
(image.name, ' '.join([e.name for e in missing_list])))
|
(image.name, ' '.join([e.name for e in missing_list])))
|
||||||
_ShowHelpForMissingBlobs(missing_list)
|
_ShowHelpForMissingBlobs(missing_list)
|
||||||
faked_list = []
|
faked_list = []
|
||||||
image.CheckFakedBlobs(faked_list)
|
image.CheckFakedBlobs(faked_list)
|
||||||
if faked_list:
|
if faked_list:
|
||||||
tout.Warning(
|
tout.warning(
|
||||||
"Image '%s' has faked external blobs and is non-functional: %s" %
|
"Image '%s' has faked external blobs and is non-functional: %s" %
|
||||||
(image.name, ' '.join([os.path.basename(e.GetDefaultFilename())
|
(image.name, ' '.join([os.path.basename(e.GetDefaultFilename())
|
||||||
for e in faked_list])))
|
for e in faked_list])))
|
||||||
missing_bintool_list = []
|
missing_bintool_list = []
|
||||||
image.check_missing_bintools(missing_bintool_list)
|
image.check_missing_bintools(missing_bintool_list)
|
||||||
if missing_bintool_list:
|
if missing_bintool_list:
|
||||||
tout.Warning(
|
tout.warning(
|
||||||
"Image '%s' has missing bintools and is non-functional: %s" %
|
"Image '%s' has missing bintools and is non-functional: %s" %
|
||||||
(image.name, ' '.join([os.path.basename(bintool.name)
|
(image.name, ' '.join([os.path.basename(bintool.name)
|
||||||
for bintool in missing_bintool_list])))
|
for bintool in missing_bintool_list])))
|
||||||
|
@ -629,7 +629,7 @@ def Binman(args):
|
||||||
|
|
||||||
if args.cmd in ['ls', 'extract', 'replace', 'tool']:
|
if args.cmd in ['ls', 'extract', 'replace', 'tool']:
|
||||||
try:
|
try:
|
||||||
tout.Init(args.verbosity)
|
tout.init(args.verbosity)
|
||||||
tools.prepare_output_dir(None)
|
tools.prepare_output_dir(None)
|
||||||
if args.cmd == 'ls':
|
if args.cmd == 'ls':
|
||||||
ListEntries(args.image, args.paths)
|
ListEntries(args.image, args.paths)
|
||||||
|
@ -682,7 +682,7 @@ def Binman(args):
|
||||||
args.indir.append(board_pathname)
|
args.indir.append(board_pathname)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tout.Init(args.verbosity)
|
tout.init(args.verbosity)
|
||||||
elf.debug = args.debug
|
elf.debug = args.debug
|
||||||
cbfs_util.VERBOSE = args.verbosity > 2
|
cbfs_util.VERBOSE = args.verbosity > 2
|
||||||
state.use_fake_dtb = args.fake_dtb
|
state.use_fake_dtb = args.fake_dtb
|
||||||
|
@ -724,13 +724,13 @@ def Binman(args):
|
||||||
elf.UpdateFile(*elf_params, data)
|
elf.UpdateFile(*elf_params, data)
|
||||||
|
|
||||||
if invalid:
|
if invalid:
|
||||||
tout.Warning("\nSome images are invalid")
|
tout.warning("\nSome images are invalid")
|
||||||
|
|
||||||
# Use this to debug the time take to pack the image
|
# Use this to debug the time take to pack the image
|
||||||
#state.TimingShow()
|
#state.TimingShow()
|
||||||
finally:
|
finally:
|
||||||
tools.finalise_output_dir()
|
tools.finalise_output_dir()
|
||||||
finally:
|
finally:
|
||||||
tout.Uninit()
|
tout.uninit()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -185,7 +185,7 @@ def LookupAndWriteSymbols(elf_fname, entry, section):
|
||||||
value = -1
|
value = -1
|
||||||
pack_string = pack_string.lower()
|
pack_string = pack_string.lower()
|
||||||
value_bytes = struct.pack(pack_string, value)
|
value_bytes = struct.pack(pack_string, value)
|
||||||
tout.Debug('%s:\n insert %s, offset %x, value %x, length %d' %
|
tout.debug('%s:\n insert %s, offset %x, value %x, length %d' %
|
||||||
(msg, name, offset, value, len(value_bytes)))
|
(msg, name, offset, value, len(value_bytes)))
|
||||||
entry.data = (entry.data[:offset] + value_bytes +
|
entry.data = (entry.data[:offset] + value_bytes +
|
||||||
entry.data[offset + sym.size:])
|
entry.data[offset + sym.size:])
|
||||||
|
@ -350,7 +350,7 @@ def DecodeElf(data, location):
|
||||||
mem_end - data_start)
|
mem_end - data_start)
|
||||||
|
|
||||||
def UpdateFile(infile, outfile, start_sym, end_sym, insert):
|
def UpdateFile(infile, outfile, start_sym, end_sym, insert):
|
||||||
tout.Notice("Creating file '%s' with data length %#x (%d) between symbols '%s' and '%s'" %
|
tout.notice("Creating file '%s' with data length %#x (%d) between symbols '%s' and '%s'" %
|
||||||
(outfile, len(insert), len(insert), start_sym, end_sym))
|
(outfile, len(insert), len(insert), start_sym, end_sym))
|
||||||
syms = GetSymbolFileOffset(infile, [start_sym, end_sym])
|
syms = GetSymbolFileOffset(infile, [start_sym, end_sym])
|
||||||
if len(syms) != 2:
|
if len(syms) != 2:
|
||||||
|
@ -368,4 +368,4 @@ def UpdateFile(infile, outfile, start_sym, end_sym, insert):
|
||||||
newdata += insert + tools.get_bytes(0, size - len(insert))
|
newdata += insert + tools.get_bytes(0, size - len(insert))
|
||||||
newdata += data[syms[end_sym].offset:]
|
newdata += data[syms[end_sym].offset:]
|
||||||
tools.write_file(outfile, newdata)
|
tools.write_file(outfile, newdata)
|
||||||
tout.Info('Written to offset %#x' % syms[start_sym].offset)
|
tout.info('Written to offset %#x' % syms[start_sym].offset)
|
||||||
|
|
|
@ -172,7 +172,7 @@ class TestElf(unittest.TestCase):
|
||||||
def testDebug(self):
|
def testDebug(self):
|
||||||
"""Check that enabling debug in the elf module produced debug output"""
|
"""Check that enabling debug in the elf module produced debug output"""
|
||||||
try:
|
try:
|
||||||
tout.Init(tout.DEBUG)
|
tout.init(tout.DEBUG)
|
||||||
entry = FakeEntry(20)
|
entry = FakeEntry(20)
|
||||||
section = FakeSection()
|
section = FakeSection()
|
||||||
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
||||||
|
@ -180,7 +180,7 @@ class TestElf(unittest.TestCase):
|
||||||
syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||||
self.assertTrue(len(stdout.getvalue()) > 0)
|
self.assertTrue(len(stdout.getvalue()) > 0)
|
||||||
finally:
|
finally:
|
||||||
tout.Init(tout.WARNING)
|
tout.init(tout.WARNING)
|
||||||
|
|
||||||
def testMakeElf(self):
|
def testMakeElf(self):
|
||||||
"""Test for the MakeElf function"""
|
"""Test for the MakeElf function"""
|
||||||
|
|
|
@ -400,7 +400,7 @@ class Entry(object):
|
||||||
data += tools.get_bytes(0, self.contents_size - new_size)
|
data += tools.get_bytes(0, self.contents_size - new_size)
|
||||||
|
|
||||||
if not size_ok:
|
if not size_ok:
|
||||||
tout.Debug("Entry '%s' size change from %s to %s" % (
|
tout.debug("Entry '%s' size change from %s to %s" % (
|
||||||
self._node.path, to_hex(self.contents_size),
|
self._node.path, to_hex(self.contents_size),
|
||||||
to_hex(new_size)))
|
to_hex(new_size)))
|
||||||
self.SetContents(data)
|
self.SetContents(data)
|
||||||
|
@ -489,12 +489,12 @@ class Entry(object):
|
||||||
def Info(self, msg):
|
def Info(self, msg):
|
||||||
"""Convenience function to log info referencing a node"""
|
"""Convenience function to log info referencing a node"""
|
||||||
tag = "Info '%s'" % self._node.path
|
tag = "Info '%s'" % self._node.path
|
||||||
tout.Detail('%30s: %s' % (tag, msg))
|
tout.detail('%30s: %s' % (tag, msg))
|
||||||
|
|
||||||
def Detail(self, msg):
|
def Detail(self, msg):
|
||||||
"""Convenience function to log detail referencing a node"""
|
"""Convenience function to log detail referencing a node"""
|
||||||
tag = "Node '%s'" % self._node.path
|
tag = "Node '%s'" % self._node.path
|
||||||
tout.Detail('%30s: %s' % (tag, msg))
|
tout.detail('%30s: %s' % (tag, msg))
|
||||||
|
|
||||||
def GetEntryArgsOrProps(self, props, required=False):
|
def GetEntryArgsOrProps(self, props, required=False):
|
||||||
"""Return the values of a set of properties
|
"""Return the values of a set of properties
|
||||||
|
@ -841,7 +841,7 @@ features to produce new behaviours.
|
||||||
"""
|
"""
|
||||||
# Use True here so that we get an uncompressed section to work from,
|
# Use True here so that we get an uncompressed section to work from,
|
||||||
# although compressed sections are currently not supported
|
# although compressed sections are currently not supported
|
||||||
tout.Debug("ReadChildData section '%s', entry '%s'" %
|
tout.debug("ReadChildData section '%s', entry '%s'" %
|
||||||
(self.section.GetPath(), self.GetPath()))
|
(self.section.GetPath(), self.GetPath()))
|
||||||
data = self.section.ReadChildData(self, decomp, alt_format)
|
data = self.section.ReadChildData(self, decomp, alt_format)
|
||||||
return data
|
return data
|
||||||
|
@ -1076,7 +1076,7 @@ features to produce new behaviours.
|
||||||
Returns:
|
Returns:
|
||||||
True to use this entry type, False to use the original one
|
True to use this entry type, False to use the original one
|
||||||
"""
|
"""
|
||||||
tout.Info("Node '%s': etype '%s': %s selected" %
|
tout.info("Node '%s': etype '%s': %s selected" %
|
||||||
(node.path, etype, new_etype))
|
(node.path, etype, new_etype))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Entry_fmap(Entry):
|
||||||
"""
|
"""
|
||||||
def _AddEntries(areas, entry):
|
def _AddEntries(areas, entry):
|
||||||
entries = entry.GetEntries()
|
entries = entry.GetEntries()
|
||||||
tout.Debug("fmap: Add entry '%s' type '%s' (%s subentries)" %
|
tout.debug("fmap: Add entry '%s' type '%s' (%s subentries)" %
|
||||||
(entry.GetPath(), entry.etype, to_hex_size(entries)))
|
(entry.GetPath(), entry.etype, to_hex_size(entries)))
|
||||||
if entries and entry.etype != 'cbfs':
|
if entries and entry.etype != 'cbfs':
|
||||||
# Create an area for the section, which encompasses all entries
|
# Create an area for the section, which encompasses all entries
|
||||||
|
|
|
@ -757,28 +757,28 @@ class Entry_section(Entry):
|
||||||
return self._sort
|
return self._sort
|
||||||
|
|
||||||
def ReadData(self, decomp=True, alt_format=None):
|
def ReadData(self, decomp=True, alt_format=None):
|
||||||
tout.Info("ReadData path='%s'" % self.GetPath())
|
tout.info("ReadData path='%s'" % self.GetPath())
|
||||||
parent_data = self.section.ReadData(True, alt_format)
|
parent_data = self.section.ReadData(True, alt_format)
|
||||||
offset = self.offset - self.section._skip_at_start
|
offset = self.offset - self.section._skip_at_start
|
||||||
data = parent_data[offset:offset + self.size]
|
data = parent_data[offset:offset + self.size]
|
||||||
tout.Info(
|
tout.info(
|
||||||
'%s: Reading data from offset %#x-%#x (real %#x), size %#x, got %#x' %
|
'%s: Reading data from offset %#x-%#x (real %#x), size %#x, got %#x' %
|
||||||
(self.GetPath(), self.offset, self.offset + self.size, offset,
|
(self.GetPath(), self.offset, self.offset + self.size, offset,
|
||||||
self.size, len(data)))
|
self.size, len(data)))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def ReadChildData(self, child, decomp=True, alt_format=None):
|
def ReadChildData(self, child, decomp=True, alt_format=None):
|
||||||
tout.Debug(f"ReadChildData for child '{child.GetPath()}'")
|
tout.debug(f"ReadChildData for child '{child.GetPath()}'")
|
||||||
parent_data = self.ReadData(True, alt_format)
|
parent_data = self.ReadData(True, alt_format)
|
||||||
offset = child.offset - self._skip_at_start
|
offset = child.offset - self._skip_at_start
|
||||||
tout.Debug("Extract for child '%s': offset %#x, skip_at_start %#x, result %#x" %
|
tout.debug("Extract for child '%s': offset %#x, skip_at_start %#x, result %#x" %
|
||||||
(child.GetPath(), child.offset, self._skip_at_start, offset))
|
(child.GetPath(), child.offset, self._skip_at_start, offset))
|
||||||
data = parent_data[offset:offset + child.size]
|
data = parent_data[offset:offset + child.size]
|
||||||
if decomp:
|
if decomp:
|
||||||
indata = data
|
indata = data
|
||||||
data = comp_util.decompress(indata, child.compress)
|
data = comp_util.decompress(indata, child.compress)
|
||||||
if child.uncomp_size:
|
if child.uncomp_size:
|
||||||
tout.Info("%s: Decompressing data size %#x with algo '%s' to data size %#x" %
|
tout.info("%s: Decompressing data size %#x with algo '%s' to data size %#x" %
|
||||||
(child.GetPath(), len(indata), child.compress,
|
(child.GetPath(), len(indata), child.compress,
|
||||||
len(data)))
|
len(data)))
|
||||||
if alt_format:
|
if alt_format:
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Entry_u_boot_spl_expanded(Entry_blob_phase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def UseExpanded(cls, node, etype, new_etype):
|
def UseExpanded(cls, node, etype, new_etype):
|
||||||
val = state.GetEntryArgBool('spl-dtb')
|
val = state.GetEntryArgBool('spl-dtb')
|
||||||
tout.DoOutput(tout.INFO if val else tout.DETAIL,
|
tout.do_output(tout.INFO if val else tout.DETAIL,
|
||||||
"Node '%s': etype '%s': %s %sselected" %
|
"Node '%s': etype '%s': %s %sselected" %
|
||||||
(node.path, etype, new_etype, '' if val else 'not '))
|
(node.path, etype, new_etype, '' if val else 'not '))
|
||||||
return val
|
return val
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Entry_u_boot_tpl_expanded(Entry_blob_phase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def UseExpanded(cls, node, etype, new_etype):
|
def UseExpanded(cls, node, etype, new_etype):
|
||||||
val = state.GetEntryArgBool('tpl-dtb')
|
val = state.GetEntryArgBool('tpl-dtb')
|
||||||
tout.DoOutput(tout.INFO if val else tout.DETAIL,
|
tout.do_output(tout.INFO if val else tout.DETAIL,
|
||||||
"Node '%s': etype '%s': %s %sselected" %
|
"Node '%s': etype '%s': %s %sselected" %
|
||||||
(node.path, etype, new_etype, '' if val else 'not '))
|
(node.path, etype, new_etype, '' if val else 'not '))
|
||||||
return val
|
return val
|
||||||
|
|
|
@ -240,7 +240,7 @@ class TestFunctional(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Enable this to turn on debugging output
|
# Enable this to turn on debugging output
|
||||||
# tout.Init(tout.DEBUG)
|
# tout.init(tout.DEBUG)
|
||||||
command.test_result = None
|
command.test_result = None
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
|
@ -175,11 +175,11 @@ class Image(section.Entry_section):
|
||||||
def BuildImage(self):
|
def BuildImage(self):
|
||||||
"""Write the image to a file"""
|
"""Write the image to a file"""
|
||||||
fname = tools.get_output_filename(self._filename)
|
fname = tools.get_output_filename(self._filename)
|
||||||
tout.Info("Writing image to '%s'" % fname)
|
tout.info("Writing image to '%s'" % fname)
|
||||||
with open(fname, 'wb') as fd:
|
with open(fname, 'wb') as fd:
|
||||||
data = self.GetPaddedData()
|
data = self.GetPaddedData()
|
||||||
fd.write(data)
|
fd.write(data)
|
||||||
tout.Info("Wrote %#x bytes" % len(data))
|
tout.info("Wrote %#x bytes" % len(data))
|
||||||
|
|
||||||
def WriteMap(self):
|
def WriteMap(self):
|
||||||
"""Write a map of the image to a .map file
|
"""Write a map of the image to a .map file
|
||||||
|
@ -230,7 +230,7 @@ class Image(section.Entry_section):
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
def ReadData(self, decomp=True, alt_format=None):
|
def ReadData(self, decomp=True, alt_format=None):
|
||||||
tout.Debug("Image '%s' ReadData(), size=%#x" %
|
tout.debug("Image '%s' ReadData(), size=%#x" %
|
||||||
(self.GetPath(), len(self._data)))
|
(self.GetPath(), len(self._data)))
|
||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
|
|
|
@ -170,16 +170,16 @@ def SetEntryArgs(args):
|
||||||
global entry_args
|
global entry_args
|
||||||
|
|
||||||
entry_args = {}
|
entry_args = {}
|
||||||
tout.Debug('Processing entry args:')
|
tout.debug('Processing entry args:')
|
||||||
if args:
|
if args:
|
||||||
for arg in args:
|
for arg in args:
|
||||||
m = re.match('([^=]*)=(.*)', arg)
|
m = re.match('([^=]*)=(.*)', arg)
|
||||||
if not m:
|
if not m:
|
||||||
raise ValueError("Invalid entry arguemnt '%s'" % arg)
|
raise ValueError("Invalid entry arguemnt '%s'" % arg)
|
||||||
name, value = m.groups()
|
name, value = m.groups()
|
||||||
tout.Debug(' %20s = %s' % (name, value))
|
tout.debug(' %20s = %s' % (name, value))
|
||||||
entry_args[name] = value
|
entry_args[name] = value
|
||||||
tout.Debug('Processing entry args done')
|
tout.debug('Processing entry args done')
|
||||||
|
|
||||||
def GetEntryArg(name):
|
def GetEntryArg(name):
|
||||||
"""Get the value of an entry argument
|
"""Get the value of an entry argument
|
||||||
|
@ -263,16 +263,16 @@ def PrepareFromLoadedData(image):
|
||||||
"""
|
"""
|
||||||
global output_fdt_info, main_dtb, fdt_path_prefix
|
global output_fdt_info, main_dtb, fdt_path_prefix
|
||||||
|
|
||||||
tout.Info('Preparing device trees')
|
tout.info('Preparing device trees')
|
||||||
output_fdt_info.clear()
|
output_fdt_info.clear()
|
||||||
fdt_path_prefix = ''
|
fdt_path_prefix = ''
|
||||||
output_fdt_info['fdtmap'] = [image.fdtmap_dtb, 'u-boot.dtb']
|
output_fdt_info['fdtmap'] = [image.fdtmap_dtb, 'u-boot.dtb']
|
||||||
main_dtb = None
|
main_dtb = None
|
||||||
tout.Info(" Found device tree type 'fdtmap' '%s'" % image.fdtmap_dtb.name)
|
tout.info(" Found device tree type 'fdtmap' '%s'" % image.fdtmap_dtb.name)
|
||||||
for etype, value in image.GetFdts().items():
|
for etype, value in image.GetFdts().items():
|
||||||
entry, fname = value
|
entry, fname = value
|
||||||
out_fname = tools.get_output_filename('%s.dtb' % entry.etype)
|
out_fname = tools.get_output_filename('%s.dtb' % entry.etype)
|
||||||
tout.Info(" Found device tree type '%s' at '%s' path '%s'" %
|
tout.info(" Found device tree type '%s' at '%s' path '%s'" %
|
||||||
(etype, out_fname, entry.GetPath()))
|
(etype, out_fname, entry.GetPath()))
|
||||||
entry._filename = entry.GetDefaultFilename()
|
entry._filename = entry.GetDefaultFilename()
|
||||||
data = entry.ReadData()
|
data = entry.ReadData()
|
||||||
|
@ -285,7 +285,7 @@ def PrepareFromLoadedData(image):
|
||||||
image_node = dtb.GetNode('/binman/%s' % image.image_node)
|
image_node = dtb.GetNode('/binman/%s' % image.image_node)
|
||||||
fdt_path_prefix = image_node.path
|
fdt_path_prefix = image_node.path
|
||||||
output_fdt_info[etype] = [dtb, None]
|
output_fdt_info[etype] = [dtb, None]
|
||||||
tout.Info(" FDT path prefix '%s'" % fdt_path_prefix)
|
tout.info(" FDT path prefix '%s'" % fdt_path_prefix)
|
||||||
|
|
||||||
|
|
||||||
def GetAllFdts():
|
def GetAllFdts():
|
||||||
|
@ -384,7 +384,7 @@ def SetInt(node, prop, value, for_repack=False):
|
||||||
for_repack: True is this property is only needed for repacking
|
for_repack: True is this property is only needed for repacking
|
||||||
"""
|
"""
|
||||||
for n in GetUpdateNodes(node, for_repack):
|
for n in GetUpdateNodes(node, for_repack):
|
||||||
tout.Detail("File %s: Update node '%s' prop '%s' to %#x" %
|
tout.detail("File %s: Update node '%s' prop '%s' to %#x" %
|
||||||
(n.GetFdt().name, n.path, prop, value))
|
(n.GetFdt().name, n.path, prop, value))
|
||||||
n.SetInt(prop, value)
|
n.SetInt(prop, value)
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ def collect_patches(series, series_id, url, rest_api=call_rest_api):
|
||||||
count = len(patch_dict)
|
count = len(patch_dict)
|
||||||
num_commits = len(series.commits)
|
num_commits = len(series.commits)
|
||||||
if count != num_commits:
|
if count != num_commits:
|
||||||
tout.Warning('Warning: Patchwork reports %d patches, series has %d' %
|
tout.warning('Warning: Patchwork reports %d patches, series has %d' %
|
||||||
(count, num_commits))
|
(count, num_commits))
|
||||||
|
|
||||||
patches = []
|
patches = []
|
||||||
|
@ -257,7 +257,7 @@ def collect_patches(series, series_id, url, rest_api=call_rest_api):
|
||||||
patch.parse_subject(pw_patch['name'])
|
patch.parse_subject(pw_patch['name'])
|
||||||
patches.append(patch)
|
patches.append(patch)
|
||||||
if warn_count > 1:
|
if warn_count > 1:
|
||||||
tout.Warning(' (total of %d warnings)' % warn_count)
|
tout.warning(' (total of %d warnings)' % warn_count)
|
||||||
|
|
||||||
# Sort patches by patch number
|
# Sort patches by patch number
|
||||||
patches = sorted(patches, key=lambda x: x.seq)
|
patches = sorted(patches, key=lambda x: x.seq)
|
||||||
|
@ -437,7 +437,7 @@ def check_patchwork_status(series, series_id, branch, dest_branch, force,
|
||||||
|
|
||||||
patch_for_commit, _, warnings = compare_with_series(series, patches)
|
patch_for_commit, _, warnings = compare_with_series(series, patches)
|
||||||
for warn in warnings:
|
for warn in warnings:
|
||||||
tout.Warning(warn)
|
tout.warning(warn)
|
||||||
|
|
||||||
patch_list = [patch_for_commit.get(c) for c in range(len(series.commits))]
|
patch_list = [patch_for_commit.get(c) for c in range(len(series.commits))]
|
||||||
|
|
||||||
|
|
|
@ -64,16 +64,16 @@ def prepare_output_dir(dirname, preserve=False):
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
raise CmdError("Cannot make output directory '%s': '%s'" %
|
raise CmdError("Cannot make output directory '%s': '%s'" %
|
||||||
(outdir, err.strerror))
|
(outdir, err.strerror))
|
||||||
tout.Debug("Using output directory '%s'" % outdir)
|
tout.debug("Using output directory '%s'" % outdir)
|
||||||
else:
|
else:
|
||||||
outdir = tempfile.mkdtemp(prefix='binman.')
|
outdir = tempfile.mkdtemp(prefix='binman.')
|
||||||
tout.Debug("Using temporary directory '%s'" % outdir)
|
tout.debug("Using temporary directory '%s'" % outdir)
|
||||||
|
|
||||||
def _remove_output_dir():
|
def _remove_output_dir():
|
||||||
global outdir
|
global outdir
|
||||||
|
|
||||||
shutil.rmtree(outdir)
|
shutil.rmtree(outdir)
|
||||||
tout.Debug("Deleted temporary directory '%s'" % outdir)
|
tout.debug("Deleted temporary directory '%s'" % outdir)
|
||||||
outdir = None
|
outdir = None
|
||||||
|
|
||||||
def finalise_output_dir():
|
def finalise_output_dir():
|
||||||
|
@ -121,7 +121,7 @@ def set_input_dirs(dirname):
|
||||||
global indir
|
global indir
|
||||||
|
|
||||||
indir = dirname
|
indir = dirname
|
||||||
tout.Debug("Using input directories %s" % indir)
|
tout.debug("Using input directories %s" % indir)
|
||||||
|
|
||||||
def get_input_filename(fname, allow_missing=False):
|
def get_input_filename(fname, allow_missing=False):
|
||||||
"""Return a filename for use as input.
|
"""Return a filename for use as input.
|
||||||
|
|
|
@ -30,10 +30,10 @@ def __enter__():
|
||||||
|
|
||||||
def __exit__(unused1, unused2, unused3):
|
def __exit__(unused1, unused2, unused3):
|
||||||
"""Clean up and remove any progress message."""
|
"""Clean up and remove any progress message."""
|
||||||
ClearProgress()
|
clear_progress()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def UserIsPresent():
|
def user_is_present():
|
||||||
"""This returns True if it is likely that a user is present.
|
"""This returns True if it is likely that a user is present.
|
||||||
|
|
||||||
Sometimes we want to prompt the user, but if no one is there then this
|
Sometimes we want to prompt the user, but if no one is there then this
|
||||||
|
@ -44,7 +44,7 @@ def UserIsPresent():
|
||||||
"""
|
"""
|
||||||
return stdout_is_tty and verbose > 0
|
return stdout_is_tty and verbose > 0
|
||||||
|
|
||||||
def ClearProgress():
|
def clear_progress():
|
||||||
"""Clear any active progress message on the terminal."""
|
"""Clear any active progress message on the terminal."""
|
||||||
global in_progress
|
global in_progress
|
||||||
if verbose > 0 and stdout_is_tty and in_progress:
|
if verbose > 0 and stdout_is_tty and in_progress:
|
||||||
|
@ -52,14 +52,14 @@ def ClearProgress():
|
||||||
_stdout.flush()
|
_stdout.flush()
|
||||||
in_progress = False
|
in_progress = False
|
||||||
|
|
||||||
def Progress(msg, warning=False, trailer='...'):
|
def progress(msg, warning=False, trailer='...'):
|
||||||
"""Display progress information.
|
"""Display progress information.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg: Message to display.
|
msg: Message to display.
|
||||||
warning: True if this is a warning."""
|
warning: True if this is a warning."""
|
||||||
global in_progress
|
global in_progress
|
||||||
ClearProgress()
|
clear_progress()
|
||||||
if verbose > 0:
|
if verbose > 0:
|
||||||
_progress = msg + trailer
|
_progress = msg + trailer
|
||||||
if stdout_is_tty:
|
if stdout_is_tty:
|
||||||
|
@ -70,7 +70,7 @@ def Progress(msg, warning=False, trailer='...'):
|
||||||
else:
|
else:
|
||||||
_stdout.write(_progress + '\n')
|
_stdout.write(_progress + '\n')
|
||||||
|
|
||||||
def _Output(level, msg, color=None):
|
def _output(level, msg, color=None):
|
||||||
"""Output a message to the terminal.
|
"""Output a message to the terminal.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -80,7 +80,7 @@ def _Output(level, msg, color=None):
|
||||||
error: True if this is an error message, else False.
|
error: True if this is an error message, else False.
|
||||||
"""
|
"""
|
||||||
if verbose >= level:
|
if verbose >= level:
|
||||||
ClearProgress()
|
clear_progress()
|
||||||
if color:
|
if color:
|
||||||
msg = _color.Color(color, msg)
|
msg = _color.Color(color, msg)
|
||||||
if level < NOTICE:
|
if level < NOTICE:
|
||||||
|
@ -88,7 +88,7 @@ def _Output(level, msg, color=None):
|
||||||
else:
|
else:
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
def DoOutput(level, msg):
|
def do_output(level, msg):
|
||||||
"""Output a message to the terminal.
|
"""Output a message to the terminal.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -96,66 +96,66 @@ def DoOutput(level, msg):
|
||||||
this as high as the currently selected level.
|
this as high as the currently selected level.
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(level, msg)
|
_output(level, msg)
|
||||||
|
|
||||||
def Error(msg):
|
def error(msg):
|
||||||
"""Display an error message
|
"""Display an error message
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(ERROR, msg, _color.RED)
|
_output(ERROR, msg, _color.RED)
|
||||||
|
|
||||||
def Warning(msg):
|
def warning(msg):
|
||||||
"""Display a warning message
|
"""Display a warning message
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(WARNING, msg, _color.YELLOW)
|
_output(WARNING, msg, _color.YELLOW)
|
||||||
|
|
||||||
def Notice(msg):
|
def notice(msg):
|
||||||
"""Display an important infomation message
|
"""Display an important infomation message
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(NOTICE, msg)
|
_output(NOTICE, msg)
|
||||||
|
|
||||||
def Info(msg):
|
def info(msg):
|
||||||
"""Display an infomation message
|
"""Display an infomation message
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(INFO, msg)
|
_output(INFO, msg)
|
||||||
|
|
||||||
def Detail(msg):
|
def detail(msg):
|
||||||
"""Display a detailed message
|
"""Display a detailed message
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(DETAIL, msg)
|
_output(DETAIL, msg)
|
||||||
|
|
||||||
def Debug(msg):
|
def debug(msg):
|
||||||
"""Display a debug message
|
"""Display a debug message
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(DEBUG, msg)
|
_output(DEBUG, msg)
|
||||||
|
|
||||||
def UserOutput(msg):
|
def user_output(msg):
|
||||||
"""Display a message regardless of the current output level.
|
"""Display a message regardless of the current output level.
|
||||||
|
|
||||||
This is used when the output was specifically requested by the user.
|
This is used when the output was specifically requested by the user.
|
||||||
Args:
|
Args:
|
||||||
msg; Message to display.
|
msg; Message to display.
|
||||||
"""
|
"""
|
||||||
_Output(0, msg)
|
_output(0, msg)
|
||||||
|
|
||||||
def Init(_verbose=WARNING, stdout=sys.stdout):
|
def init(_verbose=WARNING, stdout=sys.stdout):
|
||||||
"""Initialize a new output object.
|
"""Initialize a new output object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -173,7 +173,7 @@ def Init(_verbose=WARNING, stdout=sys.stdout):
|
||||||
stdout_is_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
|
stdout_is_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
|
||||||
stderr_is_tty = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()
|
stderr_is_tty = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()
|
||||||
|
|
||||||
def Uninit():
|
def uninit():
|
||||||
ClearProgress()
|
clear_progress()
|
||||||
|
|
||||||
Init()
|
init()
|
||||||
|
|
Loading…
Add table
Reference in a new issue