Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzeG committed Oct 24, 2024
1 parent 5228622 commit 9be4322
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
</details>

Expand Down
4 changes: 2 additions & 2 deletions catalystwan/abstractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions catalystwan/apigw_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions catalystwan/vmanage_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 "<html>" in response.text:
print("MAMMA MIA!")
raise CatalystwanException("Failed to get XSRF token")
return response.text

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9be4322

Please sign in to comment.