Salamek / huawei-lte-api

API For huawei LAN/WAN LTE Modems
GNU Lesser General Public License v3.0
376 stars 92 forks source link

Username consistency handling fixes #156

Closed scop closed 2 years ago

scop commented 2 years ago

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.

scop commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Related to https://github.com/Salamek/huawei-lte-api/issues/159