external-systems 0.102.0__py3-none-any.whl → 0.103.0rc2__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 external-systems might be problematic. Click here for more details.

@@ -16,4 +16,4 @@
16
16
  # The version is set during the publishing step (since we can't know the version in advance)
17
17
  # using the autorelease bot
18
18
 
19
- __version__ = "0.102.0"
19
+ __version__ = "0.103.0-rc2"
@@ -29,7 +29,6 @@ from ._connections import HttpsConnection
29
29
  from ._proxies import create_proxy_session
30
30
  from ._refreshable import DefaultSessionCredentialsManager, Refreshable, RefreshHandler
31
31
  from ._sockets import create_socket
32
- from ._utils import read_file
33
32
 
34
33
  log = logging.getLogger(__name__)
35
34
 
@@ -82,24 +81,49 @@ class Source:
82
81
 
83
82
  @cached_property
84
83
  def _ca_bundle_path(self) -> Optional[str]:
85
- if self._source_parameters.server_certificates is None:
86
- return None
84
+ """
85
+ Returns the path to the CA bundle file with all custom CA certificates defined in the Source.
87
86
 
88
- new_ca_contents = []
87
+ Precedence of which CA bundle to use:
88
+ 1. Custom CA bundle path (if provided assumes PEM format)
89
+ 2. Requests CA bundle path
90
+ 3. Temporary file
91
+ """
89
92
 
90
- # If a custom CA bundle path is provided, use it.
91
- # Otherwise, use the requests CA bundle path if it is set.
92
- ca_bundle_path = (
93
- self._custom_ca_bundle_path
94
- if self._custom_ca_bundle_path is not None
95
- else os.environ.get("REQUESTS_CA_BUNDLE")
96
- )
93
+ provided_ca_bundle_path = self._custom_ca_bundle_path or os.environ.get("REQUESTS_CA_BUNDLE")
94
+
95
+ if not self._source_parameters.server_certificates:
96
+ return provided_ca_bundle_path
97
97
 
98
- # Copy the CA bundle contents to the new CA bundle file.
99
- if ca_bundle_path:
100
- new_ca_contents.append(read_file(ca_bundle_path))
98
+ # Certificates from the Source to add to the CA bundle
99
+ server_certificates = list(self._source_parameters.server_certificates.values())
100
+
101
+ # If no provided CA bundle path, create a temporary file with only the server certificates
102
+ if not provided_ca_bundle_path:
103
+ with NamedTemporaryFile(delete=False, mode="w") as ca_bundle_file:
104
+ ca_bundle_file.write(os.linesep.join(server_certificates) + os.linesep)
105
+ return ca_bundle_file.name
106
+
107
+ # See https://docs.python.org/3/library/os.html#os.access for why we don't use os.access
108
+ # First try appending the server certificates to the provided CA bundle path
109
+ try:
110
+ with open(provided_ca_bundle_path, "a") as provided_ca_bundle_file:
111
+ provided_ca_bundle_file.write(os.linesep.join(server_certificates) + os.linesep)
112
+ return provided_ca_bundle_path
113
+ except PermissionError:
114
+ log.warning("PermissionError when writing to provided CA bundle path, falling back to temporary file.")
115
+
116
+ # Second try reading the provided CA bundle path and appending all content to the new CA bundle
117
+ new_ca_contents = []
118
+ try:
119
+ with open(provided_ca_bundle_path) as provided_ca_bundle_file:
120
+ new_ca_contents.append(provided_ca_bundle_file.read())
121
+ except PermissionError:
122
+ log.warning(
123
+ "PermissionError when reading from provided CA bundle path, falling back to temporary file with only the Source defined certificates."
124
+ )
101
125
 
102
- # Add all CAs for the source
126
+ # Finally, if no permissions to read or write to the provided CA bundle path, create a temporary file with only the Source defined certificates
103
127
  for required_ca in self._source_parameters.server_certificates.values():
