Merge pull request #45 from MilhouseVH/fix_py2_py3

Add Python3 support
This commit is contained in:
timg
2019-10-29 10:37:31 +00:00
committed by GitHub

View File

@@ -77,6 +77,9 @@ class BootloaderImage(object):
if self._out is not None: if self._out is not None:
self._out.write(self._bytes) self._out.write(self._bytes)
self._out.close() self._out.close()
else:
if hasattr(sys.stdout, 'buffer'):
sys.stdout.buffer.write(self._bytes)
else: else:
sys.stdout.write(self._bytes) sys.stdout.write(self._bytes)
@@ -87,6 +90,9 @@ class BootloaderImage(object):
if self._out is not None: if self._out is not None:
self._out.write(config_bytes) self._out.write(config_bytes)
self._out.close() self._out.close()
else:
if hasattr(sys.stdout, 'buffer'):
sys.stdout.buffer.write(config_bytes)
else: else:
sys.stdout.write(config_bytes) sys.stdout.write(config_bytes)