rcer-iot-client-pkg 0.1.0__py3-none-any.whl → 0.1.1__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.
@@ -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,7 @@
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.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,5 +1,3 @@
1
- from src.rcer_iot_client_pkg.services.epii.controllers.update_thies_data import (
2
- UpdateThiesDataController,
3
- )
1
+ from .update_thies_data import UpdateThiesDataController
4
2
 
5
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
  )
@@ -2,32 +2,32 @@ import os
2
2
 
3
3
  from dotenv import load_dotenv
4
4
 
5
- import src.rcer_iot_client_pkg.services.epii.use_cases.constants as c
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 src.rcer_iot_client_pkg.general_types.error_types.common import (
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 src.rcer_iot_client_pkg.libs.async_http_client import (
16
+ from rcer_iot_client_pkg.libs.async_http_client import (
17
17
  AsyncHTTPClient,
18
18
  AsyncHttpClientInitArgs,
19
19
  GetArgs,
20
20
  )
21
- from src.rcer_iot_client_pkg.libs.ftp_client import (
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 src.rcer_iot_client_pkg.services.epii.use_cases.types import (
27
+ from rcer_iot_client_pkg.services.epii.use_cases.types import (
28
28
  UpdateThiesDataUseCaseInput,
29
29
  )
30
- from src.rcer_iot_client_pkg.services.epii.utils import (
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 Exception as error:
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 Exception as error:
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
- thies_files = await self.fetch_thies_file_names()
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:
@@ -1,3 +1,3 @@
1
- from src.rcer_iot_client_pkg.services.epii.utils.update_thies_data_utils import generate_file_content
1
+ from .update_thies_data_utils import generate_file_content
2
2
 
3
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,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.1
4
4
  Summary: A client library for IoT projects in the RCER initiative
5
5
  License: MIT
6
6
  Author: pedropablozavalat
@@ -5,36 +5,36 @@ rcer_iot_client_pkg/general_types/api/update_thies_data_types.py,sha256=47DEQpj8
5
5
  rcer_iot_client_pkg/general_types/error_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  rcer_iot_client_pkg/general_types/error_types/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  rcer_iot_client_pkg/general_types/error_types/api/update_thies_data_error_types.py,sha256=pbkIZxKTGtTOSVVcOVQ-mINN5mY8JYt5PeFqsyAF-Sg,640
8
- rcer_iot_client_pkg/general_types/error_types/common/__init__.py,sha256=iICVsiGpW9SZIvUwQb7BxvP_La3NZeyCWCRLqHmJ_l8,214
8
+ rcer_iot_client_pkg/general_types/error_types/common/__init__.py,sha256=qb0Z01TjUlOSrC9W40z011XxabrjGQN8UddO8upr8KQ,158
9
9
  rcer_iot_client_pkg/general_types/error_types/common/common_types.py,sha256=w25vajcnX24zIezMG3EjG32dDouV51p-iXtNKz8qjD4,319
10
10
  rcer_iot_client_pkg/libs/async_http_client/__init__.py,sha256=LF1KEh5Dhu0j9qZhSBGOsD-PWUFKEvS2oE0eUCyNLd0,279
11
11
  rcer_iot_client_pkg/libs/async_http_client/async_http_client.py,sha256=wlOvjThS8wnpyqdcY7HbeEx1X3eVNKxJ8DuCJtx0wFk,1135
12
12
  rcer_iot_client_pkg/libs/async_http_client/async_http_client_contract.py,sha256=PCoTt4R6vFwjvyOTETQ8jEw1uqzAQC3PYiIlg_d7iRI,816
13
13
  rcer_iot_client_pkg/libs/async_http_client/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- rcer_iot_client_pkg/libs/async_http_client/clients/aiohttp_client.py,sha256=bU473GBqx1Sj5r4V06E70rGjb4DE7zP8krkPWXmgWyo,1845
14
+ rcer_iot_client_pkg/libs/async_http_client/clients/aiohttp_client.py,sha256=exJ7yq_9ukKoGhdyEwUEe8N5syvEsv2vsQ5eJcQbKSc,1837
15
15
  rcer_iot_client_pkg/libs/async_http_client/types/__init__.py,sha256=TnJOBj5R6rVA5XAiId5dpQM6KjMIfi8KJkCCav7n930,154
16
16
  rcer_iot_client_pkg/libs/async_http_client/types/async_http_client_types.py,sha256=d-_rHQ21ajTr5AI66fH3-cpJzF8VhSqG0BHbVrlwND8,329
17
17
  rcer_iot_client_pkg/libs/ftp_client/__init__.py,sha256=6c6C3_hnZVApYKlRVOlCeEPH8RPnQ22c5Fqqb-hVKp0,179
18
18
  rcer_iot_client_pkg/libs/ftp_client/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- rcer_iot_client_pkg/libs/ftp_client/clients/aioftp_client.py,sha256=8DaInFB4krJ-U-2spa6A_gUzzWSg4CWR7a_QQ6ng5hk,1127
19
+ rcer_iot_client_pkg/libs/ftp_client/clients/aioftp_client.py,sha256=cI65J230Ptew3zSsMdWdZ_9EBBDft-k9mlYwcM6410s,1269
20
20
  rcer_iot_client_pkg/libs/ftp_client/ftp_client.py,sha256=sYaq_ilO1DlDHHMFz4Gt4t7oTx3hXFHQJx9WCoqG7M4,808
21
21
  rcer_iot_client_pkg/libs/ftp_client/ftp_client_contract.py,sha256=sISJSMzkCBTdRZT9xpspzQBvo03d80mC4XdmbEd_EwY,314
22
22
  rcer_iot_client_pkg/libs/ftp_client/types/__init__.py,sha256=_HaW5-nKNvxfgf7tiGoAI_bZewzneHE9DY_3niwFRKw,143
23
23
  rcer_iot_client_pkg/libs/ftp_client/types/ftp_client_types.py,sha256=uNECnvKpc8z-WFE1C-EaYypDqprGmyG25sKDfTvONT4,276
24
24
  rcer_iot_client_pkg/libs/zero_dependency/utils/datetime_utils.py,sha256=kD38wC087H3jwTIgrntBajE55cR2ioo_ftPUHiyGs_M,751
25
25
  rcer_iot_client_pkg/services/epii/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- rcer_iot_client_pkg/services/epii/api.py,sha256=pSCvYqBQgMvAAww8Orco6Ua7A_TS5rLLcvpuf_VsJrQ,727
27
- rcer_iot_client_pkg/services/epii/controllers/__init__.py,sha256=giezZrFE8xp9Svfy1GF1ihKlkMe6TQplu_bZNOua5NI,156
28
- rcer_iot_client_pkg/services/epii/controllers/types/__init__.py,sha256=uhMAjHUFKGeFUfnMeS6ZUBmozkeTcLZbUcuId8oMTgo,250
26
+ rcer_iot_client_pkg/services/epii/api.py,sha256=dONvFF3QpHy9jc1dnwJFiB5N7ruf1lPjG29X8BHxHdQ,695
27
+ rcer_iot_client_pkg/services/epii/controllers/__init__.py,sha256=mCdGgKGDgGxCtRoiZN9Rki-fTOyOuJWw9e7festpQYA,98
28
+ rcer_iot_client_pkg/services/epii/controllers/types/__init__.py,sha256=xzky-oTSojLNkWETp_k8a4dcXYvYSQY0VhWo23Yhb8U,195
29
29
  rcer_iot_client_pkg/services/epii/controllers/types/update_thies_data_types.py,sha256=0zbNgjln7PXQRjFPAbiNV9n_cXV1H1-XtXMCC_VA4kE,336
30
- rcer_iot_client_pkg/services/epii/controllers/update_thies_data.py,sha256=GHK0nH9dniFa8sjn3zv0AmYBVfiKnIMhsSvJcAnxgFI,2689
30
+ rcer_iot_client_pkg/services/epii/controllers/update_thies_data.py,sha256=_TeHGWoIx-QC3KTfI0_o6rimkx9v_7hOpjSvSGWz4Ls,2698
31
31
  rcer_iot_client_pkg/services/epii/use_cases/constants.py,sha256=fslc2XtEBs2bwVL1pfXXeDnJw35YLYz35ApXwatplH8,202
32
32
  rcer_iot_client_pkg/services/epii/use_cases/types/__init__.py,sha256=c2RRUbjWq2PIqYW8DcxmYDg0gLZ74kmHh3BkeQCVii0,108
33
33
  rcer_iot_client_pkg/services/epii/use_cases/types/update_thies_data_types.py,sha256=Rt76-f3tjJpg5VL8sraxXYVhXG_GHlnDBKotqCFuS8o,334
34
- rcer_iot_client_pkg/services/epii/use_cases/update_thies_data.py,sha256=9nUrw-jgrT_A99k6ZplTY8EsHFwFxtYMNKnUPeCgWlo,4992
35
- rcer_iot_client_pkg/services/epii/utils/__init__.py,sha256=_IAX_luockBtgJX76SBs3q0IaXU4vC8z8YBy5Dop5TI,139
36
- rcer_iot_client_pkg/services/epii/utils/update_thies_data_utils.py,sha256=NzWYfZ18Lf7Q7r_1UpVtZTgFr3mzeUlrdpX-Z9XagG4,418
37
- rcer_iot_client_pkg-0.1.0.dist-info/LICENSE,sha256=NWpf6b38xgBWPBo5HZsCbdfp9hZSliEbRqWQgm0fkOo,1076
38
- rcer_iot_client_pkg-0.1.0.dist-info/METADATA,sha256=ddJRrZt-P6Vv4UNXKm9_-jHQBPvxR0NCkj8taKuib8Q,2427
39
- rcer_iot_client_pkg-0.1.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
40
- rcer_iot_client_pkg-0.1.0.dist-info/RECORD,,
34
+ rcer_iot_client_pkg/services/epii/use_cases/update_thies_data.py,sha256=-OibzbehJWudg7qFkFn1O4rTj-dAXuRHB-awrhy5CFE,5082
35
+ rcer_iot_client_pkg/services/epii/utils/__init__.py,sha256=cAhC0EiJkIF9WxXfst93v1AZ-pyYqbcn4y9_vav8gSg,96
36
+ rcer_iot_client_pkg/services/epii/utils/update_thies_data_utils.py,sha256=husJv2E2FXROBvFU7k9jpYfFBH-tVj4Cma_zfajpjk4,414
37
+ rcer_iot_client_pkg-0.1.1.dist-info/LICENSE,sha256=NWpf6b38xgBWPBo5HZsCbdfp9hZSliEbRqWQgm0fkOo,1076
38
+ rcer_iot_client_pkg-0.1.1.dist-info/METADATA,sha256=bWeIofagDEP-zvXSitddgFjQvOnbCm-HQlD7mr273jw,2427
39
+ rcer_iot_client_pkg-0.1.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
40
+ rcer_iot_client_pkg-0.1.1.dist-info/RECORD,,