From 9be43226ac7d02699354b07c50adbc06cafbf392 Mon Sep 17 00:00:00 2001 From: pgrochal Date: Thu, 24 Oct 2024 11:31:41 +0200 Subject: [PATCH] Small fixes --- README.md | 2 +- catalystwan/abstractions.py | 4 ++-- catalystwan/apigw_auth.py | 6 +++--- catalystwan/vmanage_auth.py | 5 ----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 839a818d..b2f28d84 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ from catalystwan.request_limiter import RequestLimiter auth = vManageAuth(username="username", password="password") limiter = RequestLimiter(max_requests=30) -manager = ManagerSession(base_url="https://url:port", auth=auth) +manager = ManagerSession(base_url="https://url:port", auth=auth, request_limiter=limiter) ``` diff --git a/catalystwan/abstractions.py b/catalystwan/abstractions.py index e17fdf82..63192c0f 100644 --- a/catalystwan/abstractions.py +++ b/catalystwan/abstractions.py @@ -2,8 +2,8 @@ from typing import Optional, Protocol, Type, TypeVar -from packaging.version import Version -from requests import PreparedRequest # type: ignore +from packaging.version import Version # type: ignore +from requests import PreparedRequest from catalystwan.typed_list import DataSequence from catalystwan.utils.session_type import SessionType diff --git a/catalystwan/apigw_auth.py b/catalystwan/apigw_auth.py index 6afb6a41..a8239e6b 100644 --- a/catalystwan/apigw_auth.py +++ b/catalystwan/apigw_auth.py @@ -38,7 +38,7 @@ def __init__(self, login: ApiGwLogin, logger: Optional[logging.Logger] = None, v self.token = "" self.logger = logger or logging.getLogger(__name__) self.verify = verify - self.registered_sessions: int = 0 + self.session_count: int = 0 self.lock: RLock = RLock() def __str__(self) -> str: @@ -102,11 +102,11 @@ def _clear(self) -> None: def increase_session_count(self) -> None: with self.lock: - self.registered_sessions += 1 + self.session_count += 1 def decrease_session_count(self) -> None: with self.lock: - self.registered_sessions -= 1 + self.session_count -= 1 def clear(self, last_request: Optional[PreparedRequest]) -> None: with self.lock: diff --git a/catalystwan/vmanage_auth.py b/catalystwan/vmanage_auth.py index ea469cf5..ab91dd83 100644 --- a/catalystwan/vmanage_auth.py +++ b/catalystwan/vmanage_auth.py @@ -112,10 +112,7 @@ def get_jsessionid(self) -> str: response: Response = post(url=url, headers=headers, data=security_payload, verify=self.verify) self.sync_cookies(response.cookies) self.logger.debug(auth_response_debug(response, str(self))) - if response.status_code != 200: - print("OLABOGA") if response.text != "" or not isinstance(self.jsessionid, str) or self.jsessionid == "": - print("NEIN!!!") raise UnauthorizedAccessError(self.username, self.password) return self.jsessionid @@ -131,7 +128,6 @@ def get_xsrftoken(self) -> str: self.sync_cookies(response.cookies) self.logger.debug(auth_response_debug(response, str(self))) if response.status_code != 200 or "" in response.text: - print("MAMMA MIA!") raise CatalystwanException("Failed to get XSRF token") return response.text @@ -174,7 +170,6 @@ def increase_session_count(self) -> None: def decrease_session_count(self) -> None: with self.lock: self.session_count -= 1 - print(f"Remaining: {self.session_count}") def clear(self, last_request: Optional[PreparedRequest]) -> None: with self.lock: