From 13482aa0e8e03a2e47aeae1aa9adc3104ed98af9 Mon Sep 17 00:00:00 2001 From: greateggsgreg Date: Mon, 7 May 2018 16:17:14 +1000 Subject: [PATCH 1/4] Removed unnecessary semicolons from config.py --- config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 05d4887..81925f9 100644 --- a/config.py +++ b/config.py @@ -52,19 +52,19 @@ def get_config(cls): for k in parser.options("root"): try: cfg[k] = parser.getboolean("root", k) - continue; + continue except ValueError: pass try: cfg[k] = parser.getint("root", k) - continue; + continue except ValueError: pass try: cfg[k] = parser.getfloat("root", k) - continue; + continue except ValueError: pass From 56346cb6984ff1e6c2b0ebd79e3898deb1e6fc42 Mon Sep 17 00:00:00 2001 From: greateggsgreg Date: Mon, 7 May 2018 16:17:43 +1000 Subject: [PATCH 2/4] Improved error reporting when image is skipped in image.py --- image.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/image.py b/image.py index 57c0d57..ac6c57c 100644 --- a/image.py +++ b/image.py @@ -28,7 +28,10 @@ def add(path): for root,dirs,files in os.walk(path): for f in files: T(f) - add_image(os.path.join(root, f)) + if add_image(os.path.join(root, f)): + print("Added: {}".format(f)) + else: + print("Skipped: {}".format(f)) def add_image(path): @@ -78,7 +81,7 @@ def add_aboot(archive): if bl.save('%s/%s-%s-%s.json' % (Config.data_path, bl.oem, bl.device, bl.build)): skipped = "" - I("%s (%d) %s" % (bl, len(bl.strings), skipped)) + I("%s (%d) %s SAVING" % (bl, len(bl.strings), skipped)) return bl From 7b9bbdd0a499eb433bbedb888e01758c6c927910 Mon Sep 17 00:00:00 2001 From: greateggsgreg Date: Tue, 8 May 2018 11:12:06 +1000 Subject: [PATCH 3/4] Updated fastboot api to conform to new python-adb changes. Switched to pycryptodome --- device.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/device.py b/device.py index 8d4f98f..3a42a58 100644 --- a/device.py +++ b/device.py @@ -5,7 +5,7 @@ import os import re from serializable import Serializable -from adb import fastboot,common,usb_exceptions,adb_commands, sign_m2crypto +from adb import fastboot,common,usb_exceptions,adb_commands, sign_pycryptodome from log import * from config import Config from enum import Enum @@ -132,11 +132,19 @@ def wait_for_fastboot(self): self.wait_for_device() def adb(self): - signer = sign_m2crypto.M2CryptoSigner(os.path.expanduser(Config.adb_key_path)) - return adb_commands.AdbCommands.Connect(self.usbdev, rsa_keys=[signer]) + signer = sign_pycryptodome.PycryptodomeAuthSigner(os.path.expanduser(Config.adb_key_path)) + device = adb_commands.AdbCommands() + return device.ConnectDevice(rsa_keys=[signer]) def fastboot(self): - return fastboot.FastbootCommands(self.usbdev) + cmds = fastboot.FastbootCommands() + while True: + try: + dev = cmds.ConnectDevice() + return dev + except: + print("Device offline, go back to bootloader!") + time.sleep(3) def serial_number(self): self.wait_for_device() @@ -222,7 +230,7 @@ def oem(self, cmd, allow_timeout=False, allow_usb_error = False): raise FastbootCommandNotFound() raise FastbootTimeoutException - except FastbootRemoteFailure, e: + except FastbootRemoteFailure as e: r = self.get_last_fb_output() error = e.msg if self.is_fb_error(error+r, cmd): From 5c79cf2f83f6a0b0408e385bd83c407720c33839 Mon Sep 17 00:00:00 2001 From: greateggsgreg Date: Thu, 10 May 2018 13:38:17 +1000 Subject: [PATCH 4/4] Migrated to python3 compatible file open functions --- aboot.py | 3 ++- config.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/aboot.py b/aboot.py index 5d776f5..e688b45 100644 --- a/aboot.py +++ b/aboot.py @@ -72,7 +72,8 @@ def all(): class ABOOT(Serializable): @classmethod def create_from_json(cls, path): - data = json.load(file(path, "rb")) + with open(path, "rb") as fh: + data = json.load(fh) return ABOOT().set_data(data) @classmethod diff --git a/config.py b/config.py index 81925f9..a88fb57 100644 --- a/config.py +++ b/config.py @@ -41,9 +41,11 @@ def get_config(cls): global config if not config: config = Config() - config.set_data(json.load(file(DATA_PATH, "rb"))) + with open(DATA_PATH, "rb") as fh: + config.set_data(json.load(fh)) - data = "[root]\n"+file(USER_CONFIG_PATH, "rb").read() + with open(USER_CONFIG_PATH, "rb") as fh: + data = "[root]\n"+fh.read() fp = io.BytesIO(data) parser = ConfigParser.RawConfigParser() parser.readfp(fp)