Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions synology_drive_api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class SynologySession:
# dsm version, used for login api version
dsm_version: str = '6'
max_retry: int = 2
timeout: int = 30

def __init__(self,
username: str,
Expand All @@ -151,6 +152,7 @@ def __init__(self,
https: Optional[bool] = True,
dsm_version: str = '6',
max_retry: int = 2,
timeout: int = 30,
otp_code: Optional[str] = None) -> None:
assert dsm_version in ('6', '7'), "dsm_version should be either '6' or '7'."

Expand All @@ -162,6 +164,7 @@ def __init__(self,
self._base_url = f"{nas_address}/webapi/"
self.req_session.cookies.set_policy(BlockAll())
self.max_retries = max_retry
self.timeout = timeout

def _request(self, method: str, endpoint: str, **kwargs):
"""
Expand Down Expand Up @@ -199,6 +202,7 @@ def _request(self, method: str, endpoint: str, **kwargs):
res = self.req_session.request(
method=method,
url=url,
timeout=self.timeout,
**kwargs
)
raise_synology_exception(res, bio_exist=bio_flag)
Expand All @@ -208,6 +212,7 @@ def _request(self, method: str, endpoint: str, **kwargs):
res = self.req_session.request(
method=method,
url=url,
timeout=self.timeout,
**kwargs
)
raise_synology_exception(res, bio_exist=bio_flag)
Expand Down
3 changes: 2 additions & 1 deletion synology_drive_api/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def __init__(self,
enable_label_cache: bool = True,
dsm_version: str = '6',
max_retry: int = 2,
timeout: int = 30,
otp_code: Optional[str] = None) -> None:
self.session = SynologySession(username, password, ip_address, port, nas_domain, https, dsm_version, max_retry,
otp_code)
timeout, otp_code)
self.enable_label_cache = enable_label_cache

def __enter__(self):
Expand Down