rcer-iot-client-pkg 0.5.1__py3-none-any.whl → 0.5.2__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,3 +1,6 @@
1
+ import json
2
+
3
+
1
4
  class ThiesConnectionError(Exception):
2
5
  """Raised when unable to connect to the THIES FTP Server"""
3
6
 
@@ -26,5 +29,15 @@ class ThiesFetchingError(Exception):
26
29
  class SharePointFetchingError(Exception):
27
30
  """Raised when there is an error fetching file names from the RCER cloud."""
28
31
 
32
+ def __init__(self, *args, reason):
33
+ super().__init__(*args, reason)
34
+ self.reason = reason
35
+
29
36
  def __str__(self):
30
- return "An error occurred while retrieving file names from the RCER cloud"
37
+ try:
38
+ _, internal_metadata = self.reason.__str__().split(",", 1)
39
+ internal_metadata_dict = json.loads(internal_metadata)
40
+ return internal_metadata_dict["error_description"]
41
+
42
+ except json.decoder.JSONDecodeError:
43
+ return self.reason.__str__()
@@ -65,17 +65,22 @@ class SharepointRestAPI(SharepointClientContract):
65
65
  }
66
66
 
67
67
  async def __aenter__(self) -> "SharepointRestAPI":
68
- self.credentials = await self._load_credentials()
69
- site_url = f"https://{self.tenant_name}.sharepoint.com"
68
+ try:
69
+ self.credentials = await self._load_credentials()
70
+ site_url = f"https://{self.tenant_name}.sharepoint.com"
70
71
 
71
- self.base_headers = {
72
- "Authorization": f"Bearer {self.credentials['access_token']}",
73
- "Accept": "application/json",
74
- "Content-Type": "application/json",
75
- }
76
- self.base_url = f"{site_url}/sites/{self.site_name}/_api/"
77
- self.session = ClientSession(headers=self.base_headers, base_url=self.base_url)
78
- return self
72
+ self.base_headers = {
73
+ "Authorization": f"Bearer {self.credentials['access_token']}",
74
+ "Accept": "application/json",
75
+ "Content-Type": "application/json",
76
+ }
77
+ self.base_url = f"{site_url}/sites/{self.site_name}/_api/"
78
+ self.session = ClientSession(
79
+ headers=self.base_headers, base_url=self.base_url
80
+ )
81
+ return self
82
+ except ClientError as error:
83
+ raise ConnectionError(error)
79
84
 
