Skip to content

Commit

Permalink
fix: handling otp error
Browse files Browse the repository at this point in the history
  • Loading branch information
flobz committed Feb 26, 2024
1 parent 9a93f73 commit 1e974a9
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions psa_car_controller/psa/otp/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,19 @@ def _get_otp_code(self):
def get_otp_code(self):
self.mode = Otp.OTP_MODE
otp_code = None
if self.activation_start():
res = self.activation_finalyze()
if res != Otp.NOK:
if res == Otp.OTP_TWICE:
self.mode = Otp.OTP_MODE
self.activation_start()
self.activation_finalyze()
otp_code = self._get_otp_code()
logger.debug("otp code: %s", otp_code)
if otp_code is None:
raise ConfigException("Can't get otp code")
try:
if self.activation_start():
res = self.activation_finalyze()
if res != Otp.NOK:
if res == Otp.OTP_TWICE:
self.mode = Otp.OTP_MODE
self.activation_start()
assert self.activation_finalyze() == Otp.OK
otp_code = self._get_otp_code()
assert otp_code is not None
logger.debug("otp code: %s", otp_code)
except AssertionError as e:
raise ConfigException("Can't get otp code") from e
return otp_code

def __getstate__(self):
Expand Down

0 comments on commit 1e974a9

Please sign in to comment.