Skip to content

Commit

Permalink
Lazy init modules
Browse files Browse the repository at this point in the history
Fixes "ERROR: Only nop and sig tag can be recevied before authentication." message before authentification

Signed-off-by: Dinolek <[email protected]>
  • Loading branch information
Dinolek committed Jul 7, 2024
1 parent ec43594 commit f2a04c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
29 changes: 18 additions & 11 deletions edlclient/Library/Modules/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# GPLv3 and has to be open sourced under GPLv3 as well. !!!!!

import logging
from functools import cached_property

from edlclient.Library.utils import LogBase

try:
Expand Down Expand Up @@ -52,25 +54,31 @@ def __init__(self, fh, serial: int, supported_functions, loglevel, devicemodel:
self.__logger.addHandler(fh)
self.options = {}
self.devicemodel = devicemodel
self.generic = None

@cached_property
def generic(self):
try:
self.generic = generic(fh=self.fh, serial=self.serial, args=self.args, loglevel=loglevel)
return generic(fh=self.fh, serial=self.serial, args=self.args, loglevel=self.__logger.loglevel)
except Exception as e:
self.error(e)
pass
self.ops = None
return None

@cached_property
def ops(self):
try:
self.ops = oneplus(fh=self.fh, projid=self.devicemodel, serial=self.serial,
supported_functions=self.supported_functions, args=self.args, loglevel=loglevel)
return oneplus(fh=self.fh, projid=self.devicemodel, serial=self.serial, loglevel=self.__logger.loglevel,
supported_functions=self.supported_functions, args=self.args)
except Exception as e:
self.error(e)
pass
self.xiaomi = None
return None

@cached_property
def xiaomi(self):
try:
self.xiaomi = xiaomi(fh=self.fh)
return xiaomi(fh=self.fh)
except Exception as e:
self.error(e)
pass
return None

def addpatch(self):
if self.ops is not None:
Expand Down Expand Up @@ -116,7 +124,6 @@ def run(self, command, args):
return self.generic.oem_unlock(enable)
elif self.ops is not None and command == "ops":
if self.devicemodel is not None:
enable = False
partition = "param"
if "enable" in options:
enable = True
Expand Down
1 change: 1 addition & 0 deletions edlclient/Library/firehose.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ def configure(self, lvl):
except Exception as err: # pylint: disable=broad-except
self.modules = None
if self.modules.edlauth():
self.info("EDL Authenticated successfully.")
rsp = self.xmlsend(connectcmd)
return rsp.resp
else:
Expand Down

0 comments on commit f2a04c8

Please sign in to comment.