From 24e5b4a9a86cb6a54bd582adeda57e43c4f73433 Mon Sep 17 00:00:00 2001 From: keepkeyjon Date: Mon, 5 Feb 2018 13:00:53 -0700 Subject: [PATCH] Fix upload via python3 --- keepkeyctl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/keepkeyctl b/keepkeyctl index b6d105a8..113af94a 100755 --- a/keepkeyctl +++ b/keepkeyctl @@ -297,7 +297,7 @@ class Commands(object): raise Exception("Must provide firmware filename or URL") if args.file: - fp = open(args.file, 'r') + fp = open(args.file, 'rb') elif args.url: print("Downloading from", args.url) resp = urllib.urlretrieve(args.url) @@ -316,8 +316,9 @@ class Commands(object): fp_old.close() fp.seek(0) - if fp.read(4) != 'KPKY': - raise Exception("KeepKey firmware header expected") + magic = fp.read(4).decode("utf-8") + if magic != 'KPKY': + raise Exception("KeepKey firmware header expected. magic={}".format(magic)) print("Please confirm action on device...")