From afdd27c551eda671c8698344d4be72deba1fb734 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sun, 16 Jul 2017 15:03:01 +0200 Subject: [PATCH] trezorctl: fix set_homescreen for python3 --- trezorctl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trezorctl b/trezorctl index 15a2dc6d1a..6e3019a89c 100755 --- a/trezorctl +++ b/trezorctl @@ -194,13 +194,15 @@ def set_homescreen(client, filename): raise CallException(types.Failure_DataError, 'Wrong size of the image') im = im.convert('1') pix = im.load() - img = '' + img = bytearray(1024) for j in range(64): for i in range(128): - img += '1' if pix[i, j] else '0' - img = ''.join(chr(int(img[i:i + 8], 2)) for i in range(0, len(img), 8)) + if pix[i, j]: + o = (i + j * 128) + img[o // 8] |= (1 << (7 - o % 8)) + img = bytes(img) else: - img = '\x00' + img = b'\x00' return client.apply_settings(homescreen=img)