From dcdb6e9448f06a9c35bc443d236859b0c357fdc8 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Mon, 28 Oct 2019 18:56:47 +0000 Subject: [PATCH] Add Python3 support --- rpi-eeprom-config | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rpi-eeprom-config b/rpi-eeprom-config index ac34921..c4471a8 100755 --- a/rpi-eeprom-config +++ b/rpi-eeprom-config @@ -75,20 +75,26 @@ class BootloaderImage(object): pad = pad + 1 if self._out is not None: - self._out.write(self._bytes) - self._out.close() + self._out.write(self._bytes) + self._out.close() else: - sys.stdout.write(self._bytes) + if hasattr(sys.stdout, 'buffer'): + sys.stdout.buffer.write(self._bytes) + else: + sys.stdout.write(self._bytes) def read(self): hdr_offset, length = self.find_config() offset = hdr_offset + 4 + FILE_HDR_LEN config_bytes = self._bytes[offset:offset+length-FILENAME_LEN-4] if self._out is not None: - self._out.write(config_bytes) - self._out.close() + self._out.write(config_bytes) + self._out.close() else: - sys.stdout.write(config_bytes) + if hasattr(sys.stdout, 'buffer'): + sys.stdout.buffer.write(config_bytes) + else: + sys.stdout.write(config_bytes) def main(): parser = argparse.ArgumentParser('RPI EEPROM config tool')