rcer-iot-client-pkg 0.1.0__tar.gz → 0.1.1__tar.gz
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.
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/PKG-INFO +1 -1
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/pyproject.toml +1 -1
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/error_types/common/__init__.py +1 -1
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/async_http_client/clients/aiohttp_client.py +2 -2
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/ftp_client/clients/aioftp_client.py +7 -4
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/api.py +2 -2
- rcer_iot_client_pkg-0.1.1/src/rcer_iot_client_pkg/services/epii/controllers/__init__.py +3 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/controllers/types/__init__.py +1 -1
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/controllers/update_thies_data.py +11 -11
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/use_cases/update_thies_data.py +13 -9
- rcer_iot_client_pkg-0.1.1/src/rcer_iot_client_pkg/services/epii/utils/__init__.py +3 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/utils/update_thies_data_utils.py +1 -1
- rcer_iot_client_pkg-0.1.0/src/rcer_iot_client_pkg/services/epii/controllers/__init__.py +0 -5
- rcer_iot_client_pkg-0.1.0/src/rcer_iot_client_pkg/services/epii/utils/__init__.py +0 -3
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/LICENSE +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/README.md +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/api/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/api/update_thies_data_types.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/error_types/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/error_types/api/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/error_types/api/update_thies_data_error_types.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/general_types/error_types/common/common_types.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/async_http_client/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/async_http_client/async_http_client.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/async_http_client/async_http_client_contract.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/async_http_client/clients/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/async_http_client/types/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/async_http_client/types/async_http_client_types.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/ftp_client/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/ftp_client/clients/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/ftp_client/ftp_client.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/ftp_client/ftp_client_contract.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/ftp_client/types/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/ftp_client/types/ftp_client_types.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/libs/zero_dependency/utils/datetime_utils.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/controllers/types/update_thies_data_types.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/use_cases/constants.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/use_cases/types/__init__.py +0 -0
- {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/use_cases/types/update_thies_data_types.py +0 -0
@@ -2,10 +2,10 @@ from typing import Any
|
|
2
2
|
|
3
3
|
from aiohttp import ClientError, ClientSession
|
4
4
|
|
5
|
-
from
|
5
|
+
from rcer_iot_client_pkg.libs.async_http_client.async_http_client_contract import (
|
6
6
|
AsyncHTTPClientContract,
|
7
7
|
)
|
8
|
-
from
|
8
|
+
from rcer_iot_client_pkg.libs.async_http_client.types.async_http_client_types import (
|
9
9
|
AsyncHttpClientInitArgs,
|
10
10
|
GetArgs,
|
11
11
|
UploadFileArgs,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
from aioftp import Client
|
2
2
|
|
3
|
-
from
|
3
|
+
from rcer_iot_client_pkg.libs.ftp_client.ftp_client_contract import (
|
4
4
|
FTPClientContract,
|
5
5
|
)
|
6
|
-
from
|
6
|
+
from rcer_iot_client_pkg.libs.ftp_client.types.ftp_client_types import (
|
7
7
|
FtpClientInitArgs,
|
8
8
|
ListFilesArgs,
|
9
9
|
ReadFileArgs,
|
@@ -19,8 +19,11 @@ class AioFTPClient(FTPClientContract):
|
|
19
19
|
self.client = Client()
|
20
20
|
|
21
21
|
async def _async_start(self) -> None:
|
22
|
-
|
23
|
-
|
22
|
+
try:
|
23
|
+
await self.client.connect(host=self.host, port=self.port)
|
24
|
+
await self.client.login(user=self.user, password=self.password)
|
25
|
+
except Exception:
|
26
|
+
raise RuntimeError("Unexpected error occurred while trying to connect to the FTP server")
|
24
27
|
|
25
28
|
async def list_files(self, args: ListFilesArgs) -> list[str]:
|
26
29
|
await self._async_start()
|
{rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.1}/src/rcer_iot_client_pkg/services/epii/api.py
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
from typing import Dict
|
2
2
|
|
3
|
-
from
|
4
|
-
from
|
3
|
+
from .controllers.update_thies_data import UpdateThiesDataController
|
4
|
+
from .controllers.types.update_thies_data_types import UpdateThiesDataControllerInput
|
5
5
|
|
6
6
|
class EpiiAPI:
|
7
7
|
def update_thies_data(
|
@@ -1,21 +1,21 @@
|
|
1
1
|
from http import HTTPStatus
|
2
2
|
|
3
|
-
from
|
3
|
+
from rcer_iot_client_pkg.general_types.error_types.api.update_thies_data_error_types import (
|
4
4
|
FetchCloudFileNamesError,
|
5
5
|
ThiesUploadEmptyError,
|
6
6
|
)
|
7
|
-
from
|
7
|
+
from rcer_iot_client_pkg.general_types.error_types.common.common_types import (
|
8
8
|
FtpClientError,
|
9
9
|
HttpClientError,
|
10
10
|
)
|
11
|
-
from
|
11
|
+
from rcer_iot_client_pkg.services.epii.controllers.types.update_thies_data_types import (
|
12
12
|
UpdateThiesDataControllerInput,
|
13
13
|
UpdateThiesDataControllerOutput,
|
14
14
|
)
|
15
|
-
from
|
15
|
+
from rcer_iot_client_pkg.services.epii.use_cases.types import (
|
16
16
|
UpdateThiesDataUseCaseInput,
|
17
17
|
)
|
18
|
-
from
|
18
|
+
from rcer_iot_client_pkg.services.epii.use_cases.update_thies_data import (
|
19
19
|
UpdateThiesDataUseCase,
|
20
20
|
)
|
21
21
|
|
@@ -31,38 +31,38 @@ class UpdateThiesDataController:
|
|
31
31
|
data = await self.use_case.execute()
|
32
32
|
return UpdateThiesDataControllerOutput(
|
33
33
|
message="THIES was synced successfully",
|
34
|
-
status=HTTPStatus.OK,
|
34
|
+
status=HTTPStatus.OK.value,
|
35
35
|
metadata={"data": data},
|
36
36
|
)
|
37
37
|
except (AttributeError, NameError, ValueError) as error:
|
38
38
|
return UpdateThiesDataControllerOutput(
|
39
39
|
message="An unexpected error occurred during use case initialization.",
|
40
|
-
status=HTTPStatus.BAD_REQUEST,
|
40
|
+
status=HTTPStatus.BAD_REQUEST.value,
|
41
41
|
metadata={"error": error.__str__()},
|
42
42
|
)
|
43
43
|
except FtpClientError as error:
|
44
44
|
return UpdateThiesDataControllerOutput(
|
45
45
|
message="Ftp Client initialization fails.",
|
46
|
-
status=HTTPStatus.
|
46
|
+
status=HTTPStatus.BAD_REQUEST.value,
|
47
47
|
metadata={"error": error.__str__()},
|
48
48
|
)
|
49
49
|
|
50
50
|
except HttpClientError as error:
|
51
51
|
return UpdateThiesDataControllerOutput(
|
52
52
|
message="Http Client initialization fails.",
|
53
|
-
status=HTTPStatus.
|
53
|
+
status=HTTPStatus.BAD_REQUEST.value,
|
54
54
|
metadata={"error": error.__str__()},
|
55
55
|
)
|
56
56
|
|
57
57
|
except FetchCloudFileNamesError as error:
|
58
58
|
return UpdateThiesDataControllerOutput(
|
59
59
|
message="An error occurred while retrieving file names from the RCER cloud",
|
60
|
-
status=HTTPStatus.INTERNAL_SERVER_ERROR,
|
60
|
+
status=HTTPStatus.INTERNAL_SERVER_ERROR.value,
|
61
61
|
metadata={"error": error.__str__()},
|
62
62
|
)
|
63
63
|
except ThiesUploadEmptyError as error:
|
64
64
|
return UpdateThiesDataControllerOutput(
|
65
65
|
message="No files were found to upload.",
|
66
|
-
status=HTTPStatus.NO_CONTENT,
|
66
|
+
status=HTTPStatus.NO_CONTENT.value,
|
67
67
|
metadata={"error": error.__str__()},
|
68
68
|
)
|
@@ -2,32 +2,32 @@ import os
|
|
2
2
|
|
3
3
|
from dotenv import load_dotenv
|
4
4
|
|
5
|
-
import
|
5
|
+
import rcer_iot_client_pkg.services.epii.use_cases.constants as c
|
6
6
|
from src.rcer_iot_client_pkg.general_types.error_types.api.update_thies_data_error_types import (
|
7
7
|
FetchCloudFileNamesError,
|
8
8
|
FetchThiesFileContentError,
|
9
9
|
ThiesUploadEmptyError,
|
10
10
|
)
|
11
|
-
from
|
11
|
+
from rcer_iot_client_pkg.general_types.error_types.common import (
|
12
12
|
EmptyDataError,
|
13
13
|
FtpClientError,
|
14
14
|
HttpClientError,
|
15
15
|
)
|
16
|
-
from
|
16
|
+
from rcer_iot_client_pkg.libs.async_http_client import (
|
17
17
|
AsyncHTTPClient,
|
18
18
|
AsyncHttpClientInitArgs,
|
19
19
|
GetArgs,
|
20
20
|
)
|
21
|
-
from
|
21
|
+
from rcer_iot_client_pkg.libs.ftp_client import (
|
22
22
|
FTPClient,
|
23
23
|
FtpClientInitArgs,
|
24
24
|
ListFilesArgs,
|
25
25
|
ReadFileArgs,
|
26
26
|
)
|
27
|
-
from
|
27
|
+
from rcer_iot_client_pkg.services.epii.use_cases.types import (
|
28
28
|
UpdateThiesDataUseCaseInput,
|
29
29
|
)
|
30
|
-
from
|
30
|
+
from rcer_iot_client_pkg.services.epii.utils import (
|
31
31
|
generate_file_content,
|
32
32
|
)
|
33
33
|
|
@@ -54,7 +54,7 @@ class UpdateThiesDataUseCase:
|
|
54
54
|
base_url="https://graph.microsoft.com/v1.0/",
|
55
55
|
)
|
56
56
|
)
|
57
|
-
except
|
57
|
+
except ConnectionError as error:
|
58
58
|
raise HttpClientError(error)
|
59
59
|
|
60
60
|
def _initialize_thies_ftp_client(self) -> FTPClient:
|
@@ -69,7 +69,7 @@ class UpdateThiesDataUseCase:
|
|
69
69
|
port=self.ftp_port,
|
70
70
|
)
|
71
71
|
)
|
72
|
-
except
|
72
|
+
except RuntimeError as error:
|
73
73
|
raise FtpClientError(error)
|
74
74
|
|
75
75
|
async def fetch_cloud_file_names(self, folder_name: str) -> set[str]:
|
@@ -124,7 +124,11 @@ class UpdateThiesDataUseCase:
|
|
124
124
|
|
125
125
|
async def execute(self) -> dict:
|
126
126
|
"""Synchronize data from the THIES Center to the cloud."""
|
127
|
-
|
127
|
+
try:
|
128
|
+
thies_files = await self.fetch_thies_file_names()
|
129
|
+
except RuntimeError as error:
|
130
|
+
raise FtpClientError(error)
|
131
|
+
|
128
132
|
cloud_files = await self.fetch_cloud_file_names(folder_name="thies")
|
129
133
|
self.uploading = thies_files - cloud_files
|
130
134
|
if not self.uploading:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|