From 83faada55ba2aa302d308e7982da0727c606d758 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Thu, 21 Jan 2021 21:46:11 +0100 Subject: [PATCH 1/2] Improve Encryption Method enum --- sagemcom_api/enums.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sagemcom_api/enums.py b/sagemcom_api/enums.py index 897ebb4..a8bb59d 100644 --- a/sagemcom_api/enums.py +++ b/sagemcom_api/enums.py @@ -4,12 +4,7 @@ class EncryptionMethod(Enum): - """TODO.""" + """Encryption method defining the password hash.""" - def __str__(self): - """TODO.""" - return str(self.value) - - MD5 = "md5" - SHA512 = "sha512" - UNKNOWN = "unknown" + MD5 = "MD5" + SHA512 = "SHA512" From 7fb81874f854511953393e69d6e37a07dbbe4ddd Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Thu, 21 Jan 2021 23:37:15 +0100 Subject: [PATCH 2/2] Bugfix & update readme --- README.md | 31 ++++++++++++++++--------------- sagemcom_api/client.py | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0d58bf4..bdaf8f1 100644 --- a/README.md +++ b/README.md @@ -15,19 +15,19 @@ Python 3.7+ required. The Sagemcom F@st series is used by multiple cable companies, where some cable companies did rebrand the router. Examples are the b-box from Proximus, Home Hub from bell and the Smart Hub from BT. -| Router Model | Provider(s) | Authentication Method | -| -------------------- | -------------------- | --------------------- | -| Sagemcom F@st 3864 | Optus | sha512 | -| Sagemcom F@st 3865b | Proximus (b-box3) | md5 | -| Sagemcom F@st 3890V3 | Delta / Zeelandnet | md5 | -| Sagemcom F@st 4360Air| KPN | md5 | -| Sagemcom F@st 5250 | Bell (Home Hub 2000) | md5 | -| Sagemcom F@st 5280 | | sha512 | -| Sagemcom F@st 5364 | BT (Smart Hub) | md5 | -| Sagemcom F@st 5370e | Telia | sha512 | -| Sagemcom F@st 5566 | Bell (Home Hub 3000) | md5 | -| Sagemcom F@st 5655V2 | MásMóvil | md5 | -| Speedport Pro | Telekom | md5 | +| Router Model | Provider(s) | Authentication Method | Comments | +| --------------------- | -------------------- | --------------------- | ----------------------------- | +| Sagemcom F@st 3864 | Optus | sha512 | username: guest, password: "" | +| Sagemcom F@st 3865b | Proximus (b-box3) | md5 | | +| Sagemcom F@st 3890V3 | Delta / Zeelandnet | md5 | | +| Sagemcom F@st 4360Air | KPN | md5 | | +| Sagemcom F@st 5250 | Bell (Home Hub 2000) | md5 | username: guest, password: "" | +| Sagemcom F@st 5280 | | sha512 | | +| Sagemcom F@st 5364 | BT (Smart Hub) | md5 | username: guest, password: "" | +| Sagemcom F@st 5370e | Telia | sha512 | | +| Sagemcom F@st 5566 | Bell (Home Hub 3000) | md5 | username: guest, password: "" | +| Sagemcom F@st 5655V2 | MásMóvil | md5 | | +| Speedport Pro | Telekom | md5 | | > Contributions welcome. If you router model is supported by this package, but not in the list above, please create [an issue](https://github.com/iMicknl/python-sagemcom-api/issues/new) or pull request. @@ -96,9 +96,11 @@ asyncio.run(main()) ## Advanced ### Determine the EncryptionMethod + (not supported yet) ### Handle exceptions + Some functions may cause an error when an attempt is made to execute it. These exceptions are thrown by the client and need to be [handled in your Python program](https://docs.python.org/3/tutorial/errors.html#handling-exceptions). Best practice is to catch some specific exceptions and handle them gracefully. ```python @@ -123,7 +125,7 @@ except Exception as exception: print(exception) ``` -### Use your own aiohttp ClientSession +### Use your own aiohttp ClientSession > ClientSession is the heart and the main entry point for all client API operations. The session contains a cookie storage and connection pool, thus cookies and connections are shared between HTTP requests sent by the same session. @@ -136,7 +138,6 @@ session = ClientSession(timeout=ClientTimeout(100)) client = SagemcomClient(session=session) ``` - ## Inspired by - [wuseman/SAGEMCOM-FAST-5370e-TELIA](https://github.com/wuseman/SAGEMCOM-FAST-5370e-TELIA) diff --git a/sagemcom_api/client.py b/sagemcom_api/client.py index fc14eff..a16ac18 100644 --- a/sagemcom_api/client.py +++ b/sagemcom_api/client.py @@ -47,7 +47,7 @@ def __init__( host, username, password, - authentication_method=EncryptionMethod.UNKNOWN, + authentication_method, session: ClientSession = None, ): """