rcer-iot-client-pkg 0.1.0__tar.gz → 0.1.2__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.
Files changed (42) hide show
  1. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/PKG-INFO +1 -1
  2. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/pyproject.toml +1 -1
  3. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/error_types/common/__init__.py +1 -1
  4. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/async_http_client/clients/aiohttp_client.py +2 -2
  5. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/ftp_client/clients/aioftp_client.py +7 -4
  6. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/api.py +3 -2
  7. rcer_iot_client_pkg-0.1.2/src/rcer_iot_client_pkg/services/epii/controllers/__init__.py +3 -0
  8. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/controllers/types/__init__.py +1 -1
  9. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/controllers/update_thies_data.py +11 -11
  10. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/use_cases/update_thies_data.py +14 -12
  11. rcer_iot_client_pkg-0.1.2/src/rcer_iot_client_pkg/services/epii/utils/__init__.py +3 -0
  12. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/utils/update_thies_data_utils.py +1 -1
  13. rcer_iot_client_pkg-0.1.0/src/rcer_iot_client_pkg/services/epii/controllers/__init__.py +0 -5
  14. rcer_iot_client_pkg-0.1.0/src/rcer_iot_client_pkg/services/epii/utils/__init__.py +0 -3
  15. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/LICENSE +0 -0
  16. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/README.md +0 -0
  17. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/__init__.py +0 -0
  18. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/__init__.py +0 -0
  19. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/api/__init__.py +0 -0
  20. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/api/update_thies_data_types.py +0 -0
  21. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/error_types/__init__.py +0 -0
  22. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/error_types/api/__init__.py +0 -0
  23. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/error_types/api/update_thies_data_error_types.py +0 -0
  24. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/general_types/error_types/common/common_types.py +0 -0
  25. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/async_http_client/__init__.py +0 -0
  26. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/async_http_client/async_http_client.py +0 -0
  27. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/async_http_client/async_http_client_contract.py +0 -0
  28. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/async_http_client/clients/__init__.py +0 -0
  29. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/async_http_client/types/__init__.py +0 -0
  30. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/async_http_client/types/async_http_client_types.py +0 -0
  31. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/ftp_client/__init__.py +0 -0
  32. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/ftp_client/clients/__init__.py +0 -0
  33. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/ftp_client/ftp_client.py +0 -0
  34. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/ftp_client/ftp_client_contract.py +0 -0
  35. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/ftp_client/types/__init__.py +0 -0
  36. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/ftp_client/types/ftp_client_types.py +0 -0
  37. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/libs/zero_dependency/utils/datetime_utils.py +0 -0
  38. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/__init__.py +0 -0
  39. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/controllers/types/update_thies_data_types.py +0 -0
  40. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/use_cases/constants.py +0 -0
  41. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/use_cases/types/__init__.py +0 -0
  42. {rcer_iot_client_pkg-0.1.0 → rcer_iot_client_pkg-0.1.2}/src/rcer_iot_client_pkg/services/epii/use_cases/types/update_thies_data_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rcer_iot_client_pkg
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: A client library for IoT projects in the RCER initiative
5
5
  License: MIT
6
6
  Author: pedropablozavalat
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "rcer_iot_client_pkg"
3
- version = "0.1.0"
3
+ version = "0.1.2"
4
4
  description = "A client library for IoT projects in the RCER initiative"
5
5
  authors = ["pedropablozavalat"]
6
6
  license = "MIT"
