Skip to content

Commit

Permalink
Merge pull request #169 from scop/feat/usersession-close-suppressions
Browse files Browse the repository at this point in the history
Suppress login required and not supported on UserSession close
  • Loading branch information
Salamek authored Jan 15, 2023
2 parents ab0ffb0 + f15812c commit aefc8df
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion huawei_lte_api/api/User.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
LoginErrorUsernamePasswordWrongException, \
LoginErrorUsernameWrongException, \
LoginErrorPasswordWrongException, \
ResponseErrorLoginRequiredException, \
ResponseErrorNotSupportedException

DEFAULT_USERNAME = 'admin'
Expand All @@ -27,7 +28,11 @@ def __init__(self, session: Session, username: str = DEFAULT_USERNAME, password:
self.user.login(username, password, True)

def close(self) -> None:
self.user.logout()
try:
self.user.logout()
except (ResponseErrorLoginRequiredException, ResponseErrorNotSupportedException):
# Idempotency/nothing further to do, suppress
pass

def __enter__(self) -> 'UserSession':
return self
Expand Down

0 comments on commit aefc8df

Please sign in to comment.