aa-ledger 0.9.9.1__py3-none-any.whl → 0.9.9.2__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.
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.2.dist-info}/METADATA +1 -1
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.2.dist-info}/RECORD +23 -23
- ledger/__init__.py +1 -1
- ledger/decorators.py +15 -80
- ledger/locale/cs_CZ/LC_MESSAGES/django.po +332 -302
- ledger/locale/de/LC_MESSAGES/django.mo +0 -0
- ledger/locale/de/LC_MESSAGES/django.po +397 -360
- ledger/locale/django.pot +331 -301
- ledger/locale/es/LC_MESSAGES/django.po +332 -302
- ledger/locale/fr_FR/LC_MESSAGES/django.po +332 -302
- ledger/locale/it_IT/LC_MESSAGES/django.po +332 -302
- ledger/locale/ja/LC_MESSAGES/django.po +332 -302
- ledger/locale/ko_KR/LC_MESSAGES/django.po +332 -302
- ledger/locale/nl_NL/LC_MESSAGES/django.po +332 -302
- ledger/locale/pl_PL/LC_MESSAGES/django.po +332 -302
- ledger/locale/ru/LC_MESSAGES/django.po +332 -302
- ledger/locale/sk/LC_MESSAGES/django.po +332 -302
- ledger/locale/uk/LC_MESSAGES/django.po +332 -302
- ledger/locale/zh_Hans/LC_MESSAGES/django.po +332 -302
- ledger/tasks.py +7 -0
- ledger/tests/test_decarators.py +33 -94
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.2.dist-info}/WHEEL +0 -0
- {aa_ledger-0.9.9.1.dist-info → aa_ledger-0.9.9.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aa-ledger
|
|
3
|
-
Version: 0.9.9.
|
|
3
|
+
Version: 0.9.9.2
|
|
4
4
|
Summary: Character and Corporation statistics, including detailed information on ESS, Ratting, Trading, Mining, and other activities.
|
|
5
5
|
Project-URL: Changelog, https://github.com/Geuthur/aa-ledger/blob/master/CHANGELOG.md
|
|
6
6
|
Project-URL: Documentation, https://github.com/Geuthur/aa-ledger/blob/master/README.md
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
ledger/__init__.py,sha256=
|
|
1
|
+
ledger/__init__.py,sha256=SmD-iaiVbHb4TvNt2hPH3sGudQ4HKZ26Eo9HUOqkBJA,207
|
|
2
2
|
ledger/admin.py,sha256=wp6nLps1tTGHznyHBLMoRnwjnYZW1RfXOnw4TfwRWhM,9408
|
|
3
3
|
ledger/app_settings.py,sha256=r9CcNaBDo6kFOlYXXlRx3aTq1xErDz_JwJy7vM-mJNk,1363
|
|
4
4
|
ledger/apps.py,sha256=XQxXGP-1xvmQqTRJYrVIuUgCwUPOdEW3iSZaxTOYvT0,442
|
|
5
5
|
ledger/auth_hooks.py,sha256=yaOoOqfHqKoqcDm4eA-_wejIxvNIEcGa_glwHK-Sul0,1454
|
|
6
6
|
ledger/checks.py,sha256=Sq-tfUyc_OElBi9Xj71DuJXBbRU0Zqu1XDSbEtp3bPI,1474
|
|
7
7
|
ledger/constants.py,sha256=WBS7yuhBcEW9nWdj4Ieit-PolUQP_Uz393QBZFNUmvs,3662
|
|
8
|
-
ledger/decorators.py,sha256=
|
|
8
|
+
ledger/decorators.py,sha256=HCC79YwIqwFQd0Kw4dLtVcUHOqBW7V2sypb6h6TNoaQ,2177
|
|
9
9
|
ledger/errors.py,sha256=8VMvWzlpjilvC6h9WSUhBtz19oN_shRoradq5sp-G-8,495
|
|
10
10
|
ledger/forms.py,sha256=DUVd2s6D9rdyhYxoM0VXlA5PODywmpKUw5FfTBJft-w,269
|
|
11
11
|
ledger/hooks.py,sha256=ofua_eHg_ikCxaql8O7c3itSx2FyUhpeXJNH39asncA,15
|
|
12
12
|
ledger/providers.py,sha256=Ggmna3W-izQdB0AwcTkJ6tijoFFHJt-VFRwT-n1Pvhw,303
|
|
13
|
-
ledger/tasks.py,sha256=
|
|
13
|
+
ledger/tasks.py,sha256=7w1vFrD9Md2Um7_NGOiwZMXsgydoNLKaJxxV07_PtZ8,14894
|
|
14
14
|
ledger/urls.py,sha256=Zs6kkBmEdsVC7ZA2rOYjTtnfT6etQu_d4pZmPyUQg08,8419
|
|
15
15
|
ledger/api/__init__.py,sha256=GtiQ3H7rMKu_i63rp5GpHieHzVH-fWtFRHnZ6s9wS_k,655
|
|
16
16
|
ledger/api/helpers.py,sha256=SyoARfjY3hxlhbnXbVKmpbMsFXvH6k1lF2QiBmynaP0,4199
|
|
@@ -36,33 +36,33 @@ ledger/helpers/discord.py,sha256=D59TBtPHAldCCWi2j_z1CzuW6140aP2kHYvgzgYwuP0,442
|
|
|
36
36
|
ledger/helpers/etag.py,sha256=7x4balvYOypaC0jKlBbjRuETn6ol3gMBTL_363b7iVA,7421
|
|
37
37
|
ledger/helpers/ref_type.py,sha256=BnRypVpSZmBaJbULWh9URJDlHrDnqRDoynd_nDSmdCo,16413
|
|
38
38
|
ledger/locale/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
-
ledger/locale/django.pot,sha256=
|
|
39
|
+
ledger/locale/django.pot,sha256=wpXzSlHjvad6TEyL40wkGDjcTc71NTH3GJGnCu-XSGM,26836
|
|
40
40
|
ledger/locale/cs_CZ/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
41
|
-
ledger/locale/cs_CZ/LC_MESSAGES/django.po,sha256=
|
|
42
|
-
ledger/locale/de/LC_MESSAGES/django.mo,sha256=
|
|
43
|
-
ledger/locale/de/LC_MESSAGES/django.po,sha256=
|
|
41
|
+
ledger/locale/cs_CZ/LC_MESSAGES/django.po,sha256=3se9bYkf-yYgS1gFsR7haSmosGUnn2cyT0m3jIjZZxo,26829
|
|
42
|
+
ledger/locale/de/LC_MESSAGES/django.mo,sha256=YEf3YV6w4zrZtYahJzQdLLQ7JfMjcrBhbVUqaqJ2rZY,12105
|
|
43
|
+
ledger/locale/de/LC_MESSAGES/django.po,sha256=IVupk3brTAxUXKmfBa-xDY3dTe0ExFM5AnfBDXNBOhs,31494
|
|
44
44
|
ledger/locale/es/LC_MESSAGES/django.mo,sha256=N1pb17IfLd0ASiKO8d68-B4ygSpDkhKOCs8YTzMXQo0,380
|
|
45
|
-
ledger/locale/es/LC_MESSAGES/django.po,sha256=
|
|
45
|
+
ledger/locale/es/LC_MESSAGES/django.po,sha256=dmImWCFb8Pn6dB_HnWeqHGdzWBlrHBAKg8Rcf0i7byQ,26876
|
|
46
46
|
ledger/locale/fr_FR/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
47
|
-
ledger/locale/fr_FR/LC_MESSAGES/django.po,sha256=
|
|
47
|
+
ledger/locale/fr_FR/LC_MESSAGES/django.po,sha256=3se9bYkf-yYgS1gFsR7haSmosGUnn2cyT0m3jIjZZxo,26829
|
|
48
48
|
ledger/locale/it_IT/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
49
|
-
ledger/locale/it_IT/LC_MESSAGES/django.po,sha256=
|
|
49
|
+
ledger/locale/it_IT/LC_MESSAGES/django.po,sha256=3se9bYkf-yYgS1gFsR7haSmosGUnn2cyT0m3jIjZZxo,26829
|
|
50
50
|
ledger/locale/ja/LC_MESSAGES/django.mo,sha256=XMj5I8Aah7EGpU-KfFOr25hoOxxLT5dfmjror1-uc8g,373
|
|
51
|
-
ledger/locale/ja/LC_MESSAGES/django.po,sha256=
|
|
51
|
+
ledger/locale/ja/LC_MESSAGES/django.po,sha256=SoC9qYHZnHk7huEaheEvQ3O2k-G7DdPFM23N9tJAOlM,26869
|
|
52
52
|
ledger/locale/ko_KR/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
53
|
-
ledger/locale/ko_KR/LC_MESSAGES/django.po,sha256=
|
|
53
|
+
ledger/locale/ko_KR/LC_MESSAGES/django.po,sha256=3se9bYkf-yYgS1gFsR7haSmosGUnn2cyT0m3jIjZZxo,26829
|
|
54
54
|
ledger/locale/nl_NL/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
55
|
-
ledger/locale/nl_NL/LC_MESSAGES/django.po,sha256=
|
|
55
|
+
ledger/locale/nl_NL/LC_MESSAGES/django.po,sha256=3se9bYkf-yYgS1gFsR7haSmosGUnn2cyT0m3jIjZZxo,26829
|
|
56
56
|
ledger/locale/pl_PL/LC_MESSAGES/django.mo,sha256=UXCQbz2AxBvh-IQ7bGgjoBnijo8h9DfE9107A-2Mgkk,337
|
|
57
|
-
ledger/locale/pl_PL/LC_MESSAGES/django.po,sha256=
|
|
57
|
+
ledger/locale/pl_PL/LC_MESSAGES/django.po,sha256=3se9bYkf-yYgS1gFsR7haSmosGUnn2cyT0m3jIjZZxo,26829
|
|
58
58
|
ledger/locale/ru/LC_MESSAGES/django.mo,sha256=hs3OUHIMDSoIE9PjzkBNf97lqqo84dp6fQ_nZOMq2us,518
|
|
59
|
-
ledger/locale/ru/LC_MESSAGES/django.po,sha256=
|
|
59
|
+
ledger/locale/ru/LC_MESSAGES/django.po,sha256=pQaDGnnaD6f1dMvfu18_qTNBQwCenU6Luhl5bJPhjW8,27020
|
|
60
60
|
ledger/locale/sk/LC_MESSAGES/django.mo,sha256=TRRRHrYeiLCvDNFGFTmkHmuh25TerdFy4jNVwPsWkzA,455
|
|
61
|
-
ledger/locale/sk/LC_MESSAGES/django.po,sha256=
|
|
61
|
+
ledger/locale/sk/LC_MESSAGES/django.po,sha256=JSQ7NYvHqJq46MrN--zN0N-_45-jcKV8zG_GQorELZw,26954
|
|
62
62
|
ledger/locale/uk/LC_MESSAGES/django.mo,sha256=db3vApZ7nY3-IsGkDVAV5ckHkmwj9XGdsaB-jj90uLE,602
|
|
63
|
-
ledger/locale/uk/LC_MESSAGES/django.po,sha256=
|
|
63
|
+
ledger/locale/uk/LC_MESSAGES/django.po,sha256=NhBuZqoUuv7MxWmQogVl10EslaIyXYM6ntMCqNjwoPA,27107
|
|
64
64
|
ledger/locale/zh_Hans/LC_MESSAGES/django.mo,sha256=XMj5I8Aah7EGpU-KfFOr25hoOxxLT5dfmjror1-uc8g,373
|
|
65
|
-
ledger/locale/zh_Hans/LC_MESSAGES/django.po,sha256=
|
|
65
|
+
ledger/locale/zh_Hans/LC_MESSAGES/django.po,sha256=SoC9qYHZnHk7huEaheEvQ3O2k-G7DdPFM23N9tJAOlM,26869
|
|
66
66
|
ledger/managers/character_audit_manager.py,sha256=UoI1aeyLLkEDo9KBgtgYYmJXtPXmxld9ARDQlcNk6Bg,6797
|
|
67
67
|
ledger/managers/character_journal_manager.py,sha256=2uEkVZ_Sp-iP68rL8s7Ia0uiT-UXHNQslxF3RfqWPdY,17482
|
|
68
68
|
ledger/managers/character_mining_manager.py,sha256=zh5wFs4RnhOTfua5AmgVeGuZFvl4pU7VuEAcaUilUGI,8182
|
|
@@ -161,7 +161,7 @@ ledger/templatetags/ledger.py,sha256=TRpJjT0YnLDzHkwf0aMKYKl9EwxJK-1QH32OKyyhtMQ
|
|
|
161
161
|
ledger/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
162
162
|
ledger/tests/test_admin.py,sha256=URLocRx_WiF1_DQwcba4EB6Qu18sfl2-gpZS1HZnvAU,8843
|
|
163
163
|
ledger/tests/test_auth_hook.py,sha256=QTheohS7syk-Hs7FZmCK4emIZhH68TfuOpLrJ1mV0LM,2007
|
|
164
|
-
ledger/tests/test_decarators.py,sha256=
|
|
164
|
+
ledger/tests/test_decarators.py,sha256=PMYA4K154z3q1r-ebuDEUqaPPsh0gf1rWIj1wJdEX_k,3095
|
|
165
165
|
ledger/tests/test_discord_installed.py,sha256=Tf-y1-RduOcxpgLNu4dDOBQKmRwJWkwx3I6JVh51Pyo,1001
|
|
166
166
|
ledger/tests/test_tasks.py,sha256=YDcklSh_QrlVaoR9CtjLM6j-241uGFXa37BizSoktd4,8576
|
|
167
167
|
ledger/tests/test_templatetags.py,sha256=KfKF1DGU8e9QofeQwai69xIvRYiaI7cEdiNrnvflUz0,1881
|
|
@@ -224,7 +224,7 @@ ledger/views/character/character_ledger.py,sha256=A8n3ela-Yv4PicXwR8c_YUpIn81WNw
|
|
|
224
224
|
ledger/views/character/planetary.py,sha256=zfcyxfs8x7B6DTZ4tViI8aO8fty94JhphTb9bd73Xr8,4459
|
|
225
225
|
ledger/views/corporation/add_corp.py,sha256=1SLMITOZ5GdBuk4VSkduaxiS5mNgP9aObsJ1SwYMUOQ,1837
|
|
226
226
|
ledger/views/corporation/corporation_ledger.py,sha256=CcRg1B1-GilF4M-6b_xlY2Qmufutoy5HRLOZgmlePzU,7357
|
|
227
|
-
aa_ledger-0.9.9.
|
|
228
|
-
aa_ledger-0.9.9.
|
|
229
|
-
aa_ledger-0.9.9.
|
|
230
|
-
aa_ledger-0.9.9.
|
|
227
|
+
aa_ledger-0.9.9.2.dist-info/METADATA,sha256=RwnVzAHgK3wYDD2zmXBoquBu2V9BhTUiVBDMKYTTtlI,50241
|
|
228
|
+
aa_ledger-0.9.9.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
229
|
+
aa_ledger-0.9.9.2.dist-info/licenses/LICENSE,sha256=2oHuqnDfrjCrYAM1--Wyhv8jO3VBpnrq8zkABGzB8N8,35109
|
|
230
|
+
aa_ledger-0.9.9.2.dist-info/RECORD,,
|
ledger/__init__.py
CHANGED
ledger/decorators.py
CHANGED
|
@@ -4,14 +4,15 @@ Decorators
|
|
|
4
4
|
|
|
5
5
|
# Standard Library
|
|
6
6
|
import time
|
|
7
|
-
import uuid
|
|
8
7
|
from functools import wraps
|
|
9
8
|
|
|
9
|
+
# Django
|
|
10
|
+
from django.core.cache import cache
|
|
11
|
+
|
|
10
12
|
# Alliance Auth
|
|
11
13
|
from allianceauth.services.hooks import get_extension_logger
|
|
12
14
|
|
|
13
15
|
# Alliance Auth (External Libs)
|
|
14
|
-
from app_utils.allianceauth import get_redis_client
|
|
15
16
|
from app_utils.esi import fetch_esi_status
|
|
16
17
|
from app_utils.logging import LoggerAddTag
|
|
17
18
|
|
|
@@ -21,57 +22,16 @@ from ledger.app_settings import IS_TESTING
|
|
|
21
22
|
|
|
22
23
|
logger = LoggerAddTag(get_extension_logger(__name__), __title__)
|
|
23
24
|
|
|
25
|
+
# Use shared ESI status route rate limit from app_settings
|
|
26
|
+
ESI_STATUS_ROUTE_RATE_LIMIT = 5
|
|
27
|
+
ESI_STATUS_KEY = "esi-is-available-status"
|
|
24
28
|
|
|
25
|
-
def _esi_cache_available(redis_client, cache_key):
|
|
26
|
-
"""Return True if ESI availability cache is present. Handles Redis errors."""
|
|
27
|
-
try:
|
|
28
|
-
if redis_client.get(cache_key):
|
|
29
|
-
return True
|
|
30
|
-
except Exception: # pylint: disable=broad-except
|
|
31
|
-
# If Redis is flaky, fall through to live check
|
|
32
|
-
logger.debug("Error reading ESI cache, will attempt live check.")
|
|
33
|
-
return False
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def _acquire_lock(redis_client, lock_key, token, lock_ttl):
|
|
37
|
-
"""Try to acquire a short-lived lock in Redis. Returns True on success."""
|
|
38
|
-
try:
|
|
39
|
-
return redis_client.set(lock_key, token, nx=True, ex=lock_ttl)
|
|
40
|
-
except Exception: # pylint: disable=broad-except
|
|
41
|
-
logger.exception("Failed to acquire ESI status lock, will attempt live check.")
|
|
42
|
-
return False
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"""
|
|
50
|
-
waited = 0.0
|
|
51
|
-
poll_interval = 0.1
|
|
52
|
-
max_wait = float(lock_ttl) - 0.1
|
|
53
|
-
while waited < max_wait:
|
|
54
|
-
try:
|
|
55
|
-
# If cache was set while waiting, proceed.
|
|
56
|
-
if _esi_cache_available(redis_client, cache_key):
|
|
57
|
-
logger.debug("ESI status became available in cache while waiting.")
|
|
58
|
-
return False, True
|
|
59
|
-
|
|
60
|
-
# If the lock expired or was released, try to acquire it.
|
|
61
|
-
if not redis_client.get(lock_key):
|
|
62
|
-
try:
|
|
63
|
-
acquired = redis_client.set(lock_key, token, nx=True, ex=lock_ttl)
|
|
64
|
-
if acquired:
|
|
65
|
-
# We acquired the lock and will perform the check
|
|
66
|
-
return True, False
|
|
67
|
-
except Exception: # pylint: disable=broad-except
|
|
68
|
-
logger.debug("Failed to re-acquire lock while waiting for holder.")
|
|
69
|
-
except Exception: # pylint: disable=broad-except
|
|
70
|
-
logger.debug("Error polling ESI cache while waiting for lock holder.")
|
|
71
|
-
time.sleep(poll_interval)
|
|
72
|
-
waited += poll_interval
|
|
73
|
-
|
|
74
|
-
return False, False
|
|
30
|
+
def get_esi_available_cache() -> bool:
|
|
31
|
+
"""Return True if ESI availability cache is present."""
|
|
32
|
+
if cache.get(ESI_STATUS_KEY):
|
|
33
|
+
return True
|
|
34
|
+
return False
|
|
75
35
|
|
|
76
36
|
|
|
77
37
|
def when_esi_is_available(func):
|
|
@@ -83,42 +43,17 @@ def when_esi_is_available(func):
|
|
|
83
43
|
|
|
84
44
|
@wraps(func)
|
|
85
45
|
def outer(*args, **kwargs):
|
|
86
|
-
# During tests we skip ESI checks
|
|
87
|
-
if IS_TESTING:
|
|
88
|
-
return func(*args, **kwargs)
|
|
89
46
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# Prevent hammering ESI status endpoint
|
|
94
|
-
if _esi_cache_available(redis_client, cache_key):
|
|
95
|
-
logger.debug("ESI status cached as available.")
|
|
47
|
+
# During tests we skip ESI checks
|
|
48
|
+
if IS_TESTING or get_esi_available_cache():
|
|
49
|
+
logger.debug("Skipping ESI check (testing mode or cache present).")
|
|
96
50
|
return func(*args, **kwargs)
|
|
97
51
|
|
|
98
|
-
# Try to acquire a short-lived lock so only one process checks ESI
|
|
99
|
-
token = str(uuid.uuid4())
|
|
100
|
-
lock_key = "esi_status_lock"
|
|
101
|
-
lock_ttl = 5
|
|
102
|
-
acquired = _acquire_lock(redis_client, lock_key, token, lock_ttl)
|
|
103
|
-
|
|
104
|
-
# If we didn't get the lock, wait a short time for cache or lock
|
|
105
|
-
if not acquired:
|
|
106
|
-
acquired, cache_available = _wait_for_lock_or_cache(
|
|
107
|
-
redis_client, cache_key, lock_key, token, lock_ttl
|
|
108
|
-
)
|
|
109
|
-
if cache_available:
|
|
110
|
-
return func(*args, **kwargs)
|
|
111
|
-
|
|
112
52
|
# Check ESI status
|
|
113
53
|
if fetch_esi_status().is_ok:
|
|
114
54
|
logger.debug("ESI is available, proceeding.")
|
|
115
|
-
|
|
116
|
-
try:
|
|
117
|
-
redis_client.setex(cache_key, 5, "1")
|
|
118
|
-
except Exception: # pylint: disable=broad-except
|
|
119
|
-
logger.debug("Failed to set ESI availability cache.")
|
|
55
|
+
cache.set(ESI_STATUS_KEY, "1", timeout=ESI_STATUS_ROUTE_RATE_LIMIT)
|
|
120
56
|
return func(*args, **kwargs)
|
|
121
|
-
|
|
122
57
|
return None # function will not run
|
|
123
58
|
|
|
124
59
|
return outer
|