@@ -1,4 +1,4 @@
1
- from src.rcer_iot_client_pkg.general_types.error_types.common.common_types import (
1
+ from .common_types import (
2
2
  EmptyDataError,
3
3
  FtpClientError,
4
4
  HttpClientError,
@@ -2,10 +2,10 @@ from typing import Any
2
2
 
3
3
  from aiohttp import ClientError, ClientSession
4
4
 
5
- from src.rcer_iot_client_pkg.libs.async_http_client.async_http_client_contract import (
5
+ from rcer_iot_client_pkg.libs.async_http_client.async_http_client_contract import (
6
6
  AsyncHTTPClientContract,
7
7
  )
8
- from src.rcer_iot_client_pkg.libs.async_http_client.types.async_http_client_types import (
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 src.rcer_iot_client_pkg.libs.ftp_client.ftp_client_contract import (
3
+ from rcer_iot_client_pkg.libs.ftp_client.ftp_client_contract import (
4
4
  FTPClientContract,
5
5
  )
6
- from src.rcer_iot_client_pkg.libs.ftp_client.types.ftp_client_types import (
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
- await self.client.connect(host=self.host, port=self.port)
23
- await self.client.login(user=self.user, password=self.password)
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()
@@ -1,7 +1,8 @@
1
1
  from typing import Dict
2
2
 
3
- from src.rcer_iot_client_pkg.services.epii.controllers import UpdateThiesDataController
4
- from src.rcer_iot_client_pkg.services.epii.controllers.types import UpdateThiesDataControllerInput
3
+ from .controllers.types.update_thies_data_types import UpdateThiesDataControllerInput
4
+ from .controllers.update_thies_data import UpdateThiesDataController
5
+
5
6
 
6
7
  class EpiiAPI:
7
8
  def update_thies_data(
@@ -0,0 +1,3 @@
1
+ from .update_thies_data import UpdateThiesDataController
2
+
3
+ __all__ = ["UpdateThiesDataController"]
@@ -1,4 +1,4 @@
1
- from src.rcer_iot_client_pkg.services.epii.controllers.types.update_thies_data_types import (
1
+ from .update_thies_data_types import (
2
2
  UpdateThiesDataControllerInput,
3
3
  UpdateThiesDataControllerOutput,
4
4
  )
@@ -1,21 +1,21 @@
1
1
  from http import HTTPStatus
2
2
 
3
- from src.rcer_iot_client_pkg.general_types.error_types.api.update_thies_data_error_types import (
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 src.rcer_iot_client_pkg.general_types.error_types.common import (
7
+ from rcer_iot_client_pkg.general_types.error_types.common.common_types import (
8
8
  FtpClientError,
9
9
  HttpClientError,
10
10
  )
11
- from src.rcer_iot_client_pkg.services.epii.controllers.types.update_thies_data_types import (
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 src.rcer_iot_client_pkg.services.epii.use_cases.types import (
15
+ from rcer_iot_client_pkg.services.epii.use_cases.types import (
16
16
  UpdateThiesDataUseCaseInput,
17
17
  )
18
- from src.rcer_iot_client_pkg.services.epii.use_cases.update_thies_data import (
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.INTERNAL_SERVER_ERROR,
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.INTERNAL_SERVER_ERROR,
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
  )
@@ -1,33 +1,31 @@
1
- import os
2
-
3
1
  from dotenv import load_dotenv
4
2
 
5
- import src.rcer_iot_client_pkg.services.epii.use_cases.constants as c
6
- from src.rcer_iot_client_pkg.general_types.error_types.api.update_thies_data_error_types import (
3
+ import rcer_iot_client_pkg.services.epii.use_cases.constants as c
4
+ from rcer_iot_client_pkg.general_types.error_types.api.update_thies_data_error_types import (
7
5
  FetchCloudFileNamesError,
8
6
  FetchThiesFileContentError,
9
7
  ThiesUploadEmptyError,
10
8
  )
11
- from src.rcer_iot_client_pkg.general_types.error_types.common import (
9
+ from rcer_iot_client_pkg.general_types.error_types.common import (
12
10
  EmptyDataError,
13
11
  FtpClientError,
14
12
  HttpClientError,
15
13
  )
16
- from src.rcer_iot_client_pkg.libs.async_http_client import (
14
+ from rcer_iot_client_pkg.libs.async_http_client import (
17
15
  AsyncHTTPClient,
18
16
  AsyncHttpClientInitArgs,
19
17
  GetArgs,
20
18
  )
21
- from src.rcer_iot_client_pkg.libs.ftp_client import (
19
+ from rcer_iot_client_pkg.libs.ftp_client import (
22
20
  FTPClient,
23
21
  FtpClientInitArgs,
24
22
  ListFilesArgs,
25
23
  ReadFileArgs,
26
24
  )
27
- from src.rcer_iot_client_pkg.services.epii.use_cases.types import (
25
+ from rcer_iot_client_pkg.services.epii.use_cases.types import (
28
26
  UpdateThiesDataUseCaseInput,
29
27
  )
30
- from src.rcer_iot_client_pkg.services.epii.utils import (
28
+ from rcer_iot_client_pkg.services.epii.utils import (
31
29
  generate_file_content,
32
30
  )
33
31
 
@@ -54,7 +52,7 @@ class UpdateThiesDataUseCase:
54
52
  base_url="https://graph.microsoft.com/v1.0/",
55
53
  )
56
54
  )
57
- except Exception as error:
55
+ except ConnectionError as error:
58
56
  raise HttpClientError(error)
59
57
 
60
58
  def _initialize_thies_ftp_client(self) -> FTPClient:
@@ -69,7 +67,7 @@ class UpdateThiesDataUseCase:
69
67
  port=self.ftp_port,
70
68
  )
71
69
  )
72
- except Exception as error:
70
+ except RuntimeError as error:
73
71
  raise FtpClientError(error)
74
72
 
75
73
  async def fetch_cloud_file_names(self, folder_name: str) -> set[str]:
@@ -124,7 +122,11 @@ class UpdateThiesDataUseCase:
124
122
 
125
123
  async def execute(self) -> dict:
126
124
  """Synchronize data from the THIES Center to the cloud."""
127
- thies_files = await self.fetch_thies_file_names()
125
+ try:
126
+ thies_files = await self.fetch_thies_file_names()
127
+ except RuntimeError as error:
128
+ raise FtpClientError(error)
129
+
128
130
  cloud_files = await self.fetch_cloud_file_names(folder_name="thies")
129
131
  self.uploading = thies_files - cloud_files
130
132
  if not self.uploading:
@@ -0,0 +1,3 @@
1
+ from .update_thies_data_utils import generate_file_content
2
+
3
+ __all__ = ["generate_file_content"]
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
2
 
3
- from src.rcer_iot_client_pkg.libs.zero_dependency.utils.datetime_utils import (
3
+ from rcer_iot_client_pkg.libs.zero_dependency.utils.datetime_utils import (
4
4
  datetime_to_str,
5
5
  today,
6
6
  )
@@ -1,5 +0,0 @@
1
- from src.rcer_iot_client_pkg.services.epii.controllers.update_thies_data import (
2
- UpdateThiesDataController,
3
- )
4
-
5
- __all__ = ["UpdateThiesDataController"]
@@ -1,3 +0,0 @@
1
- from src.rcer_iot_client_pkg.services.epii.utils.update_thies_data_utils import generate_file_content
2
-
3
- __all__ = ["generate_file_content"]