80
85
  async def __aexit__(
81
86
  self, _exc_type: type[BaseException], _exc_val: BaseException, _exc_tb: Any
@@ -73,14 +73,14 @@ class UpdateThiesDataController:
73
73
  except SharepointClientError as error:
74
74
  return UpdateThiesDataControllerOutput(
75
75
  message="Sharepoint Client initialization fails.",
76
- status=HTTPStatus.BAD_REQUEST.value,
76
+ status=HTTPStatus.INTERNAL_SERVER_ERROR.value,
77
77
  metadata={"error": error.__str__()},
78
78
  )
79
79
 
80
80
  except SharePointFetchingError as error:
81
81
  return UpdateThiesDataControllerOutput(
82
- message="An error occurred while retrieving file names from the RCER cloud",
83
- status=HTTPStatus.INTERNAL_SERVER_ERROR.value,
82
+ message="An error occurred while retrieving file names from Microsoft SharePoint",
83
+ status=HTTPStatus.BAD_REQUEST.value,
84
84
  metadata={"error": error.__str__()},
85
85
  )
86
86
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rcer_iot_client_pkg
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: A client library for IoT projects in the RCER initiative
5
5
  License: MIT
6
6
  Author: pedropablozavalat
@@ -4,7 +4,7 @@ rcer_iot_client_pkg/general_types/api/__init__.py,sha256=1afRFS8AkxkxOWmcNLFI3H1
4
4
  rcer_iot_client_pkg/general_types/api/update_thies_data_types.py,sha256=NqViiGKm1FdhgxJrNkLBLzqI-8SnPieAYv21kEN752U,963
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
- rcer_iot_client_pkg/general_types/error_types/api/update_thies_data_error_types.py,sha256=lDVcK7RrqT4s0Bzxa5nEyIsNee93GaIRCyPV9k0s4-o,928
7
+ rcer_iot_client_pkg/general_types/error_types/api/update_thies_data_error_types.py,sha256=Wl9zd7qM2KeZF-h28dqSd6L9N8azOEagD837zoBgpAc,1269
8
8
  rcer_iot_client_pkg/general_types/error_types/common/__init__.py,sha256=yOBLZbt64Ki9Q0IJ0tMAubgq7PtrQ7XQ3RgtAzyOjiE,170
9
9
  rcer_iot_client_pkg/general_types/error_types/common/common_types.py,sha256=n5yuw-gVtkrtNfmaZ83ZkYxYHGl4jynOLUB9C8Tr32w,474
10
10
  rcer_iot_client_pkg/libs/ftp_client/__init__.py,sha256=dW2Yutgc7mJJJzgKLhWKXMgQ6KIWJYfFa1sGpjHH5xU,191
@@ -15,7 +15,7 @@ rcer_iot_client_pkg/libs/ftp_client/ftp_client_contract.py,sha256=2x1MPZNFVw3l-s
15
15
  rcer_iot_client_pkg/libs/ftp_client/types/__init__.py,sha256=syfwf9feP4QK7fkCTfl4j8l11ic-jHtfi1DE2chaWbs,155
16
16
  rcer_iot_client_pkg/libs/ftp_client/types/ftp_client_types.py,sha256=e4SmYkewldulaD8ms2q75zVgLFXyBxBqoa_L-IQOmso,256
17
17
  rcer_iot_client_pkg/libs/sharepoint_client/__init__.py,sha256=v7h-cNsK-BaPp-hTU3NWRNXYRD9ztU-hsCk0eNRPIKA,334
18
- rcer_iot_client_pkg/libs/sharepoint_client/clients/sharepoint_rest_api.py,sha256=e0f4F8_Elt-y8dgxLqviQUy8PR8E2Qn60ecP0v78VQM,5269
18
+ rcer_iot_client_pkg/libs/sharepoint_client/clients/sharepoint_rest_api.py,sha256=Jxa8ZODVHVMdIwTCcE1tNS7z2JJDPMbgSshLvQ7H0Uk,5430
19
19
  rcer_iot_client_pkg/libs/sharepoint_client/sharepoint_client.py,sha256=UYfAhckzmal5-Jjvbz0P4gt64w5gOYJYksVSHXdJPiQ,1234
20
20
  rcer_iot_client_pkg/libs/sharepoint_client/sharepoint_client_contract.py,sha256=xqNHzCjp7GvUGGUox9YTJj2QJgTc5819t2etOk8X26o,485
21
21
  rcer_iot_client_pkg/libs/sharepoint_client/types/sharepoint_client_types.py,sha256=gfXhvKuqZjxSdbgbEgGF1EKYDDq7CjK9Tdth-Waq5xo,414
@@ -26,13 +26,13 @@ rcer_iot_client_pkg/services/epii/constants/update_thies_data_constants.py,sha25
26
26
  rcer_iot_client_pkg/services/epii/controllers/__init__.py,sha256=mCdGgKGDgGxCtRoiZN9Rki-fTOyOuJWw9e7festpQYA,98
27
27
  rcer_iot_client_pkg/services/epii/controllers/types/__init__.py,sha256=xzky-oTSojLNkWETp_k8a4dcXYvYSQY0VhWo23Yhb8U,195
28
28
  rcer_iot_client_pkg/services/epii/controllers/types/update_thies_data_types.py,sha256=M5rYsjgqTndhPIRi77McxLyTrjmGsoVUIAGPETNXz9U,374
29
- rcer_iot_client_pkg/services/epii/controllers/update_thies_data.py,sha256=Suxehwi1onUsc2rWGbzO1vBsBp0RfgCp6FUqe-lrY20,4054
29
+ rcer_iot_client_pkg/services/epii/controllers/update_thies_data.py,sha256=YWoXXNVaddCt8D_rTb8cU7gYR6l1VNwrjtldbqLIQ3A,4060
30
30
  rcer_iot_client_pkg/services/epii/use_cases/types/__init__.py,sha256=u6fyodOEJE2j6FMqJux40Xf9ccYAi-UUYxqT-Kzc0kE,199
31
31
  rcer_iot_client_pkg/services/epii/use_cases/types/update_thies_data_types.py,sha256=C0TU50KKYodpaX87OnG0MnHyGY4gRzmluUHk-esCEVU,635
32
32
  rcer_iot_client_pkg/services/epii/use_cases/update_thies_data.py,sha256=Tc12NUnZ0or2Tz5BA9jE62I5XxmKvZ__v4w5dTBk_5A,5052
33
33
  rcer_iot_client_pkg/services/epii/utils/__init__.py,sha256=cYt2tvq65_OMjFaqb8-CCC7IGCQgFd4ziEUWJV7s1iY,98
34
34
  rcer_iot_client_pkg/services/epii/utils/update_thies_data_utils.py,sha256=-q8t-xZmpwFDADGlDu0S7EKvZK7R0GUR6JqOxQShWgE,415
35
- rcer_iot_client_pkg-0.5.1.dist-info/LICENSE,sha256=NWpf6b38xgBWPBo5HZsCbdfp9hZSliEbRqWQgm0fkOo,1076
36
- rcer_iot_client_pkg-0.5.1.dist-info/METADATA,sha256=iM1HsE_ZZZA4ELdR0fA_GpujNOamSfd7PuYAPXR6AZc,3860
37
- rcer_iot_client_pkg-0.5.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
38
- rcer_iot_client_pkg-0.5.1.dist-info/RECORD,,
35
+ rcer_iot_client_pkg-0.5.2.dist-info/LICENSE,sha256=NWpf6b38xgBWPBo5HZsCbdfp9hZSliEbRqWQgm0fkOo,1076
36
+ rcer_iot_client_pkg-0.5.2.dist-info/METADATA,sha256=BWgFty5jiYYErS5W7KgoFumdMKUy6ZfciJ3r309PkzA,3860
37
+ rcer_iot_client_pkg-0.5.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
38
+ rcer_iot_client_pkg-0.5.2.dist-info/RECORD,,