sumo-wrapper-python 1.0.22__tar.gz → 1.0.24__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.
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.gitignore +1 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/PKG-INFO +1 -1
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_auth_provider.py +34 -7
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_retry_strategy.py +1 -1
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_version.py +2 -2
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/sumo_client.py +27 -9
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.github/workflows/build_docs.yaml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.github/workflows/linting.yml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.github/workflows/publish_release.yml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.github/workflows/pytest.yml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.pre-commit-config.yaml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.readthedocs.yaml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/CONTRIBUTING.md +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/LICENSE +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/README.md +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/SECURITY.md +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/Makefile +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/_static/equinor-logo.png +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/_static/equinor-logo2.jpg +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/_static/equinor_logo.jpg +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/_static/equinor_logo_only.jpg +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/_templates/layout.html +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/api.rst +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/conf.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/index.rst +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/make.bat +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/sumo-wrapper-python.rst +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/pyproject.toml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/setup.cfg +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/__init__.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/__init__.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_blob_client.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_decorators.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_logging.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/config.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/login.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo_wrapper_python.egg-info/SOURCES.txt +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/tests/conftest.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/tests/test_sumo_thin_client.py +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/tests/testdata/case.yml +0 -0
- {sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/tests/testdata/surface.yml +0 -0
{sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_auth_provider.py
RENAMED
|
@@ -4,7 +4,8 @@ import os
|
|
|
4
4
|
import stat
|
|
5
5
|
import sys
|
|
6
6
|
import time
|
|
7
|
-
from datetime import datetime, timedelta
|
|
7
|
+
from datetime import datetime, timedelta, timezone
|
|
8
|
+
from urllib.parse import parse_qs
|
|
8
9
|
|
|
9
10
|
import jwt
|
|
10
11
|
import msal
|
|
@@ -30,20 +31,17 @@ def _maybe_nfs_exception(exception):
|
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
def get_token_dir():
|
|
33
|
-
return os.path.
|
|
34
|
+
return os.path.expanduser("~/.sumo")
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
def get_token_path(resource_id, suffix, case_uuid=None):
|
|
37
38
|
if case_uuid is not None:
|
|
38
39
|
return os.path.join(
|
|
39
|
-
|
|
40
|
-
".sumo",
|
|
40
|
+
get_token_dir(),
|
|
41
41
|
str(resource_id) + "+" + str(case_uuid) + suffix,
|
|
42
42
|
)
|
|
43
43
|
else:
|
|
44
|
-
return os.path.join(
|
|
45
|
-
os.path.expanduser("~"), ".sumo", str(resource_id) + suffix
|
|
46
|
-
)
|
|
44
|
+
return os.path.join(get_token_dir(), str(resource_id) + suffix)
|
|
47
45
|
|
|
48
46
|
|
|
49
47
|
class AuthProvider:
|
|
@@ -91,6 +89,7 @@ class AuthProvider:
|
|
|
91
89
|
) as f:
|
|
92
90
|
f.write(token)
|
|
93
91
|
protect_token_cache(self._resource_id, ".sharedkey", case_uuid)
|
|
92
|
+
return
|
|
94
93
|
|
|
95
94
|
def has_case_token(self, case_uuid):
|
|
96
95
|
return os.path.exists(
|
|
@@ -459,3 +458,31 @@ def get_auth_provider(
|
|
|
459
458
|
]
|
|
460
459
|
):
|
|
461
460
|
return AuthProviderManaged(resource_id)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def cleanup_shared_keys():
|
|
464
|
+
tokendir = get_token_dir()
|
|
465
|
+
if not os.path.exists(tokendir):
|
|
466
|
+
return
|
|
467
|
+
for f in os.listdir(tokendir):
|
|
468
|
+
ff = os.path.join(tokendir, f)
|
|
469
|
+
if os.path.isfile(ff):
|
|
470
|
+
(name, ext) = os.path.splitext(ff)
|
|
471
|
+
if ext.lower() == ".sharedkey":
|
|
472
|
+
try:
|
|
473
|
+
with open(ff, "r") as file:
|
|
474
|
+
token = file.read()
|
|
475
|
+
pq = parse_qs(token)
|
|
476
|
+
se = pq["se"][0]
|
|
477
|
+
end = datetime.strptime(se, "%Y-%m-%dT%H:%M:%S.%fZ")
|
|
478
|
+
now = datetime.now(timezone.utc)
|
|
479
|
+
if now.timestamp() > end.timestamp():
|
|
480
|
+
os.unlink(ff)
|
|
481
|
+
pass
|
|
482
|
+
pass
|
|
483
|
+
pass
|
|
484
|
+
except Exception:
|
|
485
|
+
pass
|
|
486
|
+
pass
|
|
487
|
+
pass
|
|
488
|
+
return
|
{sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/src/sumo/wrapper/_retry_strategy.py
RENAMED
|
@@ -30,7 +30,7 @@ def _is_retryable_exception(exception):
|
|
|
30
30
|
|
|
31
31
|
# Define the conditions for retrying based on HTTP status codes
|
|
32
32
|
def _is_retryable_status_code(response):
|
|
33
|
-
return response.status_code in [502, 503
|
|
33
|
+
return response.status_code in [502, 503]
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def _return_last_value(retry_state):
|
|
@@ -6,7 +6,7 @@ import re
|
|
|
6
6
|
import httpx
|
|
7
7
|
import jwt
|
|
8
8
|
|
|
9
|
-
from ._auth_provider import get_auth_provider
|
|
9
|
+
from ._auth_provider import cleanup_shared_keys, get_auth_provider
|
|
10
10
|
from ._blob_client import BlobClient
|
|
11
11
|
from ._decorators import (
|
|
12
12
|
raise_for_status,
|
|
@@ -34,6 +34,8 @@ class SumoClient:
|
|
|
34
34
|
retry_strategy=RetryStrategy(),
|
|
35
35
|
timeout=DEFAULT_TIMEOUT,
|
|
36
36
|
case_uuid=None,
|
|
37
|
+
http_client=None,
|
|
38
|
+
async_http_client=None,
|
|
37
39
|
):
|
|
38
40
|
"""Initialize a new Sumo object
|
|
39
41
|
|
|
@@ -54,8 +56,19 @@ class SumoClient:
|
|
|
54
56
|
self._verbosity = verbosity
|
|
55
57
|
|
|
56
58
|
self._retry_strategy = retry_strategy
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
if http_client is None:
|
|
60
|
+
self._client = httpx.Client()
|
|
61
|
+
self._borrowed_client = False
|
|
62
|
+
else:
|
|
63
|
+
self._client = http_client
|
|
64
|
+
self._borrowed_client = True
|
|
65
|
+
|
|
66
|
+
if async_http_client is None:
|
|
67
|
+
self._async_client = httpx.AsyncClient()
|
|
68
|
+
self._borrowed_async_client = False
|
|
69
|
+
else:
|
|
70
|
+
self._async_client = async_http_client
|
|
71
|
+
self._borrowed_async_client = True
|
|
59
72
|
|
|
60
73
|
self._timeout = timeout
|
|
61
74
|
|
|
@@ -81,6 +94,9 @@ class SumoClient:
|
|
|
81
94
|
refresh_token = token
|
|
82
95
|
pass
|
|
83
96
|
pass
|
|
97
|
+
|
|
98
|
+
cleanup_shared_keys()
|
|
99
|
+
|
|
84
100
|
self.auth = get_auth_provider(
|
|
85
101
|
client_id=APP_REGISTRATION[env]["CLIENT_ID"],
|
|
86
102
|
authority=f"{AUTHORITY_HOST_URI}/{TENANT_ID}",
|
|
@@ -103,7 +119,8 @@ class SumoClient:
|
|
|
103
119
|
return self
|
|
104
120
|
|
|
105
121
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
106
|
-
self.
|
|
122
|
+
if not self._borrowed_client:
|
|
123
|
+
self._client.close()
|
|
107
124
|
self._client = None
|
|
108
125
|
return False
|
|
109
126
|
|
|
@@ -111,16 +128,17 @@ class SumoClient:
|
|
|
111
128
|
return self
|
|
112
129
|
|
|
113
130
|
async def __aexit__(self, exc_type, exc_value, traceback):
|
|
114
|
-
|
|
131
|
+
if not self._borrowed_async_client:
|
|
132
|
+
await self._async_client.aclose()
|
|
115
133
|
self._async_client = None
|
|
116
134
|
return False
|
|
117
135
|
|
|
118
136
|
def __del__(self):
|
|
119
|
-
if self._client is not None:
|
|
137
|
+
if self._client is not None and not self._borrowed_client:
|
|
120
138
|
self._client.close()
|
|
121
|
-
self._client = None
|
|
122
139
|
pass
|
|
123
|
-
|
|
140
|
+
self._client = None
|
|
141
|
+
if self._async_client is not None and not self._borrowed_async_client:
|
|
124
142
|
|
|
125
143
|
async def closeit(client):
|
|
126
144
|
await client.aclose()
|
|
@@ -131,8 +149,8 @@ class SumoClient:
|
|
|
131
149
|
loop.create_task(closeit(self._async_client))
|
|
132
150
|
except RuntimeError:
|
|
133
151
|
pass
|
|
134
|
-
self._async_client = None
|
|
135
152
|
pass
|
|
153
|
+
self._async_client = None
|
|
136
154
|
|
|
137
155
|
def authenticate(self):
|
|
138
156
|
if self.auth is None:
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/.github/workflows/publish_release.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.0.22 → sumo_wrapper_python-1.0.24}/docs/_static/equinor_logo_only.jpg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|