atomicshop 3.3.22__py3-none-any.whl → 3.3.23__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 atomicshop might be problematic. Click here for more details.

atomicshop/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '3.3.22'
4
+ __version__ = '3.3.23'
atomicshop/web.py CHANGED
@@ -1,11 +1,13 @@
1
1
  import os
2
2
  import urllib.request
3
+ import urllib.error
3
4
  import ssl
4
5
  from typing import Any
6
+ import http.client
7
+
5
8
  # noinspection PyPackageRequirements
6
9
  import certifi
7
10
 
8
-
9
11
  from .archiver import zips
10
12
  from .urls import url_parser
11
13
  from .file_io import file_io
@@ -211,12 +213,34 @@ def download(
211
213
  # Create a default SSL context using the certifi CA store.
212
214
  # This is useful for environments where the system's CA store is not available or not trusted.
213
215
  # 'certifi.where()' returns the path to the certifi CA bundle.
214
- ssl_context = ssl.create_default_context(cafile=certifi.where())
216
+ ssl_context: ssl.SSLContext = ssl.create_default_context(cafile=certifi.where())
215
217
 
216
218
  # In order to use 'urllib.request', it is not enough to 'import urllib', you need to 'import urllib.request'.
217
219
  # Build a Request object with headers if provided.
218
220
  req = urllib.request.Request(file_url, headers=headers or {})
219
- file_to_download = urllib.request.urlopen(req, context=ssl_context)
221
+
222
+ def do_urlopen(ssl_context_internal: ssl.SSLContext) -> http.client.HTTPResponse | None:
223
+ try:
224
+ response: http.client.HTTPResponse = urllib.request.urlopen(req, context=ssl_context_internal)
225
+ return response
226
+ except urllib.error.URLError as e:
227
+ if getattr(e, 'reason', None) and isinstance(e.reason, ssl.SSLCertVerificationError):
228
+ if getattr(e.reason, 'reason', None) and e.reason.reason == 'CERTIFICATE_VERIFY_FAILED':
229
+ if getattr(e.reason, 'verify_message', None) and e.reason.verify_message == 'unable to get local issuer certificate':
230
+ return None
231
+
232
+ raise e
233
+
234
+ # Try to open the URL with the created SSL context with certifi.
235
+ file_to_download = do_urlopen(ssl_context_internal=ssl_context)
236
+ if not file_to_download:
237
+ # If failed, try to open the URL with the system's default SSL context.
238
+ ssl_context = ssl.create_default_context()
239
+ file_to_download = do_urlopen(ssl_context_internal=ssl_context)
240
+ if not file_to_download:
241
+ print_api.print_api(
242
+ 'ERROR: URL open failed with both certifi and system\'s default SSL context.', error_type=True, **kwargs)
243
+ return None
220
244
 
221
245
  # Check status of url.
222
246
  if not is_status_ok(status_code=file_to_download.status, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atomicshop
3
- Version: 3.3.22
3
+ Version: 3.3.23
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=CwR_3jqYkF_a_nmrM3h4bWwuqn_DXHc7ThZPhoeOZoE,123
1
+ atomicshop/__init__.py,sha256=SVEyQmBJFUE371lRYyRuD9Bi1k7XEA5UIZulvlGbD8k,123
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
4
4
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
@@ -48,7 +48,7 @@ atomicshop/uuids.py,sha256=JSQdm3ZTJiwPQ1gYe6kU0TKS_7suwVrHc8JZDGYlydM,2214
48
48
  atomicshop/venvs.py,sha256=D9lwOoObkYoRx-weuoAmbvN-RdSHhVm4DE9TVl-utAs,903
49
49
  atomicshop/versioning.py,sha256=e5W6m9AF3__M5nntqI9CqNAeHqkwY9JhlnpYeZ1CEus,970
50
50
  atomicshop/virtualization.py,sha256=LPP4vjE0Vr10R6DA4lqhfX_WaNdDGRAZUW0Am6VeGco,494
51
- atomicshop/web.py,sha256=zceiDUNIJfSSOKXNaKthvQJpIkU_sTTCWDEBbIQ_K5g,13068
51
+ atomicshop/web.py,sha256=mHWrHb-zl0NRg7oHBZr-0k66aTBmKLvanBzoCZ63Xks,14340
52
52
  atomicshop/websocket_parse.py,sha256=aLHWyKqaYqEn_MRBWm2L6rIl6QPmqbVrjEXE_rBzwCw,16711
53
53
  atomicshop/a_installs/ubuntu/docker_rootless.py,sha256=9IPNtGZYjfy1_n6ZRt7gWz9KZgR6XCgevjqq02xk-o0,281
54
54
  atomicshop/a_installs/ubuntu/docker_sudo.py,sha256=JzayxeyKDtiuT4Icp2L2LyFRbx4wvpyN_bHLfZ-yX5E,281
@@ -314,8 +314,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=_gA8bMX6Sw_UCXKi2y9wNAwlqif
314
314
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
315
315
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
316
316
  atomicshop/wrappers/winregw/winreg_network.py,sha256=ih0BVNwByLvf9F_Lac4EdmDYYJA3PzMvmG0PieDZrsE,9905
317
- atomicshop-3.3.22.dist-info/licenses/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
318
- atomicshop-3.3.22.dist-info/METADATA,sha256=XyMxJFTTJwHywcPPUpS42MjToQQiaXSP6vjxpdphYH0,9312
319
- atomicshop-3.3.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
320
- atomicshop-3.3.22.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
321
- atomicshop-3.3.22.dist-info/RECORD,,
317
+ atomicshop-3.3.23.dist-info/licenses/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
318
+ atomicshop-3.3.23.dist-info/METADATA,sha256=xbmLVSZnBgpxy0Q-fUDt--RFuw8RANnPINcEeZZwg3U,9312
319
+ atomicshop-3.3.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
320
+ atomicshop-3.3.23.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
321
+ atomicshop-3.3.23.dist-info/RECORD,,