saviialib 1.2.6__py3-none-any.whl → 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of saviialib might be problematic. Click here for more details.
- saviialib/__init__.py +71 -3
- saviialib/general_types/api/__init__.py +0 -3
- saviialib/general_types/api/{epii_api_types.py → saviia_api_types.py} +2 -39
- saviialib/general_types/api/saviia_backup_api_types.py +24 -0
- saviialib/general_types/api/saviia_thies_api_types.py +31 -0
- saviialib/libs/sharepoint_client/clients/sharepoint_rest_api.py +7 -4
- saviialib/services/backup/api.py +36 -0
- saviialib/services/{epii → backup}/controllers/types/__init__.py +1 -1
- saviialib/services/{epii → backup}/controllers/types/upload_backup_to_sharepoint_types.py +2 -2
- saviialib/services/{epii → backup}/controllers/upload_backup_to_sharepoint.py +5 -5
- saviialib/services/{epii → backup}/use_cases/types/__init__.py +1 -1
- saviialib/services/{epii → backup}/use_cases/types/upload_backup_to_sharepoint_types.py +1 -1
- saviialib/services/{epii → backup}/use_cases/upload_backup_to_sharepoint.py +2 -2
- saviialib/services/backup/utils/__init__.py +3 -0
- saviialib/services/{epii → backup}/utils/upload_backup_to_sharepoint_utils.py +1 -1
- saviialib/services/thies/__init__.py +0 -0
- saviialib/services/thies/api.py +35 -0
- saviialib/services/{epii → thies}/controllers/types/update_thies_data_types.py +2 -4
- saviialib/services/{epii → thies}/controllers/update_thies_data.py +4 -4
- saviialib/services/{epii → thies}/use_cases/components/create_thies_statistics_file.py +10 -1
- saviialib/services/{epii → thies}/use_cases/types/update_thies_data_types.py +1 -1
- saviialib/services/{epii → thies}/use_cases/update_thies_data.py +19 -12
- {saviialib-1.2.6.dist-info → saviialib-1.4.0.dist-info}/METADATA +5 -3
- saviialib-1.4.0.dist-info/RECORD +61 -0
- {saviialib-1.2.6.dist-info → saviialib-1.4.0.dist-info}/WHEEL +1 -1
- saviialib/services/epii/api.py +0 -94
- saviialib/services/epii/utils/__init__.py +0 -3
- saviialib-1.2.6.dist-info/RECORD +0 -57
- /saviialib/general_types/error_types/api/{epii_api_error_types.py → saviia_api_error_types.py} +0 -0
- /saviialib/services/{epii → backup}/__init__.py +0 -0
- /saviialib/services/{epii → backup}/controllers/__init__.py +0 -0
- /saviialib/services/{epii → backup}/use_cases/constants/upload_backup_to_sharepoint_constants.py +0 -0
- /saviialib/services/{epii → thies}/use_cases/components/thies_bp.py +0 -0
- /saviialib/services/{epii → thies}/utils/update_thies_data_utils.py +0 -0
- {saviialib-1.2.6.dist-info → saviialib-1.4.0.dist-info/licenses}/LICENSE +0 -0
saviialib/__init__.py
CHANGED
|
@@ -3,7 +3,75 @@ from importlib.metadata import version
|
|
|
3
3
|
|
|
4
4
|
__version__ = version("saviialib")
|
|
5
5
|
|
|
6
|
-
from .
|
|
7
|
-
from .general_types.api.epii_api_types import EpiiAPIConfig
|
|
6
|
+
from .general_types.api.saviia_api_types import SaviiaAPIConfig
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
from typing import Dict, Type, Any, overload, Literal, List
|
|
9
|
+
|
|
10
|
+
from saviialib.services.backup.api import SaviiaBackupAPI
|
|
11
|
+
from saviialib.services.thies.api import SaviiaThiesAPI
|
|
12
|
+
from saviialib.general_types.api.saviia_thies_api_types import SaviiaThiesConfig
|
|
13
|
+
from saviialib.general_types.api.saviia_backup_api_types import SaviiaBackupConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SaviiaAPI:
|
|
17
|
+
API_REGISTRY: Dict[str, Type] = {
|
|
18
|
+
"thies": SaviiaThiesAPI,
|
|
19
|
+
"backup": SaviiaBackupAPI,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@overload
|
|
23
|
+
def get(self, name: Literal["thies"]) -> SaviiaThiesAPI: ...
|
|
24
|
+
@overload
|
|
25
|
+
def get(self, name: Literal["backup"]) -> SaviiaBackupAPI: ...
|
|
26
|
+
|
|
27
|
+
def __init__(self, config: SaviiaAPIConfig):
|
|
28
|
+
"""
|
|
29
|
+
Receive a dictionary of configurations, with the same key
|
|
30
|
+
as those registered in API_REGISTRY.
|
|
31
|
+
|
|
32
|
+
:params configs: Dictionary of configurations for each API.
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
configs = {
|
|
36
|
+
"thies": SaviiaThiesConfig(...),
|
|
37
|
+
"backup": SaviiaBackupConfig(...)
|
|
38
|
+
}
|
|
39
|
+
"""
|
|
40
|
+
self._instances: Dict[str, Any] = {}
|
|
41
|
+
|
|
42
|
+
for name, api_class in SaviiaAPI.API_REGISTRY.items():
|
|
43
|
+
if name == "thies":
|
|
44
|
+
service_config = SaviiaThiesConfig(
|
|
45
|
+
ftp_host=config.ftp_host,
|
|
46
|
+
ftp_port=config.ftp_port,
|
|
47
|
+
ftp_user=config.ftp_user,
|
|
48
|
+
ftp_password=config.ftp_password,
|
|
49
|
+
sharepoint_client_id=config.sharepoint_client_id,
|
|
50
|
+
sharepoint_client_secret=config.sharepoint_client_secret,
|
|
51
|
+
sharepoint_tenant_id=config.sharepoint_tenant_id,
|
|
52
|
+
sharepoint_tenant_name=config.sharepoint_tenant_name,
|
|
53
|
+
sharepoint_site_name=config.sharepoint_site_name,
|
|
54
|
+
logger=config.logger,
|
|
55
|
+
)
|
|
56
|
+
elif name == "backup":
|
|
57
|
+
service_config = SaviiaBackupConfig(
|
|
58
|
+
sharepoint_client_id=config.sharepoint_client_id,
|
|
59
|
+
sharepoint_client_secret=config.sharepoint_client_secret,
|
|
60
|
+
sharepoint_tenant_id=config.sharepoint_tenant_id,
|
|
61
|
+
sharepoint_tenant_name=config.sharepoint_tenant_name,
|
|
62
|
+
sharepoint_site_name=config.sharepoint_site_name,
|
|
63
|
+
logger=config.logger,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
self._instances[name] = api_class(service_config)
|
|
67
|
+
|
|
68
|
+
def get(self, name: Literal["thies", "backup"]) -> Any:
|
|
69
|
+
"""Returns the API instance associated with the given name."""
|
|
70
|
+
try:
|
|
71
|
+
return self._instances[name]
|
|
72
|
+
except KeyError:
|
|
73
|
+
raise ValueError(f"API '{name}' is not registered or not configured.")
|
|
74
|
+
|
|
75
|
+
def list_available(self) -> List[str]:
|
|
76
|
+
"""List of available registered APIs."""
|
|
77
|
+
return list(self._instances.keys())
|
|
@@ -3,9 +3,9 @@ from logging import Logger
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
@dataclass
|
|
6
|
-
class
|
|
6
|
+
class SaviiaAPIConfig:
|
|
7
7
|
"""
|
|
8
|
-
Configuration for
|
|
8
|
+
Configuration for SAVIIA API.
|
|
9
9
|
|
|
10
10
|
Attributes:
|
|
11
11
|
ftp_port (int): Port number of the FTP server.
|
|
@@ -30,7 +30,6 @@ class EpiiAPIConfig:
|
|
|
30
30
|
sharepoint_site_name: str
|
|
31
31
|
logger: Logger
|
|
32
32
|
|
|
33
|
-
|
|
34
33
|
@dataclass
|
|
35
34
|
class FtpClientConfig:
|
|
36
35
|
ftp_host: str
|
|
@@ -46,39 +45,3 @@ class SharepointConfig:
|
|
|
46
45
|
sharepoint_tenant_id: str
|
|
47
46
|
sharepoint_tenant_name: str
|
|
48
47
|
sharepoint_site_name: str
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@dataclass
|
|
52
|
-
class EpiiUpdateThiesConfig:
|
|
53
|
-
ftp_port: int
|
|
54
|
-
ftp_host: str
|
|
55
|
-
ftp_user: str
|
|
56
|
-
ftp_password: str
|
|
57
|
-
sharepoint_client_id: str
|
|
58
|
-
sharepoint_client_secret: str
|
|
59
|
-
sharepoint_tenant_id: str
|
|
60
|
-
sharepoint_tenant_name: str
|
|
61
|
-
sharepoint_site_name: str
|
|
62
|
-
logger: Logger
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@dataclass
|
|
66
|
-
class EpiiSharepointBackupConfig:
|
|
67
|
-
"""
|
|
68
|
-
Configuration for backing up files to SharePoint.
|
|
69
|
-
|
|
70
|
-
Attributes:
|
|
71
|
-
sharepoint_client_id (str): Client ID for SharePoint authentication.
|
|
72
|
-
sharepoint_client_secret (str): Client secret for SharePoint authentication.
|
|
73
|
-
sharepoint_tenant_id (str): Tenant ID for SharePoint authentication.
|
|
74
|
-
sharepoint_tenant_name (str): Tenant name for SharePoint.
|
|
75
|
-
sharepoint_site_name (str): Site name in SharePoint.
|
|
76
|
-
local_backup_source_path (str): Local path to backup.
|
|
77
|
-
"""
|
|
78
|
-
|
|
79
|
-
sharepoint_client_id: str
|
|
80
|
-
sharepoint_client_secret: str
|
|
81
|
-
sharepoint_tenant_id: str
|
|
82
|
-
sharepoint_tenant_name: str
|
|
83
|
-
sharepoint_site_name: str
|
|
84
|
-
logger: Logger
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from logging import Logger
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class SaviiaBackupConfig:
|
|
7
|
+
"""
|
|
8
|
+
Configuration for backing up files to SharePoint.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
sharepoint_client_id (str): Client ID for SharePoint authentication.
|
|
12
|
+
sharepoint_client_secret (str): Client secret for SharePoint authentication.
|
|
13
|
+
sharepoint_tenant_id (str): Tenant ID for SharePoint authentication.
|
|
14
|
+
sharepoint_tenant_name (str): Tenant name for SharePoint.
|
|
15
|
+
sharepoint_site_name (str): Site name in SharePoint.
|
|
16
|
+
local_backup_source_path (str): Local path to backup.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
sharepoint_client_id: str
|
|
20
|
+
sharepoint_client_secret: str
|
|
21
|
+
sharepoint_tenant_id: str
|
|
22
|
+
sharepoint_tenant_name: str
|
|
23
|
+
sharepoint_site_name: str
|
|
24
|
+
logger: Logger
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from logging import Logger
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class SaviiaThiesConfig:
|
|
7
|
+
"""
|
|
8
|
+
Configuration for Saviia Thies.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
ftp_port (int): Port number of the FTP server.
|
|
12
|
+
ftp_host (str): Hostname or IP address of the FTP server.
|
|
13
|
+
ftp_user (str): Username for the FTP server.
|
|
14
|
+
ftp_password (str): Password for the FTP server.
|
|
15
|
+
sharepoint_client_id (str): Client ID for SharePoint authentication.
|
|
16
|
+
sharepoint_client_secret (str): Client secret for SharePoint authentication.
|
|
17
|
+
sharepoint_tenant_id (str): Tenant ID for SharePoint authentication.
|
|
18
|
+
sharepoint_tenant_name (str): Tenant name for SharePoint.
|
|
19
|
+
sharepoint_site_name (str): Site name in SharePoint.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
ftp_host: str
|
|
23
|
+
ftp_port: int
|
|
24
|
+
ftp_user: str
|
|
25
|
+
ftp_password: str
|
|
26
|
+
sharepoint_client_id: str
|
|
27
|
+
sharepoint_client_secret: str
|
|
28
|
+
sharepoint_tenant_id: str
|
|
29
|
+
sharepoint_tenant_name: str
|
|
30
|
+
sharepoint_site_name: str
|
|
31
|
+
logger: Logger
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
import json
|
|
3
|
-
from aiohttp import ClientError, ClientSession
|
|
3
|
+
from aiohttp import ClientError, ClientSession, TCPConnector
|
|
4
4
|
from dotenv import load_dotenv
|
|
5
|
+
import ssl
|
|
6
|
+
import certifi
|
|
5
7
|
|
|
6
8
|
from saviialib.libs.sharepoint_client.sharepoint_client_contract import (
|
|
7
9
|
SharepointClientContract,
|
|
@@ -15,7 +17,7 @@ from saviialib.libs.sharepoint_client.types.sharepoint_client_types import (
|
|
|
15
17
|
)
|
|
16
18
|
|
|
17
19
|
load_dotenv()
|
|
18
|
-
|
|
20
|
+
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
|
19
21
|
|
|
20
22
|
class SharepointRestAPI(SharepointClientContract):
|
|
21
23
|
def __init__(self, args: SharepointClientInitArgs):
|
|
@@ -51,7 +53,7 @@ class SharepointRestAPI(SharepointClientContract):
|
|
|
51
53
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
async with ClientSession() as session:
|
|
56
|
+
async with ClientSession(connector=TCPConnector(ssl=ssl_context)) as session:
|
|
55
57
|
# Load access token
|
|
56
58
|
response = await session.post(url, data=payload, headers=headers)
|
|
57
59
|
if response.status != 200:
|
|
@@ -75,8 +77,9 @@ class SharepointRestAPI(SharepointClientContract):
|
|
|
75
77
|
"Content-Type": "application/json",
|
|
76
78
|
}
|
|
77
79
|
self.base_url = f"{site_url}/sites/{self.site_name}/_api/"
|
|
80
|
+
connector = TCPConnector(ssl=ssl_context)
|
|
78
81
|
self.session = ClientSession(
|
|
79
|
-
headers=self.base_headers, base_url=self.base_url
|
|
82
|
+
headers=self.base_headers, base_url=self.base_url, connector=connector
|
|
80
83
|
)
|
|
81
84
|
return self
|
|
82
85
|
except ClientError as error:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
|
+
|
|
3
|
+
from .controllers.upload_backup_to_sharepoint import (
|
|
4
|
+
UploadBackupToSharepointControllerInput,
|
|
5
|
+
)
|
|
6
|
+
from .controllers.upload_backup_to_sharepoint import UploadBackupToSharepointController
|
|
7
|
+
from saviialib.general_types.api.saviia_backup_api_types import SaviiaBackupConfig
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SaviiaBackupAPI:
|
|
11
|
+
"""
|
|
12
|
+
EpiiAPI is a service class that provides methods to interact with Patagonia Center system.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, config: SaviiaBackupConfig):
|
|
16
|
+
self.config = config
|
|
17
|
+
|
|
18
|
+
async def upload_backup_to_sharepoint(
|
|
19
|
+
self, local_backup_source_path: str, sharepoint_destination_path: str
|
|
20
|
+
) -> Dict[str, Any]:
|
|
21
|
+
"""Migrate a backup folder from Home assistant to Sharepoint directory.
|
|
22
|
+
Args:
|
|
23
|
+
local_backup_source_path (str): Local path to backup.
|
|
24
|
+
Returns:
|
|
25
|
+
response (dict): A dictionary containing the response from the upload operation.
|
|
26
|
+
This dictionary will typically include information about the success or
|
|
27
|
+
failure of the upload, as well as any relevant metadata.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
controller = UploadBackupToSharepointController(
|
|
31
|
+
UploadBackupToSharepointControllerInput(
|
|
32
|
+
self.config, local_backup_source_path, sharepoint_destination_path
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
response = await controller.execute()
|
|
36
|
+
return response.__dict__
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from dataclasses import dataclass, field
|
|
2
2
|
from typing import Dict
|
|
3
3
|
|
|
4
|
-
from saviialib.general_types.api.
|
|
4
|
+
from saviialib.general_types.api.saviia_backup_api_types import SaviiaBackupConfig
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
@dataclass
|
|
8
8
|
class UploadBackupToSharepointControllerInput:
|
|
9
|
-
config:
|
|
9
|
+
config: SaviiaBackupConfig
|
|
10
10
|
local_backup_source_path: str
|
|
11
11
|
sharepoint_destination_path: str
|
|
12
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from http import HTTPStatus
|
|
2
|
-
from saviialib.general_types.api.
|
|
2
|
+
from saviialib.general_types.api.saviia_api_types import SharepointConfig
|
|
3
3
|
|
|
4
|
-
from saviialib.general_types.error_types.api.
|
|
4
|
+
from saviialib.general_types.error_types.api.saviia_api_error_types import (
|
|
5
5
|
BackupUploadError,
|
|
6
6
|
BackupSourcePathError,
|
|
7
7
|
BackupEmptyError,
|
|
@@ -10,14 +10,14 @@ from saviialib.general_types.error_types.common.common_types import (
|
|
|
10
10
|
EmptyDataError,
|
|
11
11
|
SharepointClientError,
|
|
12
12
|
)
|
|
13
|
-
from saviialib.services.
|
|
13
|
+
from saviialib.services.backup.controllers.types.upload_backup_to_sharepoint_types import (
|
|
14
14
|
UploadBackupToSharepointControllerInput,
|
|
15
15
|
UploadBackupToSharepointControllerOutput,
|
|
16
16
|
)
|
|
17
|
-
from saviialib.services.
|
|
17
|
+
from saviialib.services.backup.use_cases.types.upload_backup_to_sharepoint_types import (
|
|
18
18
|
UploadBackupToSharepointUseCaseInput,
|
|
19
19
|
)
|
|
20
|
-
from saviialib.services.
|
|
20
|
+
from saviialib.services.backup.use_cases.upload_backup_to_sharepoint import (
|
|
21
21
|
UploadBackupToSharepointUsecase,
|
|
22
22
|
)
|
|
23
23
|
|
|
@@ -2,7 +2,7 @@ import asyncio
|
|
|
2
2
|
from time import time
|
|
3
3
|
from saviialib.libs.zero_dependency.utils.datetime_utils import today, datetime_to_str
|
|
4
4
|
from logging import Logger
|
|
5
|
-
from saviialib.general_types.error_types.api.
|
|
5
|
+
from saviialib.general_types.error_types.api.saviia_api_error_types import (
|
|
6
6
|
BackupEmptyError,
|
|
7
7
|
BackupSourcePathError,
|
|
8
8
|
BackupUploadError,
|
|
@@ -23,7 +23,7 @@ from saviialib.libs.sharepoint_client import (
|
|
|
23
23
|
SpUploadFileArgs,
|
|
24
24
|
SpCreateFolderArgs,
|
|
25
25
|
)
|
|
26
|
-
from saviialib.services.
|
|
26
|
+
from saviialib.services.backup.utils.upload_backup_to_sharepoint_utils import (
|
|
27
27
|
calculate_percentage_uploaded,
|
|
28
28
|
count_files_in_directory,
|
|
29
29
|
extract_error_message,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import re
|
|
2
2
|
from logging import Logger
|
|
3
3
|
from typing import List, Dict, Optional
|
|
4
|
-
from saviialib.general_types.error_types.api.
|
|
4
|
+
from saviialib.general_types.error_types.api.saviia_api_error_types import (
|
|
5
5
|
BackupSourcePathError,
|
|
6
6
|
)
|
|
7
7
|
from saviialib.libs.directory_client import DirectoryClient, DirectoryClientArgs
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
|
+
|
|
3
|
+
from .controllers.types.update_thies_data_types import UpdateThiesDataControllerInput
|
|
4
|
+
from .controllers.update_thies_data import UpdateThiesDataController
|
|
5
|
+
from saviialib.general_types.api.saviia_thies_api_types import (
|
|
6
|
+
SaviiaThiesConfig,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SaviiaThiesAPI:
|
|
11
|
+
def __init__(self, config: SaviiaThiesConfig) -> None:
|
|
12
|
+
self.config = config
|
|
13
|
+
|
|
14
|
+
async def update_thies_data(
|
|
15
|
+
self, sharepoint_folders_path: List[str], ftp_server_folders_path: List[str]
|
|
16
|
+
) -> Dict[str, Any]:
|
|
17
|
+
"""Updates data from a THIES Data Logger by connecting to an FTP server
|
|
18
|
+
and transferring data to specified Sharepoint folders.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
sharepoint_folders_path (list): List of Sharepoint folder paths for AVG and EXT data.
|
|
22
|
+
The AVG path must be the first element.
|
|
23
|
+
ftp_server_folders_path (list): List of FTP server folder paths for AVG and EXT data.
|
|
24
|
+
The AVG path must be the first element.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
dict: A dictionary representation of the API response.
|
|
28
|
+
"""
|
|
29
|
+
controller = UpdateThiesDataController(
|
|
30
|
+
UpdateThiesDataControllerInput(
|
|
31
|
+
self.config, sharepoint_folders_path, ftp_server_folders_path
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
response = await controller.execute()
|
|
35
|
+
return response.__dict__
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
from dataclasses import dataclass, field
|
|
2
2
|
from typing import Dict
|
|
3
|
-
from saviialib.general_types.api.
|
|
4
|
-
EpiiUpdateThiesConfig,
|
|
5
|
-
)
|
|
3
|
+
from saviialib.general_types.api.saviia_thies_api_types import SaviiaThiesConfig
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
@dataclass
|
|
9
7
|
class UpdateThiesDataControllerInput:
|
|
10
|
-
config:
|
|
8
|
+
config: SaviiaThiesConfig
|
|
11
9
|
sharepoint_folders_path: list
|
|
12
10
|
ftp_server_folders_path: list
|
|
13
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from http import HTTPStatus
|
|
2
2
|
|
|
3
|
-
from saviialib.general_types.error_types.api.
|
|
3
|
+
from saviialib.general_types.error_types.api.saviia_api_error_types import (
|
|
4
4
|
SharePointFetchingError,
|
|
5
5
|
ThiesConnectionError,
|
|
6
6
|
ThiesFetchingError,
|
|
@@ -12,16 +12,16 @@ from saviialib.general_types.error_types.common.common_types import (
|
|
|
12
12
|
FtpClientError,
|
|
13
13
|
SharepointClientError,
|
|
14
14
|
)
|
|
15
|
-
from saviialib.services.
|
|
15
|
+
from saviialib.services.thies.controllers.types.update_thies_data_types import (
|
|
16
16
|
UpdateThiesDataControllerInput,
|
|
17
17
|
UpdateThiesDataControllerOutput,
|
|
18
18
|
)
|
|
19
|
-
from saviialib.services.
|
|
19
|
+
from saviialib.services.backup.use_cases.types import (
|
|
20
20
|
UpdateThiesDataUseCaseInput,
|
|
21
21
|
SharepointConfig,
|
|
22
22
|
FtpClientConfig,
|
|
23
23
|
)
|
|
24
|
-
from saviialib.services.
|
|
24
|
+
from saviialib.services.thies.use_cases.update_thies_data import (
|
|
25
25
|
UpdateThiesDataUseCase,
|
|
26
26
|
)
|
|
27
27
|
|
|
@@ -70,7 +70,7 @@ UNITS = {
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
async def create_thies_daily_statistics_file(
|
|
73
|
-
os_client: DirectoryClient, logger: Logger
|
|
73
|
+
os_client: DirectoryClient, logger: Logger
|
|
74
74
|
) -> None:
|
|
75
75
|
logger.debug("[thies_synchronization_lib] Creating Daily Statistics ...")
|
|
76
76
|
csv_client = FilesClient(FilesClientInitArgs(client_name="csv_client"))
|
|
@@ -127,6 +127,15 @@ async def create_thies_daily_statistics_file(
|
|
|
127
127
|
if max_col not in row:
|
|
128
128
|
max_val = 0
|
|
129
129
|
|
|
130
|
+
if (mean < min_val or mean > max_val) and col not in ["WD"]:
|
|
131
|
+
logger.warning(
|
|
132
|
+
f"[thies_synchronization_lib] Inconsistent data for {col}: "
|
|
133
|
+
f"min {min_val}, max {max_val}, mean {mean}. "
|
|
134
|
+
)
|
|
135
|
+
mean = (min_val + max_val) / 2
|
|
136
|
+
logger.warning(
|
|
137
|
+
f"[thies_synchronization_lib] Mean value corrected to {mean}.")
|
|
138
|
+
|
|
130
139
|
if col in ["WD"]: # Avoid error
|
|
131
140
|
rows.append(
|
|
132
141
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from dataclasses import dataclass, field
|
|
2
2
|
from typing import Dict, List
|
|
3
|
-
from saviialib.general_types.api.
|
|
3
|
+
from saviialib.general_types.api.saviia_api_types import FtpClientConfig, SharepointConfig
|
|
4
4
|
from logging import Logger
|
|
5
5
|
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from saviialib.general_types.error_types.api.
|
|
1
|
+
from saviialib.general_types.error_types.api.saviia_api_error_types import (
|
|
2
2
|
SharePointFetchingError,
|
|
3
3
|
SharePointDirectoryError,
|
|
4
4
|
SharePointUploadError,
|
|
@@ -26,16 +26,17 @@ from saviialib.libs.sharepoint_client import (
|
|
|
26
26
|
from saviialib.libs.directory_client import DirectoryClient, DirectoryClientArgs
|
|
27
27
|
|
|
28
28
|
from saviialib.libs.files_client import FilesClient, FilesClientInitArgs, WriteArgs
|
|
29
|
-
from saviialib.services.
|
|
29
|
+
from saviialib.services.backup.use_cases.types import (
|
|
30
30
|
FtpClientConfig,
|
|
31
31
|
SharepointConfig,
|
|
32
32
|
UpdateThiesDataUseCaseInput,
|
|
33
33
|
)
|
|
34
|
-
from saviialib.services.
|
|
34
|
+
from saviialib.services.backup.utils import (
|
|
35
35
|
parse_execute_response,
|
|
36
36
|
)
|
|
37
37
|
from saviialib.libs.zero_dependency.utils.datetime_utils import today, datetime_to_str
|
|
38
38
|
from .components.create_thies_statistics_file import create_thies_daily_statistics_file
|
|
39
|
+
from typing import Set, Dict, List
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
class UpdateThiesDataUseCase:
|
|
@@ -95,7 +96,7 @@ class UpdateThiesDataUseCase:
|
|
|
95
96
|
reason=f"The current folder '{folder_name}' doesn't exist."
|
|
96
97
|
)
|
|
97
98
|
|
|
98
|
-
async def fetch_cloud_file_names(self) ->
|
|
99
|
+
async def fetch_cloud_file_names(self) -> Set[str]:
|
|
99
100
|
"""Fetch file names from the RCER cloud."""
|
|
100
101
|
await self._validate_sharepoint_current_folders()
|
|
101
102
|
try:
|
|
@@ -113,7 +114,7 @@ class UpdateThiesDataUseCase:
|
|
|
113
114
|
except Exception as error:
|
|
114
115
|
raise SharePointFetchingError(reason=error)
|
|
115
116
|
|
|
116
|
-
async def fetch_thies_file_names(self) ->
|
|
117
|
+
async def fetch_thies_file_names(self) -> Set[str]:
|
|
117
118
|
"""Fetch file names from the THIES FTP server."""
|
|
118
119
|
try:
|
|
119
120
|
thies_files = set()
|
|
@@ -131,7 +132,7 @@ class UpdateThiesDataUseCase:
|
|
|
131
132
|
except ConnectionAbortedError as error:
|
|
132
133
|
raise ThiesFetchingError(reason=error)
|
|
133
134
|
|
|
134
|
-
async def fetch_thies_file_content(self) ->
|
|
135
|
+
async def fetch_thies_file_content(self) -> Dict[str, bytes]:
|
|
135
136
|
"""Fetch the content of files from the THIES FTP server."""
|
|
136
137
|
try:
|
|
137
138
|
content_files = {}
|
|
@@ -165,8 +166,8 @@ class UpdateThiesDataUseCase:
|
|
|
165
166
|
raise ThiesFetchingError(reason=error)
|
|
166
167
|
|
|
167
168
|
async def upload_thies_files_to_sharepoint(
|
|
168
|
-
self, files:
|
|
169
|
-
) ->
|
|
169
|
+
self, files: Dict
|
|
170
|
+
) -> Dict[str, List[str]]:
|
|
170
171
|
"""Upload files to SharePoint and categorize the results."""
|
|
171
172
|
upload_results = {"failed_files": [], "new_files": []}
|
|
172
173
|
|
|
@@ -269,7 +270,15 @@ class UpdateThiesDataUseCase:
|
|
|
269
270
|
FtpReadFileArgs(file_path)
|
|
270
271
|
)
|
|
271
272
|
except FileNotFoundError as error:
|
|
272
|
-
|
|
273
|
+
reason = str(error) + ". The file might not be available yet for statistics."
|
|
274
|
+
self.logger.warning(
|
|
275
|
+
"[thies_synchronization_lib] Warning: %s", reason
|
|
276
|
+
)
|
|
277
|
+
self.logger.warning(
|
|
278
|
+
"[thies_synchronization_lib] Skipping the creation of daily statistics %s",
|
|
279
|
+
filename,
|
|
280
|
+
)
|
|
281
|
+
return
|
|
273
282
|
# Destination local folder
|
|
274
283
|
self.logger.debug(file_path)
|
|
275
284
|
|
|
@@ -305,9 +314,7 @@ class UpdateThiesDataUseCase:
|
|
|
305
314
|
dest_folder,
|
|
306
315
|
)
|
|
307
316
|
# Read the files with ThiesDayData class
|
|
308
|
-
await create_thies_daily_statistics_file(
|
|
309
|
-
self.os_client, self.logger, daily_files
|
|
310
|
-
)
|
|
317
|
+
await create_thies_daily_statistics_file(self.os_client, self.logger)
|
|
311
318
|
|
|
312
319
|
async def execute(self):
|
|
313
320
|
"""Synchronize data from the THIES Center to the cloud."""
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: saviialib
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A client library for IoT projects in the RCER initiative
|
|
5
5
|
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Author: pedropablozavalat
|
|
7
8
|
Requires-Python: >=3.11,<4.0
|
|
8
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -10,15 +11,16 @@ Classifier: Programming Language :: Python :: 3
|
|
|
10
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
15
|
Requires-Dist: aiofiles
|
|
14
16
|
Requires-Dist: aioftp
|
|
15
17
|
Requires-Dist: aiohttp
|
|
16
18
|
Requires-Dist: bitarray
|
|
17
19
|
Requires-Dist: build
|
|
20
|
+
Requires-Dist: certifi
|
|
18
21
|
Requires-Dist: dotenv (>=0.9.9,<0.10.0)
|
|
19
22
|
Requires-Dist: numpy (>=2.2.0,<2.4.0)
|
|
20
23
|
Requires-Dist: pandas (>=2.2.3,<2.3.1)
|
|
21
|
-
Requires-Dist: pytest-cov (>=6.1.1,<7.0.0)
|
|
22
24
|
Description-Content-Type: text/markdown
|
|
23
25
|
|
|
24
26
|
# SAVIIA Library
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
saviialib/__init__.py,sha256=jhd-pnya5KnMxjOvpU0_fBo1WajPwt2Miz8wgCpWulo,3030
|
|
2
|
+
saviialib/general_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
saviialib/general_types/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
saviialib/general_types/api/saviia_api_types.py,sha256=3pryGPpvhXDZVwAJUwY-o95rUm7MjhB7QzUWQ5l0faY,1317
|
|
5
|
+
saviialib/general_types/api/saviia_backup_api_types.py,sha256=mtXRxFjBOqfUBWWtgLZxNq-vb_mBkCUS9fxoFRJfoYE,791
|
|
6
|
+
saviialib/general_types/api/saviia_thies_api_types.py,sha256=ueqOFjHvRuT-N8H1UZEVXErgK1S1iRw0AXeO8bTdBts,1017
|
|
7
|
+
saviialib/general_types/error_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
saviialib/general_types/error_types/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
saviialib/general_types/error_types/api/saviia_api_error_types.py,sha256=iprpNvVoNA3vakMm7-dQdjCv7ZrRs6tRiXK1uaV3DNU,3049
|
|
10
|
+
saviialib/general_types/error_types/common/__init__.py,sha256=yOBLZbt64Ki9Q0IJ0tMAubgq7PtrQ7XQ3RgtAzyOjiE,170
|
|
11
|
+
saviialib/general_types/error_types/common/common_types.py,sha256=n5yuw-gVtkrtNfmaZ83ZkYxYHGl4jynOLUB9C8Tr32w,474
|
|
12
|
+
saviialib/libs/directory_client/__init__.py,sha256=ys07nzp74fHew2mUkbGpntp5w4t_PnhZIS6D4_mJw2A,162
|
|
13
|
+
saviialib/libs/directory_client/client/os_client.py,sha256=TgDnIQvgMP7sIVjn5kAKEJ5BYET7pN-FIQP0lvFMl4Q,763
|
|
14
|
+
saviialib/libs/directory_client/directory_client.py,sha256=5HmB1Pt9M8Tk18WKzfh3Fwr8gKa_RZCdAqvbU0rg7mw,1086
|
|
15
|
+
saviialib/libs/directory_client/directory_client_contract.py,sha256=wtNaUak1a7r6t9OI1L2ou7XMMJFXWpQFb7WyT6X7fCQ,479
|
|
16
|
+
saviialib/libs/directory_client/types/directory_client_types.py,sha256=ncMwVs_o6EYMuypXXmVInsjVDKJsdxVkmwj1M-LEInA,109
|
|
17
|
+
saviialib/libs/files_client/__init__.py,sha256=sIi9ne7Z3EfxnqGTaSmH-cZ8QsKyu0hoOz61GyA3njs,192
|
|
18
|
+
saviialib/libs/files_client/clients/aiofiles_client.py,sha256=Mu5pSnnEa3dT3GONmt1O-lCQstuQNXHtJHM3D2L6TU8,1107
|
|
19
|
+
saviialib/libs/files_client/clients/csv_client.py,sha256=Rk4QbiKlVKrYxYtxQt-Pmkp9QoB_dNgs5r36JB9hU0o,1478
|
|
20
|
+
saviialib/libs/files_client/files_client.py,sha256=oWfaMLA_Lw91H1_pPirFtFbdJh4abSyZp91qBsAiePs,950
|
|
21
|
+
saviialib/libs/files_client/files_client_contract.py,sha256=fYvd68IMpc1OFkxbzNSmRUoTWVctf3hkNVQ7QZV0m6I,304
|
|
22
|
+
saviialib/libs/files_client/types/files_client_types.py,sha256=GOTM5fBY304-EX6IiUnWmt2JpsyQ6Nmb_Tp0wingt0M,755
|
|
23
|
+
saviialib/libs/ftp_client/__init__.py,sha256=dW2Yutgc7mJJJzgKLhWKXMgQ6KIWJYfFa1sGpjHH5xU,191
|
|
24
|
+
saviialib/libs/ftp_client/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
saviialib/libs/ftp_client/clients/aioftp_client.py,sha256=5sgr3PMETgaBRlKeu_avxHIh6tr1gb7t2mkxmpRas_k,1925
|
|
26
|
+
saviialib/libs/ftp_client/clients/ftplib_client.py,sha256=VcpAn23r03iyCUAj35xHU_AVNrll_45uHFN8Z9OnBkE,2203
|
|
27
|
+
saviialib/libs/ftp_client/ftp_client.py,sha256=Naj9p0yYWlXt9um0zKfvuHSoycM8JZg2SPBm8110pYk,1008
|
|
28
|
+
saviialib/libs/ftp_client/ftp_client_contract.py,sha256=tymkugDzsJ5PzUXIaSkwX1h7T0naR15qAkjrqswqDyM,338
|
|
29
|
+
saviialib/libs/ftp_client/types/__init__.py,sha256=syfwf9feP4QK7fkCTfl4j8l11ic-jHtfi1DE2chaWbs,155
|
|
30
|
+
saviialib/libs/ftp_client/types/ftp_client_types.py,sha256=e4SmYkewldulaD8ms2q75zVgLFXyBxBqoa_L-IQOmso,256
|
|
31
|
+
saviialib/libs/sharepoint_client/__init__.py,sha256=6RbEzFtCfMrrY8F0JOCVcK6Gqt1FBJ09m0NuWHMCmCI,384
|
|
32
|
+
saviialib/libs/sharepoint_client/clients/sharepoint_rest_api.py,sha256=LOdaY16yu-aqOJuwvK2i5XbW6JU4cunvf9kgsW-PF5k,6318
|
|
33
|
+
saviialib/libs/sharepoint_client/sharepoint_client.py,sha256=gXFisWWCk6pKhoEeaNN8dcHA5ywrGDLqfiKjchrHRy0,1816
|
|
34
|
+
saviialib/libs/sharepoint_client/sharepoint_client_contract.py,sha256=H-WsXR5f50jy5RRYNlgV61y_YGjOUq4U_E1DWUUrDYw,612
|
|
35
|
+
saviialib/libs/sharepoint_client/types/sharepoint_client_types.py,sha256=JruUCn6o16w00t4zxDrxmv_Bxa52UyShGYmwUFfBCCQ,482
|
|
36
|
+
saviialib/libs/zero_dependency/utils/datetime_utils.py,sha256=c2H_JpUKpunCzDw6I4alDWNftEqaciWGtEUklPepm_s,759
|
|
37
|
+
saviialib/services/backup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
+
saviialib/services/backup/api.py,sha256=LQAsf3JEY58_b0McgmR0FxX3dZgZ9I729Gu081_OQm4,1414
|
|
39
|
+
saviialib/services/backup/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
saviialib/services/backup/controllers/types/__init__.py,sha256=0zIWXQb6YQVIIbb5b_FeL-D9Zy_d1GqR8kVz3hen4IU,222
|
|
41
|
+
saviialib/services/backup/controllers/types/upload_backup_to_sharepoint_types.py,sha256=AzoHx3AWrVCM8LjmlEovDlRe4kJPJBbRoMToG8QK_Nw,464
|
|
42
|
+
saviialib/services/backup/controllers/upload_backup_to_sharepoint.py,sha256=rW8FmcalRO1Ip8rhOsfpJIKRVYyn8oO-_jJSiS7MJOk,3827
|
|
43
|
+
saviialib/services/backup/use_cases/constants/upload_backup_to_sharepoint_constants.py,sha256=erkn-3E8YwBMFs25o7exXoK7s73NdgP9IYDXeWzALcI,98
|
|
44
|
+
saviialib/services/backup/use_cases/types/__init__.py,sha256=uVfu-L3-2QGnki0-rL2fOVTj4hVMvykyqKEv7kQHNvE,224
|
|
45
|
+
saviialib/services/backup/use_cases/types/upload_backup_to_sharepoint_types.py,sha256=QSZ32Fsan-jGpmGFpip86N3S16oWaeIxri5at2x46nw,322
|
|
46
|
+
saviialib/services/backup/use_cases/upload_backup_to_sharepoint.py,sha256=tBAfztcXdr3pmJqhwdHKc6AbddajZubs_wkL93Wajv4,11890
|
|
47
|
+
saviialib/services/backup/utils/__init__.py,sha256=Khz07TAC17xGBbkSgNcOXSjzeFm6-NiQadNJ3R7tRgg,112
|
|
48
|
+
saviialib/services/backup/utils/upload_backup_to_sharepoint_utils.py,sha256=J2PkLvNFHqka4NLW4lrAdaK5pRgHnU3ZSOflO43uu78,3530
|
|
49
|
+
saviialib/services/thies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
|
+
saviialib/services/thies/api.py,sha256=ibXBSzs_LJjZbC9LWh1EcHMWUp5qWTz-P_qOIb3rx6Y,1365
|
|
51
|
+
saviialib/services/thies/controllers/types/update_thies_data_types.py,sha256=YSLd0HgkeB7auTXFjZVYz_g9jv2hY2vaK7x6VLZ2BK4,439
|
|
52
|
+
saviialib/services/thies/controllers/update_thies_data.py,sha256=j_orYJfom4lo8xm8Jsru1h8JjDFI4xAfUL2oSM_XpcE,4890
|
|
53
|
+
saviialib/services/thies/use_cases/components/create_thies_statistics_file.py,sha256=yH2rd66qjvYbPwpJem-GX9iXGY02NrkRj1jVSfFs4tI,5582
|
|
54
|
+
saviialib/services/thies/use_cases/components/thies_bp.py,sha256=1Iq5Wz3kqzJfQNawV_v8ORr_Pl-PoamFp_2Xo8DjvmI,15042
|
|
55
|
+
saviialib/services/thies/use_cases/types/update_thies_data_types.py,sha256=VoK9wIRuBF72beEYU3sLUhBQ8Mi-3mi2jJTZ9mKjqbo,541
|
|
56
|
+
saviialib/services/thies/use_cases/update_thies_data.py,sha256=jiD0CHN7SQM60m6aEtZvyHkuV8PPCiFVd8uweaoshLY,14960
|
|
57
|
+
saviialib/services/thies/utils/update_thies_data_utils.py,sha256=EpjYWXqyHxJ-dO3MHhdXp-rGV7WyUckeFko-nnfnNac,555
|
|
58
|
+
saviialib-1.4.0.dist-info/METADATA,sha256=wFykbY3s8rYATm7zmctuKA8ilE8-WJqcYqpvoTItwqM,4166
|
|
59
|
+
saviialib-1.4.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
60
|
+
saviialib-1.4.0.dist-info/licenses/LICENSE,sha256=NWpf6b38xgBWPBo5HZsCbdfp9hZSliEbRqWQgm0fkOo,1076
|
|
61
|
+
saviialib-1.4.0.dist-info/RECORD,,
|
saviialib/services/epii/api.py
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List
|
|
2
|
-
|
|
3
|
-
from .controllers.types.update_thies_data_types import UpdateThiesDataControllerInput
|
|
4
|
-
from .controllers.types.upload_backup_to_sharepoint_types import (
|
|
5
|
-
UploadBackupToSharepointControllerInput,
|
|
6
|
-
)
|
|
7
|
-
from .controllers.update_thies_data import UpdateThiesDataController
|
|
8
|
-
from .controllers.upload_backup_to_sharepoint import UploadBackupToSharepointController
|
|
9
|
-
from saviialib.general_types.api.epii_api_types import (
|
|
10
|
-
EpiiUpdateThiesConfig,
|
|
11
|
-
EpiiSharepointBackupConfig,
|
|
12
|
-
EpiiAPIConfig,
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class EpiiAPI:
|
|
17
|
-
"""
|
|
18
|
-
EpiiAPI is a service class that provides methods to interact with Patagonia Center system.
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
def __init__(self, config: EpiiAPIConfig):
|
|
22
|
-
self.ftp_port = config.ftp_port
|
|
23
|
-
self.ftp_host = config.ftp_host
|
|
24
|
-
self.ftp_user = config.ftp_user
|
|
25
|
-
self.ftp_password = config.ftp_password
|
|
26
|
-
self.sharepoint_client_id = config.sharepoint_client_id
|
|
27
|
-
self.sharepoint_client_secret = config.sharepoint_client_secret
|
|
28
|
-
self.sharepoint_tenant_id = config.sharepoint_tenant_id
|
|
29
|
-
self.sharepoint_tenant_name = config.sharepoint_tenant_name
|
|
30
|
-
self.sharepoint_site_name = config.sharepoint_site_name
|
|
31
|
-
self.logger = config.logger
|
|
32
|
-
|
|
33
|
-
async def update_thies_data(
|
|
34
|
-
self, sharepoint_folders_path: List[str], ftp_server_folders_path: List[str]
|
|
35
|
-
) -> Dict[str, Any]:
|
|
36
|
-
"""Updates data from a THIES Data Logger by connecting to an FTP server
|
|
37
|
-
and transferring data to specified Sharepoint folders.
|
|
38
|
-
|
|
39
|
-
Args:
|
|
40
|
-
sharepoint_folders_path (list): List of Sharepoint folder paths for AVG and EXT data.
|
|
41
|
-
The AVG path must be the first element.
|
|
42
|
-
ftp_server_folders_path (list): List of FTP server folder paths for AVG and EXT data.
|
|
43
|
-
The AVG path must be the first element.
|
|
44
|
-
|
|
45
|
-
Returns:
|
|
46
|
-
dict: A dictionary representation of the API response.
|
|
47
|
-
"""
|
|
48
|
-
config = EpiiUpdateThiesConfig(
|
|
49
|
-
ftp_port=self.ftp_port,
|
|
50
|
-
ftp_host=self.ftp_host,
|
|
51
|
-
ftp_user=self.ftp_user,
|
|
52
|
-
ftp_password=self.ftp_password,
|
|
53
|
-
sharepoint_client_id=self.sharepoint_client_id,
|
|
54
|
-
sharepoint_client_secret=self.sharepoint_client_secret,
|
|
55
|
-
sharepoint_site_name=self.sharepoint_site_name,
|
|
56
|
-
sharepoint_tenant_id=self.sharepoint_tenant_id,
|
|
57
|
-
sharepoint_tenant_name=self.sharepoint_tenant_name,
|
|
58
|
-
logger=self.logger,
|
|
59
|
-
)
|
|
60
|
-
controller = UpdateThiesDataController(
|
|
61
|
-
UpdateThiesDataControllerInput(
|
|
62
|
-
config, sharepoint_folders_path, ftp_server_folders_path
|
|
63
|
-
)
|
|
64
|
-
)
|
|
65
|
-
response = await controller.execute()
|
|
66
|
-
return response.__dict__
|
|
67
|
-
|
|
68
|
-
async def upload_backup_to_sharepoint(
|
|
69
|
-
self, local_backup_source_path: str, sharepoint_destination_path: str
|
|
70
|
-
) -> Dict[str, Any]:
|
|
71
|
-
"""Migrate a backup folder from Home assistant to Sharepoint directory.
|
|
72
|
-
Args:
|
|
73
|
-
local_backup_source_path (str): Local path to backup.
|
|
74
|
-
Returns:
|
|
75
|
-
response (dict): A dictionary containing the response from the upload operation.
|
|
76
|
-
This dictionary will typically include information about the success or
|
|
77
|
-
failure of the upload, as well as any relevant metadata.
|
|
78
|
-
"""
|
|
79
|
-
config = EpiiSharepointBackupConfig(
|
|
80
|
-
sharepoint_client_id=self.sharepoint_client_id,
|
|
81
|
-
sharepoint_client_secret=self.sharepoint_client_secret,
|
|
82
|
-
sharepoint_site_name=self.sharepoint_site_name,
|
|
83
|
-
sharepoint_tenant_id=self.sharepoint_tenant_id,
|
|
84
|
-
sharepoint_tenant_name=self.sharepoint_tenant_name,
|
|
85
|
-
logger=self.logger,
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
controller = UploadBackupToSharepointController(
|
|
89
|
-
UploadBackupToSharepointControllerInput(
|
|
90
|
-
config, local_backup_source_path, sharepoint_destination_path
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
response = await controller.execute()
|
|
94
|
-
return response.__dict__
|
saviialib-1.2.6.dist-info/RECORD
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
saviialib/__init__.py,sha256=TMsEY8OOjo9KOz-0jf3QBh6WFOhCY07Rd7W2PK7C-1A,253
|
|
2
|
-
saviialib/general_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
saviialib/general_types/api/__init__.py,sha256=jXhoMlbSv7UCizW_Fm2mqR_3n99qkocVwg6CF7s3w7w,145
|
|
4
|
-
saviialib/general_types/api/epii_api_types.py,sha256=jspp5tDN06qx27O3ubRyPfZ3i9ybvn2HLxjh3UTFNcY,2345
|
|
5
|
-
saviialib/general_types/error_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
saviialib/general_types/error_types/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
saviialib/general_types/error_types/api/epii_api_error_types.py,sha256=iprpNvVoNA3vakMm7-dQdjCv7ZrRs6tRiXK1uaV3DNU,3049
|
|
8
|
-
saviialib/general_types/error_types/common/__init__.py,sha256=yOBLZbt64Ki9Q0IJ0tMAubgq7PtrQ7XQ3RgtAzyOjiE,170
|
|
9
|
-
saviialib/general_types/error_types/common/common_types.py,sha256=n5yuw-gVtkrtNfmaZ83ZkYxYHGl4jynOLUB9C8Tr32w,474
|
|
10
|
-
saviialib/libs/directory_client/__init__.py,sha256=ys07nzp74fHew2mUkbGpntp5w4t_PnhZIS6D4_mJw2A,162
|
|
11
|
-
saviialib/libs/directory_client/client/os_client.py,sha256=TgDnIQvgMP7sIVjn5kAKEJ5BYET7pN-FIQP0lvFMl4Q,763
|
|
12
|
-
saviialib/libs/directory_client/directory_client.py,sha256=5HmB1Pt9M8Tk18WKzfh3Fwr8gKa_RZCdAqvbU0rg7mw,1086
|
|
13
|
-
saviialib/libs/directory_client/directory_client_contract.py,sha256=wtNaUak1a7r6t9OI1L2ou7XMMJFXWpQFb7WyT6X7fCQ,479
|
|
14
|
-
saviialib/libs/directory_client/types/directory_client_types.py,sha256=ncMwVs_o6EYMuypXXmVInsjVDKJsdxVkmwj1M-LEInA,109
|
|
15
|
-
saviialib/libs/files_client/__init__.py,sha256=sIi9ne7Z3EfxnqGTaSmH-cZ8QsKyu0hoOz61GyA3njs,192
|
|
16
|
-
saviialib/libs/files_client/clients/aiofiles_client.py,sha256=Mu5pSnnEa3dT3GONmt1O-lCQstuQNXHtJHM3D2L6TU8,1107
|
|
17
|
-
saviialib/libs/files_client/clients/csv_client.py,sha256=Rk4QbiKlVKrYxYtxQt-Pmkp9QoB_dNgs5r36JB9hU0o,1478
|
|
18
|
-
saviialib/libs/files_client/files_client.py,sha256=oWfaMLA_Lw91H1_pPirFtFbdJh4abSyZp91qBsAiePs,950
|
|
19
|
-
saviialib/libs/files_client/files_client_contract.py,sha256=fYvd68IMpc1OFkxbzNSmRUoTWVctf3hkNVQ7QZV0m6I,304
|
|
20
|
-
saviialib/libs/files_client/types/files_client_types.py,sha256=GOTM5fBY304-EX6IiUnWmt2JpsyQ6Nmb_Tp0wingt0M,755
|
|
21
|
-
saviialib/libs/ftp_client/__init__.py,sha256=dW2Yutgc7mJJJzgKLhWKXMgQ6KIWJYfFa1sGpjHH5xU,191
|
|
22
|
-
saviialib/libs/ftp_client/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
-
saviialib/libs/ftp_client/clients/aioftp_client.py,sha256=5sgr3PMETgaBRlKeu_avxHIh6tr1gb7t2mkxmpRas_k,1925
|
|
24
|
-
saviialib/libs/ftp_client/clients/ftplib_client.py,sha256=VcpAn23r03iyCUAj35xHU_AVNrll_45uHFN8Z9OnBkE,2203
|
|
25
|
-
saviialib/libs/ftp_client/ftp_client.py,sha256=Naj9p0yYWlXt9um0zKfvuHSoycM8JZg2SPBm8110pYk,1008
|
|
26
|
-
saviialib/libs/ftp_client/ftp_client_contract.py,sha256=tymkugDzsJ5PzUXIaSkwX1h7T0naR15qAkjrqswqDyM,338
|
|
27
|
-
saviialib/libs/ftp_client/types/__init__.py,sha256=syfwf9feP4QK7fkCTfl4j8l11ic-jHtfi1DE2chaWbs,155
|
|
28
|
-
saviialib/libs/ftp_client/types/ftp_client_types.py,sha256=e4SmYkewldulaD8ms2q75zVgLFXyBxBqoa_L-IQOmso,256
|
|
29
|
-
saviialib/libs/sharepoint_client/__init__.py,sha256=6RbEzFtCfMrrY8F0JOCVcK6Gqt1FBJ09m0NuWHMCmCI,384
|
|
30
|
-
saviialib/libs/sharepoint_client/clients/sharepoint_rest_api.py,sha256=Gq__zrYtSyiwi5NguMYCqJ5Bbs84UqzC9L5qvOMhfVI,6100
|
|
31
|
-
saviialib/libs/sharepoint_client/sharepoint_client.py,sha256=gXFisWWCk6pKhoEeaNN8dcHA5ywrGDLqfiKjchrHRy0,1816
|
|
32
|
-
saviialib/libs/sharepoint_client/sharepoint_client_contract.py,sha256=H-WsXR5f50jy5RRYNlgV61y_YGjOUq4U_E1DWUUrDYw,612
|
|
33
|
-
saviialib/libs/sharepoint_client/types/sharepoint_client_types.py,sha256=JruUCn6o16w00t4zxDrxmv_Bxa52UyShGYmwUFfBCCQ,482
|
|
34
|
-
saviialib/libs/zero_dependency/utils/datetime_utils.py,sha256=c2H_JpUKpunCzDw6I4alDWNftEqaciWGtEUklPepm_s,759
|
|
35
|
-
saviialib/services/epii/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
|
-
saviialib/services/epii/api.py,sha256=99G-iC8Nz8vv9TuNPpdFsHxDAH8DXVCHnUQzwAUO9Ao,4036
|
|
37
|
-
saviialib/services/epii/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
-
saviialib/services/epii/controllers/types/__init__.py,sha256=xzky-oTSojLNkWETp_k8a4dcXYvYSQY0VhWo23Yhb8U,195
|
|
39
|
-
saviialib/services/epii/controllers/types/update_thies_data_types.py,sha256=kmt18vq7RLEAfIJj9MYz62fJH9etuU1WqZJ5MYmjiIg,448
|
|
40
|
-
saviialib/services/epii/controllers/types/upload_backup_to_sharepoint_types.py,sha256=5mDMLy3J5grACl1ezBGYZPOyhIkWYeIWWBOklaP2IlQ,471
|
|
41
|
-
saviialib/services/epii/controllers/update_thies_data.py,sha256=8TV420d4VWTvCW18M6sAguHZrX5VODXscgrUfhwO1fs,4884
|
|
42
|
-
saviialib/services/epii/controllers/upload_backup_to_sharepoint.py,sha256=7-ABo89yXhrWv-iOFjCkBGX-y_I62eFaOi1LtO5Gb4k,3817
|
|
43
|
-
saviialib/services/epii/use_cases/components/create_thies_statistics_file.py,sha256=G9K5UpsUYPM_w2sbusiyRWnZwbumSh5rYgil-rt8EB8,5171
|
|
44
|
-
saviialib/services/epii/use_cases/components/thies_bp.py,sha256=1Iq5Wz3kqzJfQNawV_v8ORr_Pl-PoamFp_2Xo8DjvmI,15042
|
|
45
|
-
saviialib/services/epii/use_cases/constants/upload_backup_to_sharepoint_constants.py,sha256=erkn-3E8YwBMFs25o7exXoK7s73NdgP9IYDXeWzALcI,98
|
|
46
|
-
saviialib/services/epii/use_cases/types/__init__.py,sha256=u6fyodOEJE2j6FMqJux40Xf9ccYAi-UUYxqT-Kzc0kE,199
|
|
47
|
-
saviialib/services/epii/use_cases/types/update_thies_data_types.py,sha256=3lJzG1nuZoP1mqFlvQ0-aFJp80SECaeiROlvucVhaSY,539
|
|
48
|
-
saviialib/services/epii/use_cases/types/upload_backup_to_sharepoint_types.py,sha256=J_sGhqSaPoMZA0GIrzCx6pmgSKgIkGi0uyrsltU_H8w,320
|
|
49
|
-
saviialib/services/epii/use_cases/update_thies_data.py,sha256=Pk70x0QR9okpmw4P6Da108jMQ59hTpl16LzVYpTBkiA,14591
|
|
50
|
-
saviialib/services/epii/use_cases/upload_backup_to_sharepoint.py,sha256=-0MvCzkFM7T2y7XLgFevWAXmqAsthzuY68ReiiL2zDU,11886
|
|
51
|
-
saviialib/services/epii/utils/__init__.py,sha256=cYt2tvq65_OMjFaqb8-CCC7IGCQgFd4ziEUWJV7s1iY,98
|
|
52
|
-
saviialib/services/epii/utils/update_thies_data_utils.py,sha256=EpjYWXqyHxJ-dO3MHhdXp-rGV7WyUckeFko-nnfnNac,555
|
|
53
|
-
saviialib/services/epii/utils/upload_backup_to_sharepoint_utils.py,sha256=hEeV4_kcG8YL6t_3V8AlhgDHtHiUNsdYpilfgTLaQMc,3528
|
|
54
|
-
saviialib-1.2.6.dist-info/LICENSE,sha256=NWpf6b38xgBWPBo5HZsCbdfp9hZSliEbRqWQgm0fkOo,1076
|
|
55
|
-
saviialib-1.2.6.dist-info/METADATA,sha256=bZUPYCg6EJyzyUInlu0zzwsJLkSEy9A9JNF8YGgQOcs,4113
|
|
56
|
-
saviialib-1.2.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
57
|
-
saviialib-1.2.6.dist-info/RECORD,,
|
/saviialib/general_types/error_types/api/{epii_api_error_types.py → saviia_api_error_types.py}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/saviialib/services/{epii → backup}/use_cases/constants/upload_backup_to_sharepoint_constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|