Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Username consistency handling fixes #156

Merged
merged 2 commits into from
Nov 6, 2022

Conversation

scop
Copy link
Contributor

@scop scop commented Nov 6, 2022

See individual commits for details. The latter is a bit "while at it"/unrelated, but perhaps we can smuggle it in together with the actual substance of the PR.

Set up a session if only the password is given for consistency with
`User.login` behavior. Add explicit username defaults to `UserSession`
constructor and `User.login`, expose `DEFAULT_USERNAME`.
@scop
Copy link
Contributor Author

scop commented Nov 6, 2022

There's a bit of a problem with the HA integration related to this at the moment, so I would not mind a new release.

CI failure is unrelated, fix in PR #157

@Salamek Salamek merged commit 68695e4 into Salamek:master Nov 6, 2022
@scop scop deleted the refactor-username-consistency branch November 6, 2022 18:30
@Salamek
Copy link
Owner

Salamek commented Nov 17, 2022

This kinda causes an issue on devices where no login is required (USB dongles like E3372), UserSession is used due to defaulting to admin user... but then device does not support log out, so on end of code a exception is thrown



Traceback (most recent call last):
  File "/home/sadam/projects/test_huaweilte/main.py", line 7, in <module>
    with Connection('http://192.168.8.1') as connection:
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/Connection.py", line 54, in __exit__
    self.close()
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/Connection.py", line 42, in close
    self.user_session.close()
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/api/User.py", line 30, in close
    self.user.logout()
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/api/User.py", line 115, in logout
    return self._session.post_set('user/logout', {
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/Session.py", line 215, in post_set
    self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/Session.py", line 34, in wrapped
    return fn(*args, **kw)
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/Session.py", line 254, in _post
    response_data = cast(str, self._check_response_status(self._process_response_data(response)))
  File "/home/sadam/projects/test_huaweilte/venv/lib/python3.10/site-packages/huawei_lte_api/Session.py", line 156, in _check_response_status
    raise error_code_to_exception.get(error_code, ResponseErrorException)(
huawei_lte_api.exceptions.ResponseErrorNotSupportedException: 100002: No support

1.6.4 does not have this issue...

@Salamek
Copy link
Owner

Salamek commented Nov 17, 2022

Related to #159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants