-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nonce, add auto retry on auth exception, fix session id int, impr…
…ove code quality (#336) This pull request includes several changes to improve error handling, enhance functionality, and update configurations. The most important changes include adding new exception handling for invalid sessions, updating the `postCreateCommand` in the devcontainer, and adding custom funding options. ### Error Handling Improvements: * Added `InvalidSessionException` to handle invalid session errors and updated relevant methods to raise this exception when needed (`sagemcom_api/client.py`, `sagemcom_api/const.py`, `sagemcom_api/exceptions.py`). [[1]](diffhunk://#diff-052218051094ff1cc2c8352cd555cfb9eb02bf261eb5e635cf73b798809306a5R32) [[2]](diffhunk://#diff-052218051094ff1cc2c8352cd555cfb9eb02bf261eb5e635cf73b798809306a5R46) [[3]](diffhunk://#diff-052218051094ff1cc2c8352cd555cfb9eb02bf261eb5e635cf73b798809306a5R220-R225) [[4]](diffhunk://#diff-57cf505b5e01fc69f170c5a1b839fb40b45a97a9c0ebc1fe53f4bd524ae9ac04R10) [[5]](diffhunk://#diff-63c847110513149341a9f7e94d412bfb7c67d79df07a321774a9a2f3329ca34fR4-L43) * Introduced `retry_login` function to retry login on specific exceptions using backoff (`sagemcom_api/client.py`). [[1]](diffhunk://#diff-052218051094ff1cc2c8352cd555cfb9eb02bf261eb5e635cf73b798809306a5R58-R62) [[2]](diffhunk://#diff-052218051094ff1cc2c8352cd555cfb9eb02bf261eb5e635cf73b798809306a5R260-R270) ### Functional Enhancements: * Modified `get_hosts` method to include `capability-flags` in the options for retrieving hosts (`sagemcom_api/client.py`). * Corrected the nonce generation logic to use the correct range (`sagemcom_api/client.py`). ### Configuration Updates: * Updated `postCreateCommand` in `.devcontainer/devcontainer.json` to include `pre-commit install-hooks` for better pre-commit setup. * Added a custom funding option in `.github/FUNDING.yml` to include a PayPal link.
- Loading branch information
Showing
5 changed files
with
63 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
custom: ["https://paypal.me/imick"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,51 @@ | ||
"""Exceptions for the Sagemcom F@st client.""" | ||
|
||
|
||
class BaseSagemcomException(Exception): | ||
"""Base exception for Sagemcom F@st client.""" | ||
|
||
|
||
# Broad exceptions provided by this library | ||
class BadRequestException(BaseSagemcomException): | ||
"""Bad request.""" | ||
|
||
|
||
class UnauthorizedException(BaseSagemcomException): | ||
"""Unauthorized.""" | ||
|
||
|
||
class UnknownException(BaseSagemcomException): | ||
"""Unknown exception.""" | ||
|
||
|
||
# Exceptions provided by SagemCom API | ||
class AccessRestrictionException(Exception): | ||
class AccessRestrictionException(BaseSagemcomException): | ||
"""Raised when current user has access restrictions.""" | ||
|
||
|
||
class AuthenticationException(Exception): | ||
class AuthenticationException(UnauthorizedException): | ||
"""Raised when authentication is not correct.""" | ||
|
||
|
||
class LoginRetryErrorException(Exception): | ||
class InvalidSessionException(UnauthorizedException): | ||
"""Raised when session is invalid.""" | ||
|
||
|
||
class LoginRetryErrorException(BaseSagemcomException): | ||
"""Raised when too many login retries are attempted.""" | ||
|
||
|
||
class LoginTimeoutException(Exception): | ||
class LoginTimeoutException(BaseSagemcomException): | ||
"""Raised when a timeout is encountered during login.""" | ||
|
||
|
||
class NonWritableParameterException(Exception): | ||
class NonWritableParameterException(BaseSagemcomException): | ||
"""Raised when provided parameter is not writable.""" | ||
|
||
|
||
class UnknownPathException(Exception): | ||
class UnknownPathException(BaseSagemcomException): | ||
"""Raised when provided path does not exist.""" | ||
|
||
|
||
class MaximumSessionCountException(Exception): | ||
class MaximumSessionCountException(BaseSagemcomException): | ||
"""Raised when the maximum session count is reached.""" | ||
|
||
|
||
# Broad exceptions provided by this library | ||
class BadRequestException(Exception): | ||
"""TODO.""" | ||
|
||
|
||
class UnauthorizedException(Exception): | ||
"""TODO.""" | ||
|
||
|
||
class UnknownException(Exception): | ||
"""TODO.""" |