Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -52,19 +54,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

Expand Down
18 changes: 13 additions & 5 deletions device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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


Expand Down