pyrelukko 0.6.1__tar.gz → 0.8.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.
Potentially problematic release.
This version of pyrelukko might be problematic. Click here for more details.
- pyrelukko-0.8.0/PKG-INFO +40 -0
- pyrelukko-0.8.0/README.md +19 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/run_pytest.sh +1 -1
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/pyproject.toml +2 -2
- pyrelukko-0.6.1/src/pyrelukko/retry.py → pyrelukko-0.8.0/src/pyrelukko/decorators.py +36 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/src/pyrelukko/pyrelukko.py +10 -1
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/src/pyrelukko/testcontainers.py +5 -2
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/src/pyrelukko/version.py +1 -1
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/conftest.py +6 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/test_relukko.py +1 -1
- pyrelukko-0.8.0/tests/test_skip_relukko.py +48 -0
- pyrelukko-0.6.1/PKG-INFO +0 -24
- pyrelukko-0.6.1/README.md +0 -3
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/.gitlab-ci.yml +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/LICENSE +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/run_docs_pages.sh +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/run_publish.sh +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/run_pylint.sh +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/run_shellcheck.sh +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/tox_docs_pages.sh +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/tox_publish.sh +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/cicd/tox_shellcheck.sh +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/src/pyrelukko/__init__.py +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/5d868fca.0 +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/README.md +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/relukko.crt +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/relukko.csr +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/relukko.key +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/rootCA.crt +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/rootCA.der +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/rootCA.key +0 -0
- {pyrelukko-0.6.1 → pyrelukko-0.8.0}/tests/cert/rootCA.srl +0 -0
pyrelukko-0.8.0/PKG-INFO
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pyrelukko
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: Relukko client.
|
|
5
|
+
Author-email: Reto Zingg <g.d0b3rm4n@gmail.com>
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Dist: requests >=2.32.3
|
|
17
|
+
Requires-Dist: websockets >= 14.1
|
|
18
|
+
Project-URL: Homepage, https://gitlab.com/relukko/pyrelukko
|
|
19
|
+
Project-URL: Issues, https://gitlab.com/relukko/pyrelukko/-/issues
|
|
20
|
+
|
|
21
|
+
# PyRelukko
|
|
22
|
+
|
|
23
|
+
[](https://pypi.org/project/pyrelukko)
|
|
24
|
+
[](https://pypi.org/project/pyrelukko)
|
|
25
|
+

|
|
26
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
-----
|
|
37
|
+
|
|
38
|
+
Python library to access a
|
|
39
|
+
[Relukko back-end](https://gitlab.com/relukko/relukko).
|
|
40
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# PyRelukko
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/pyrelukko)
|
|
4
|
+
[](https://pypi.org/project/pyrelukko)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+
-----
|
|
17
|
+
|
|
18
|
+
Python library to access a
|
|
19
|
+
[Relukko back-end](https://gitlab.com/relukko/relukko).
|
|
@@ -16,7 +16,7 @@ classifiers = [
|
|
|
16
16
|
"Programming Language :: Python :: 3.12",
|
|
17
17
|
"Programming Language :: Python :: 3.13",
|
|
18
18
|
]
|
|
19
|
-
requires-python = ">=3.
|
|
19
|
+
requires-python = ">=3.11"
|
|
20
20
|
dynamic = ["version", "description"]
|
|
21
21
|
dependencies = [
|
|
22
22
|
"requests >=2.32.3",
|
|
@@ -43,7 +43,7 @@ publish = [
|
|
|
43
43
|
]
|
|
44
44
|
|
|
45
45
|
[tool.flit.sdist]
|
|
46
|
-
exclude = [".gitignore", "demo.py"]
|
|
46
|
+
exclude = [".gitignore", "demo.py", "utils"]
|
|
47
47
|
|
|
48
48
|
[project.urls]
|
|
49
49
|
Homepage = "https://gitlab.com/relukko/pyrelukko"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
TBD
|
|
3
3
|
"""
|
|
4
|
+
import os
|
|
4
5
|
import time
|
|
5
6
|
from functools import wraps
|
|
6
7
|
|
|
@@ -43,3 +44,38 @@ def retry(logger, exceptions, tries=4, delay=5,
|
|
|
43
44
|
return f(*args, **kwargs)
|
|
44
45
|
return f_retry # true decorator
|
|
45
46
|
return deco_retry
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
SKIP_RELUKKO = {
|
|
50
|
+
"id": "00000000-0000-0000-0000-000000000000",
|
|
51
|
+
"lock_name": "WE TRUST YOU",
|
|
52
|
+
"creator": "Dummy Dummy",
|
|
53
|
+
"ip": "0.0.0.0",
|
|
54
|
+
"expires_at": "1970-01-01T00:00:00Z",
|
|
55
|
+
"created_at": "1970-01-01T00:00:00Z",
|
|
56
|
+
"updated_at": "1970-01-01T00:00:00Z"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def skip_http_call():
|
|
61
|
+
"""
|
|
62
|
+
Decorator for pyrlukko methods.
|
|
63
|
+
|
|
64
|
+
It skips the actual method if the environment variable
|
|
65
|
+
`RELUKKO_TRUST_ME_IT_IS_LOCKED` is set and returns instead a static lock
|
|
66
|
+
dictionary or list with the same static lock dictionary.
|
|
67
|
+
|
|
68
|
+
Useful when developing and the resource is for sure locked, e.g through the
|
|
69
|
+
Web UI.
|
|
70
|
+
"""
|
|
71
|
+
def deco_skip(f):
|
|
72
|
+
|
|
73
|
+
@wraps(f)
|
|
74
|
+
def f_skip(*args, **kwargs):
|
|
75
|
+
if os.environ.get('RELUKKO_TRUST_ME_IT_IS_LOCKED'):
|
|
76
|
+
if f.__name__ == "get_locks":
|
|
77
|
+
return [ SKIP_RELUKKO ]
|
|
78
|
+
return SKIP_RELUKKO
|
|
79
|
+
return f(*args, **kwargs)
|
|
80
|
+
return f_skip # true decorator
|
|
81
|
+
return deco_skip
|
|
@@ -18,7 +18,7 @@ from urllib3.util.retry import Retry
|
|
|
18
18
|
from websockets import ConnectionClosed as WsConnectionClosed
|
|
19
19
|
from websockets.asyncio.client import connect as ws_connect
|
|
20
20
|
|
|
21
|
-
from .
|
|
21
|
+
from .decorators import retry, skip_http_call
|
|
22
22
|
|
|
23
23
|
SSL_KWARGS = [
|
|
24
24
|
'check_hostname',
|
|
@@ -300,6 +300,7 @@ class RelukkoClient:
|
|
|
300
300
|
|
|
301
301
|
return _do_request()
|
|
302
302
|
|
|
303
|
+
@skip_http_call()
|
|
303
304
|
def acquire_relukko(self, lock_name, creator, max_run_time):
|
|
304
305
|
"""
|
|
305
306
|
TBD
|
|
@@ -336,6 +337,7 @@ class RelukkoClient:
|
|
|
336
337
|
return thread_store[0]
|
|
337
338
|
return None
|
|
338
339
|
|
|
340
|
+
@skip_http_call()
|
|
339
341
|
def get_lock(self, lock_id: str) -> Dict:
|
|
340
342
|
"""
|
|
341
343
|
TBD
|
|
@@ -343,6 +345,7 @@ class RelukkoClient:
|
|
|
343
345
|
url = f"{self.base_url}/v1/locks/{lock_id}"
|
|
344
346
|
return self._make_request(url, "GET")
|
|
345
347
|
|
|
348
|
+
@skip_http_call()
|
|
346
349
|
def get_locks(self) -> List:
|
|
347
350
|
"""
|
|
348
351
|
TBD
|
|
@@ -350,6 +353,7 @@ class RelukkoClient:
|
|
|
350
353
|
url = f"{self.base_url}/v1/locks/"
|
|
351
354
|
return self._make_request(url, "GET")
|
|
352
355
|
|
|
356
|
+
@skip_http_call()
|
|
353
357
|
def update_relukko(
|
|
354
358
|
self, lock_id: str, creator: str=None, expires_at: datetime=None):
|
|
355
359
|
"""
|
|
@@ -367,6 +371,7 @@ class RelukkoClient:
|
|
|
367
371
|
url = f"{self.base_url}/v1/locks/{lock_id}"
|
|
368
372
|
return self._make_request(url, "PUT", payload)
|
|
369
373
|
|
|
374
|
+
@skip_http_call()
|
|
370
375
|
def delete_relukko(self, lock_id: str):
|
|
371
376
|
"""
|
|
372
377
|
TBD
|
|
@@ -374,6 +379,7 @@ class RelukkoClient:
|
|
|
374
379
|
url = f"{self.base_url}/v1/locks/{lock_id}"
|
|
375
380
|
return self._make_request(url, "DELETE")
|
|
376
381
|
|
|
382
|
+
@skip_http_call()
|
|
377
383
|
def keep_relukko_alive(self, lock_id: str):
|
|
378
384
|
"""
|
|
379
385
|
TBD
|
|
@@ -381,6 +387,7 @@ class RelukkoClient:
|
|
|
381
387
|
url = f"{self.base_url}/v1/locks/{lock_id}/keep_alive"
|
|
382
388
|
return self._make_request(url, "GET")
|
|
383
389
|
|
|
390
|
+
@skip_http_call()
|
|
384
391
|
def keep_relukko_alive_put(self, lock_id: str, seconds: int):
|
|
385
392
|
"""
|
|
386
393
|
TBD
|
|
@@ -391,6 +398,7 @@ class RelukkoClient:
|
|
|
391
398
|
}
|
|
392
399
|
return self._make_request(url, "PUT", payload)
|
|
393
400
|
|
|
401
|
+
@skip_http_call()
|
|
394
402
|
def add_to_expires_at_time(self, lock_id: str):
|
|
395
403
|
"""
|
|
396
404
|
TBD
|
|
@@ -398,6 +406,7 @@ class RelukkoClient:
|
|
|
398
406
|
url = f"{self.base_url}/v1/locks/{lock_id}/add_to_expire_at"
|
|
399
407
|
return self._make_request(url, "GET")
|
|
400
408
|
|
|
409
|
+
@skip_http_call()
|
|
401
410
|
def add_to_expires_at_time_put(self, lock_id: str, seconds: int):
|
|
402
411
|
"""
|
|
403
412
|
TBD
|
|
@@ -14,6 +14,7 @@ def relukko_backend():
|
|
|
14
14
|
base_url=backend.get_api_url(), api_key="somekey")
|
|
15
15
|
yield relukko, backend
|
|
16
16
|
"""
|
|
17
|
+
import os
|
|
17
18
|
import socket
|
|
18
19
|
|
|
19
20
|
from testcontainers.core.network import Network
|
|
@@ -24,10 +25,12 @@ from testcontainers.postgres import PostgresContainer
|
|
|
24
25
|
|
|
25
26
|
class RelukkoContainer(ServerContainer):
|
|
26
27
|
def __init__(self, net: Network,
|
|
27
|
-
image="registry.gitlab.com/relukko/relukko:latest",
|
|
28
|
+
image="registry.gitlab.com/relukko/relukko:latest",
|
|
29
|
+
db_url=None):
|
|
30
|
+
container_image = os.environ.get('CI_RELUKKO_CONTAINER_IMAGE') or image
|
|
28
31
|
self.db_url = db_url
|
|
29
32
|
self.net = net
|
|
30
|
-
super(RelukkoContainer, self).__init__(image=
|
|
33
|
+
super(RelukkoContainer, self).__init__(image=container_image, port=3000)
|
|
31
34
|
|
|
32
35
|
def _configure(self):
|
|
33
36
|
self.with_env("DATABASE_URL", self.db_url)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# pylint: disable=all
|
|
2
|
-
__version__ = "0.
|
|
2
|
+
__version__ = "0.8.0"
|
|
@@ -77,3 +77,9 @@ def tls_listener():
|
|
|
77
77
|
|
|
78
78
|
keep_running.clear()
|
|
79
79
|
thread.join()
|
|
80
|
+
|
|
81
|
+
@pytest.fixture(scope="function")
|
|
82
|
+
def mock_env_relukko_skip(monkeypatch):
|
|
83
|
+
monkeypatch.setenv("RELUKKO_TRUST_ME_IT_IS_LOCKED", "yes")
|
|
84
|
+
yield
|
|
85
|
+
monkeypatch.delenv("RELUKKO_TRUST_ME_IT_IS_LOCKED", raising=True)
|
|
@@ -15,7 +15,7 @@ from urllib3.util import parse_url
|
|
|
15
15
|
|
|
16
16
|
from pyrelukko import RelukkoClient
|
|
17
17
|
from pyrelukko.pyrelukko import RelukkoDoRetry
|
|
18
|
-
from pyrelukko.
|
|
18
|
+
from pyrelukko.decorators import retry
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
SCRIPT_DIR = Path(__file__).parent.absolute()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
from pyrelukko import RelukkoClient
|
|
5
|
+
from pyrelukko.decorators import SKIP_RELUKKO
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
exp_expires_at = datetime.fromisoformat(SKIP_RELUKKO["expires_at"])
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_skip_life_cycle(mock_env_relukko_skip):
|
|
12
|
+
assert mock_env_relukko_skip is None
|
|
13
|
+
relukko = RelukkoClient(base_url="http://relukko", api_key="abc")
|
|
14
|
+
|
|
15
|
+
skipped = relukko.acquire_relukko(
|
|
16
|
+
"SKIP_THIS", creator="skipper", max_run_time=5)
|
|
17
|
+
assert skipped == SKIP_RELUKKO
|
|
18
|
+
|
|
19
|
+
lock = relukko.get_lock(
|
|
20
|
+
"00000000-0000-0000-0000-000000000000")
|
|
21
|
+
assert lock == SKIP_RELUKKO
|
|
22
|
+
|
|
23
|
+
locks = relukko.get_locks()
|
|
24
|
+
assert locks == [ SKIP_RELUKKO ]
|
|
25
|
+
|
|
26
|
+
lock = relukko.update_relukko(
|
|
27
|
+
"00000000-0000-0000-0000-000000000000", creator="Skipper")
|
|
28
|
+
assert lock == SKIP_RELUKKO
|
|
29
|
+
|
|
30
|
+
lock = relukko.delete_relukko(
|
|
31
|
+
"00000000-0000-0000-0000-000000000000")
|
|
32
|
+
assert lock == SKIP_RELUKKO
|
|
33
|
+
|
|
34
|
+
lock = relukko.keep_relukko_alive(
|
|
35
|
+
"00000000-0000-0000-0000-000000000000")
|
|
36
|
+
assert lock == SKIP_RELUKKO
|
|
37
|
+
|
|
38
|
+
lock = relukko.keep_relukko_alive_put(
|
|
39
|
+
"00000000-0000-0000-0000-000000000000", 5)
|
|
40
|
+
assert lock == SKIP_RELUKKO
|
|
41
|
+
|
|
42
|
+
lock = relukko.add_to_expires_at_time(
|
|
43
|
+
"00000000-0000-0000-0000-000000000000")
|
|
44
|
+
assert lock == SKIP_RELUKKO
|
|
45
|
+
|
|
46
|
+
lock = relukko.add_to_expires_at_time_put(
|
|
47
|
+
"00000000-0000-0000-0000-000000000000", 5)
|
|
48
|
+
assert lock == SKIP_RELUKKO
|
pyrelukko-0.6.1/PKG-INFO
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: pyrelukko
|
|
3
|
-
Version: 0.6.1
|
|
4
|
-
Summary: Relukko client.
|
|
5
|
-
Author-email: Reto Zingg <g.d0b3rm4n@gmail.com>
|
|
6
|
-
Requires-Python: >=3.10
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Classifier: Development Status :: 4 - Beta
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Topic :: Internet :: WWW/HTTP
|
|
12
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Requires-Dist: requests >=2.32.3
|
|
17
|
-
Requires-Dist: websockets >= 14.1
|
|
18
|
-
Project-URL: Homepage, https://gitlab.com/relukko/pyrelukko
|
|
19
|
-
Project-URL: Issues, https://gitlab.com/relukko/pyrelukko/-/issues
|
|
20
|
-
|
|
21
|
-
# PyRelukko
|
|
22
|
-
Python library to access a
|
|
23
|
-
[Relukko back-end](https://gitlab.com/relukko/relukko).
|
|
24
|
-
|
pyrelukko-0.6.1/README.md
DELETED
|
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
|