pyrelukko 0.6.1__py3-none-any.whl → 0.8.0__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 pyrelukko might be problematic. Click here for more details.

@@ -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
pyrelukko/pyrelukko.py CHANGED
@@ -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 .retry import retry
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", db_url=None):
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=image, port=3000)
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)
pyrelukko/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # pylint: disable=all
2
- __version__ = "0.6.1"
2
+ __version__ = "0.8.0"
@@ -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
+ [![PyPI - Version](https://img.shields.io/pypi/v/pyrelukko.svg)](https://pypi.org/project/pyrelukko)
24
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyrelukko.svg)](https://pypi.org/project/pyrelukko)
25
+ ![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fgitlab.com%2Frelukko%2Fpyrelukko%2F-%2Fraw%2Fmaster%2Fpyproject.toml%3Fref_type%3Dheads)
26
+ ![Gitlab Pipeline Status](https://img.shields.io/gitlab/pipeline-status/relukko%2Fpyrelukko?branch=master)
27
+ ![PyPI - Downloads](https://img.shields.io/pypi/dm/pyrelukko)
28
+ ![PyPI - License](https://img.shields.io/pypi/l/pyrelukko)
29
+ ![GitLab License](https://img.shields.io/gitlab/license/relukko%2Fpyrelukko)
30
+ ![PyPI - Format](https://img.shields.io/pypi/format/pyrelukko)
31
+ ![PyPI - Status](https://img.shields.io/pypi/status/pyrelukko)
32
+ ![PyPI - Implementation](https://img.shields.io/pypi/implementation/pyrelukko)
33
+ ![PyPI - Wheel](https://img.shields.io/pypi/wheel/pyrelukko)
34
+ ![GitLab Stars](https://img.shields.io/gitlab/stars/relukko%2Fpyrelukko)
35
+ ![GitLab Forks](https://img.shields.io/gitlab/forks/relukko%2Fpyrelukko)
36
+ -----
37
+
38
+ Python library to access a
39
+ [Relukko back-end](https://gitlab.com/relukko/relukko).
40
+
@@ -0,0 +1,9 @@
1
+ pyrelukko/__init__.py,sha256=n-mTJV7AOfr4bljtDxok3E3gXIBRk-kFa2_Ql3S8Ht0,61
2
+ pyrelukko/decorators.py,sha256=O570z9yJ8wIWtX7B7OMbOy1X8WLOLWpe1Kp-quYHhmE,2611
3
+ pyrelukko/pyrelukko.py,sha256=gdUGIZ4zMunLgaAHFBlxOqpvoSyzOJCDZQoFHwywfXY,13718
4
+ pyrelukko/testcontainers.py,sha256=hWcMn3fWcxp9oD78SfWllDDnkLhDchO4B_WwpWS-vWc,3471
5
+ pyrelukko/version.py,sha256=t8WZzhgAY9BatyKcAF1YBxq4xBN63Yn5B8qpZtlLtJQ,44
6
+ pyrelukko-0.8.0.dist-info/LICENSE,sha256=aEI4dThWmRUiEPch0-KaZQmHZgTyuz88Edmp25H6tAw,1089
7
+ pyrelukko-0.8.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
8
+ pyrelukko-0.8.0.dist-info/METADATA,sha256=Eopk6nougkKLCk47_pTfFaLMNd72MPIpxw69bsFRV6A,2034
9
+ pyrelukko-0.8.0.dist-info/RECORD,,
@@ -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
-
@@ -1,9 +0,0 @@
1
- pyrelukko/__init__.py,sha256=n-mTJV7AOfr4bljtDxok3E3gXIBRk-kFa2_Ql3S8Ht0,61
2
- pyrelukko/pyrelukko.py,sha256=Pjn2pf4rg1rDgAHzUSFdLnooHttn0ZLh3g_29Fxi0RM,13499
3
- pyrelukko/retry.py,sha256=XeCc0trPhAggdEnu2nwtpFderlHaDQFTXH_O1dLeiGQ,1587
4
- pyrelukko/testcontainers.py,sha256=mSUfnyBFVmt9N9LoI_EwXG4EomY8pQCvHzff2ESio-8,3354
5
- pyrelukko/version.py,sha256=-uxD-uvgHyGDV97RE6sWoC15xz0uG1dBpD0xE_sq6Sg,44
6
- pyrelukko-0.6.1.dist-info/LICENSE,sha256=aEI4dThWmRUiEPch0-KaZQmHZgTyuz88Edmp25H6tAw,1089
7
- pyrelukko-0.6.1.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
8
- pyrelukko-0.6.1.dist-info/METADATA,sha256=k7WLcnWt0dwnAynM98FJSqNM29TtVnHnVvDFrB8iOj8,887
9
- pyrelukko-0.6.1.dist-info/RECORD,,