104
128
  new_ca_contents.append(required_ca)
105
129
 
@@ -23,8 +23,3 @@ def has_expiration_property(source_credentials: SourceCredentials) -> bool:
23
23
  """
24
24
 
25
25
  return hasattr(source_credentials, "expiration")
26
-
27
-
28
- def read_file(path: str) -> str:
29
- with open(path) as file:
30
- return file.read()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: external-systems
3
- Version: 0.102.0
3
+ Version: 0.103.0rc2
4
4
  Summary: A Python library for interacting with Foundry Sources
5
5
  License: Apache-2.0
6
6
  Keywords: Palantir,Foundry,Sources,Compute Modules,Python Functions,Transforms
@@ -1,5 +1,5 @@
1
1
  external_systems/__init__.py,sha256=xXDUDD6_qRO-nHuXZx-fXp0R0vc3N_OOsB1F5mF_kpU,651
2
- external_systems/_version.py,sha256=aOeo7RvdkuBp6xLr7Odso1kea_U7b_Aa8uI1C1HczV8,749
2
+ external_systems/_version.py,sha256=lBi-RzbHSkavkwyphRFfL_xUs1muORLHKdGm5O_W6lQ,753
3
3
  external_systems/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  external_systems/sources/__init__.py,sha256=aqXbMIy_pnyIC1uPRzQfApLCbhYB4N8iRFnpOX4RdAk,1156
5
5
  external_systems/sources/_api.py,sha256=NV7oNIgzSWz4ROFW8uPpUJjDN5vfFzdTs3yKC37S39k,3262
@@ -7,9 +7,9 @@ external_systems/sources/_connections.py,sha256=h82npEks29NALAAfMHrXcSnB7TY_OLeX
7
7
  external_systems/sources/_proxies.py,sha256=8Rq197KkGXVkwlK8lJNxrs3b1xul09XGh9E4r9nedgA,5722
8
8
  external_systems/sources/_refreshable.py,sha256=0pa5XW0_2gTMW-ZymKhlhh3Kka_bWTWffThKvrTTifc,4421
9
9
  external_systems/sources/_sockets.py,sha256=XH51adVnloqg8XYVHPxl6K8R_q2BCh6WZ77cq1L8nRg,4473
10
- external_systems/sources/_sources.py,sha256=-DP1QzuCtXOnsijwTNxI9x2vyEmxgyRB47ZTVQshfXA,10829
11
- external_systems/sources/_utils.py,sha256=EmUKKiKRDOZ2cZs7FZ4qCSan_lq1K_tquh3kxleB-jA,1004
12
- external_systems-0.102.0.dist-info/LICENSE.txt,sha256=NAk6Uc9K_N_J5V75k9qECpzUnO-ujT-mKK_jk_mboUE,569
13
- external_systems-0.102.0.dist-info/METADATA,sha256=xiGatU8M_GLsJnwM94hw7lzXZ9qryB-KXcOZcYfCcFY,4765
14
- external_systems-0.102.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
15
- external_systems-0.102.0.dist-info/RECORD,,
10
+ external_systems/sources/_sources.py,sha256=a6MH5Q4IPKQ9uj2l-zntStxmfxb8Y-vSM0Xkb-OyNCc,12422
11
+ external_systems/sources/_utils.py,sha256=_GDyJOzPHQudEbrPsRhXMs8u6AaHpgJQIq8H9xSYJZk,913
12
+ external_systems-0.103.0rc2.dist-info/LICENSE.txt,sha256=NAk6Uc9K_N_J5V75k9qECpzUnO-ujT-mKK_jk_mboUE,569
13
+ external_systems-0.103.0rc2.dist-info/METADATA,sha256=AahfaqtOm4oDO_oTzI06jr-nYcYWmpqTEhteA4S_K-E,4768
14
+ external_systems-0.103.0rc2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
15
+ external_systems-0.103.0rc2.dist-info/RECORD,,