Closed wdoekes closed 3 years ago
Problem:
$ pstore -s =xxx File "/usr/local/bin/pstore", line 769, in print_result_search fmt_args[2:] = [' '.join(fmt_args[2:])] TypeError: sequence item 2: expected str instance, bytes found
Ugly fix:
--- /usr/local/bin/pstore.orig 2018-06-06 14:51:54.043895833 +0200 +++ /usr/local/bin/pstore 2018-06-06 14:56:32.245669517 +0200 @@ -744,16 +744,18 @@ def print_result_related_properties(mach def print_result_search(properties, config): - fmt = '%1s %-25s %s' - print(fmt % (' ', 'Machine', 'Property and value')) - print('-' * 72) + fmt = b'%1s %-25s %s\n' + bytes_stdout.write(fmt % (b' ', b'Machine', b'Property and value')) + bytes_stdout.write(b'-' * 72 + b'\n') for machine in sorted(properties.keys()): props = properties[machine]['properties'] for i, propname in enumerate(sorted(props.keys())): if i == 0: - fmt_args = ['+', machine, propname, '='] + fmt_args = [ + b'+', machine.encode('ascii'), propname.encode('ascii'), + b'='] else: - fmt_args = ['', '', propname, '='] + fmt_args = [b'', b'', propname.encode('ascii'), b'='] info = props[propname] if 'data' in info: assert info['enctype'] == 'none' @@ -761,14 +763,14 @@ def print_result_search(properties, conf if len(data) < 80: fmt_args.append(data) else: - fmt_args.append('(%d byte document)' % info['size']) + fmt_args.append(b'(%d byte document)' % info['size']) elif info['enctype'] != 'none': - fmt_args.append('(%d byte encrypted)' % info['size']) + fmt_args.append(b'(%d byte encrypted)' % info['size']) else: - fmt_args.append('(%d byte document)' % info['size']) - fmt_args[2:] = [' '.join(fmt_args[2:])] + fmt_args.append(b'(%d byte document)' % info['size']) + fmt_args[2:] = [b' '.join(fmt_args[2:])] - print(fmt % tuple(fmt_args)) + bytes_stdout.write(fmt % tuple(fmt_args)) def run_usage(verbose=False):
AsciiField has been dropped. Object and properties names are strings now.
Problem:
Ugly fix: