sumo-wrapper-python 1.4.0__tar.gz → 1.5.0__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 (45) hide show
  1. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/PKG-INFO +1 -1
  2. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/_auth_provider.py +11 -2
  3. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/_decorators.py +8 -4
  4. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/_version.py +3 -3
  5. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/sumo_client.py +7 -0
  6. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
  7. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/.github/workflows/build_docs.yaml +0 -0
  8. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/.github/workflows/linting.yml +0 -0
  9. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/.github/workflows/publish_release.yml +0 -0
  10. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/.github/workflows/pytest.yml +0 -0
  11. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/.gitignore +0 -0
  12. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/.pre-commit-config.yaml +0 -0
  13. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/.readthedocs.yaml +0 -0
  14. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/CONTRIBUTING.md +0 -0
  15. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/LICENSE +0 -0
  16. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/README.md +0 -0
  17. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/SECURITY.md +0 -0
  18. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/Makefile +0 -0
  19. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/_static/equinor-logo.png +0 -0
  20. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/_static/equinor-logo2.jpg +0 -0
  21. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/_static/equinor_logo.jpg +0 -0
  22. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/_static/equinor_logo_only.jpg +0 -0
  23. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/_templates/layout.html +0 -0
  24. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/api.rst +0 -0
  25. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/conf.py +0 -0
  26. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/index.rst +0 -0
  27. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/make.bat +0 -0
  28. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/docs/sumo-wrapper-python.rst +0 -0
  29. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/pyproject.toml +0 -0
  30. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/setup.cfg +0 -0
  31. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/__init__.py +0 -0
  32. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/__init__.py +0 -0
  33. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/_blob_client.py +0 -0
  34. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/_logging.py +0 -0
  35. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/_retry_strategy.py +0 -0
  36. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo/wrapper/login.py +0 -0
  37. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo_wrapper_python.egg-info/SOURCES.txt +0 -0
  38. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
  39. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
  40. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
  41. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
  42. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/tests/conftest.py +0 -0
  43. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/tests/test_sumo_thin_client.py +0 -0
  44. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/tests/testdata/case.yml +0 -0
  45. {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.5.0}/tests/testdata/surface.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumo-wrapper-python
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -99,6 +99,9 @@ class AuthProvider:
99
99
  get_token_path(self._resource_id, ".sharedkey", case_uuid)
100
100
  )
101
101
 
102
+ def delete_token(self):
103
+ return False
104
+
102
105
  pass
103
106
 
104
107
 
@@ -400,9 +403,10 @@ class AuthProviderSumoToken(AuthProvider):
400
403
  def __init__(self, resource_id, case_uuid=None):
401
404
  super().__init__(resource_id)
402
405
  protect_token_cache(resource_id, ".sharedkey", case_uuid)
403
- token_path = get_token_path(resource_id, ".sharedkey", case_uuid)
404
- with open(token_path, "r") as f:
406
+ self.token_path = get_token_path(resource_id, ".sharedkey", case_uuid)
407
+ with open(self.token_path, "r") as f:
405
408
  self._token = f.readline().strip()
409
+
406
410
  return
407
411
 
408
412
  def get_token(self):
@@ -411,6 +415,11 @@ class AuthProviderSumoToken(AuthProvider):
411
415
  def get_authorization(self):
412
416
  return {"X-SUMO-Token": self._token}
413
417
 
418
+ def delete_token(self):
419
+ if os.path.exists(self.token_path):
420
+ os.unlink(self.token_path)
421
+ return True
422
+
414
423
 
415
424
  @tn.retry(
416
425
  retry=tn.retry_if_exception(_maybe_nfs_exception),
@@ -4,11 +4,13 @@ from functools import wraps
4
4
 
5
5
  def raise_for_status(func):
6
6
  @wraps(func)
7
- def wrapper(*args, **kwargs):
7
+ def wrapper(self, *args, **kwargs):
8
8
  # FIXME: in newer versions of httpx, raise_for_status() is chainable,
9
9
  # so we could simply write
10
10
  # return func(*args, **kwargs).raise_for_status()
11
- response = func(*args, **kwargs)
11
+ response = func(self, *args, **kwargs)
12
+ if response.status_code == 401:
13
+ self._handle_invalid_shared_key()
12
14
  response.raise_for_status()
13
15
  return response
14
16
 
@@ -17,11 +19,13 @@ def raise_for_status(func):
17
19
 
18
20
  def raise_for_status_async(func):
19
21
  @wraps(func)
20
- async def wrapper(*args, **kwargs):
22
+ async def wrapper(self, *args, **kwargs):
21
23
  # FIXME: in newer versions of httpx, raise_for_status() is chainable,
22
24
  # so we could simply write
23
25
  # return func(*args, **kwargs).raise_for_status()
24
- response = await func(*args, **kwargs)
26
+ response = await func(self, *args, **kwargs)
27
+ if response.status_code == 401:
28
+ self._handle_invalid_shared_key()
25
29
  response.raise_for_status()
26
30
  return response
27
31
 
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '1.4.0'
32
- __version_tuple__ = version_tuple = (1, 4, 0)
31
+ __version__ = version = '1.5.0'
32
+ __version_tuple__ = version_tuple = (1, 5, 0)
33
33
 
34
- __commit_id__ = commit_id = 'g8c4d4a4f8'
34
+ __commit_id__ = commit_id = 'g2790997c5'
@@ -208,6 +208,13 @@ class SumoClient:
208
208
  self._retry_strategy,
209
209
  )
210
210
 
211
+ def _handle_invalid_shared_key(self):
212
+ """Handle the invalid shared key by deleting it."""
213
+ if self.auth.delete_token():
214
+ print(
215
+ "Invalid shared key detected and deleted, run again to reset automatically"
216
+ )
217
+
211
218
  @raise_for_status
212
219
  def get(self, path: str, params: Optional[Dict] = None) -> httpx.Response:
213
220
  """Performs a GET-request to the Sumo API.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumo-wrapper-python
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License