bell-tag 1.0.7__py3-none-any.whl → 1.0.9__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.
- bell_tag/decorators.py +15 -3
- bell_tag/utils.py +15 -12
- {bell_tag-1.0.7.dist-info → bell_tag-1.0.9.dist-info}/METADATA +1 -1
- bell_tag-1.0.9.dist-info/RECORD +10 -0
- bell_tag-1.0.7.dist-info/RECORD +0 -10
- {bell_tag-1.0.7.dist-info → bell_tag-1.0.9.dist-info}/WHEEL +0 -0
- {bell_tag-1.0.7.dist-info → bell_tag-1.0.9.dist-info}/top_level.txt +0 -0
bell_tag/decorators.py
CHANGED
|
@@ -9,11 +9,15 @@ def bell_tag(name: str = None):
|
|
|
9
9
|
"""
|
|
10
10
|
Decorator to track a Flask route.
|
|
11
11
|
If no name is provided, use the function's __name__.
|
|
12
|
+
Supports both:
|
|
13
|
+
@bell_tag
|
|
14
|
+
@bell_tag("custom_name")
|
|
12
15
|
"""
|
|
16
|
+
# This inner function is the real decorator
|
|
13
17
|
def decorator(f):
|
|
14
18
|
route_name = name or f.__name__
|
|
15
19
|
|
|
16
|
-
# Load
|
|
20
|
+
# Load API_KEY from .env
|
|
17
21
|
config = load_env_config()
|
|
18
22
|
api_key = config.get("BELL_KEY")
|
|
19
23
|
if not api_key:
|
|
@@ -34,7 +38,7 @@ def bell_tag(name: str = None):
|
|
|
34
38
|
"https://belltagmanager.com/api/v1/track",
|
|
35
39
|
json={
|
|
36
40
|
"api_key": api_key,
|
|
37
|
-
"route_name": route_name,
|
|
41
|
+
"route_name": route_name,
|
|
38
42
|
"path": path,
|
|
39
43
|
"method": method,
|
|
40
44
|
"ip": ip_address,
|
|
@@ -46,5 +50,13 @@ def bell_tag(name: str = None):
|
|
|
46
50
|
pass # fail silently
|
|
47
51
|
|
|
48
52
|
return f(*args, **kwargs)
|
|
53
|
+
|
|
49
54
|
return wrapper
|
|
50
|
-
|
|
55
|
+
|
|
56
|
+
# Handle the case when decorator is used without parentheses: @bell_tag
|
|
57
|
+
if callable(name):
|
|
58
|
+
func = name # name is actually the function
|
|
59
|
+
name = None
|
|
60
|
+
return decorator(func)
|
|
61
|
+
|
|
62
|
+
return decorator
|
bell_tag/utils.py
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
from dotenv import load_dotenv
|
|
3
|
-
import requests
|
|
4
|
-
from .exceptions import VerificationFailed
|
|
1
|
+
# bell_tag/utils.py
|
|
5
2
|
|
|
6
3
|
_verified = False # internal flag for verification
|
|
7
4
|
|
|
8
5
|
def load_env_config():
|
|
6
|
+
from dotenv import load_dotenv
|
|
7
|
+
import os
|
|
9
8
|
"""Load BELL_KEY from .env"""
|
|
10
9
|
load_dotenv() # loads .env from current working directory
|
|
11
10
|
return {"BELL_KEY": os.getenv("BELL_KEY")}
|
|
12
|
-
|
|
13
11
|
def verify_server_once(api_key):
|
|
14
|
-
"""Verify server with API once per process"""
|
|
12
|
+
"""Verify server with API once per process, fail silently if server is down"""
|
|
15
13
|
global _verified
|
|
16
14
|
if _verified:
|
|
17
15
|
return True
|
|
18
16
|
|
|
19
17
|
try:
|
|
18
|
+
import requests
|
|
20
19
|
resp = requests.post(
|
|
21
20
|
"https://belltagmanager.com/api/v1/verify",
|
|
22
21
|
json={"api_key": api_key},
|
|
23
22
|
timeout=5
|
|
24
23
|
)
|
|
25
|
-
if resp.status_code
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if resp.status_code == 200:
|
|
25
|
+
_verified = True
|
|
26
|
+
return True
|
|
27
|
+
else:
|
|
28
|
+
# server responded but failed verification — log silently
|
|
29
|
+
print("Bell Tag: Verification failed, continuing anyway.")
|
|
30
|
+
return False
|
|
30
31
|
except Exception as e:
|
|
31
|
-
|
|
32
|
+
# server unreachable — fail silently
|
|
33
|
+
print(f"Bell Tag: Verification could not be completed ({e}), continuing anyway.")
|
|
34
|
+
return False
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
bell_tag/__init__.py,sha256=9gUiTu_ERtU4dzpFDL07Tr7w66vhSL_QPAim2FjXfRE,232
|
|
2
|
+
bell_tag/decorators.py,sha256=DlrGRqHqLE1h7wYQ70jheACNxxGlyn5QWfv62oVtOpk,1916
|
|
3
|
+
bell_tag/exceptions.py,sha256=Z3iiOE_PXyM06cVrS531G_f3EH4DnC5QB5lcuiM-xng,94
|
|
4
|
+
bell_tag/middleware.py,sha256=oh7MvtZ8RxPoZ330jIVoELPnqvOGNzyD4CeqA6LRqMU,1099
|
|
5
|
+
bell_tag/py.typed,sha256=LeuNCoxZozlVi222NDN-i_wW5_jAlti_H1mOypLzovw,50
|
|
6
|
+
bell_tag/utils.py,sha256=Fh_dc9LjZVhyS50lyYO4T9RGNK539UhgmVwpFywHZME,1112
|
|
7
|
+
bell_tag-1.0.9.dist-info/METADATA,sha256=G7aTm52rbgEsHbjRAWejlEg8Bv_gaDCWSgfJj7kzkYw,667
|
|
8
|
+
bell_tag-1.0.9.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
9
|
+
bell_tag-1.0.9.dist-info/top_level.txt,sha256=zNG3fCyKOmwKuKQz5PFEbzWq9T2tH4C1Tx3CvevSIRg,9
|
|
10
|
+
bell_tag-1.0.9.dist-info/RECORD,,
|
bell_tag-1.0.7.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
bell_tag/__init__.py,sha256=9gUiTu_ERtU4dzpFDL07Tr7w66vhSL_QPAim2FjXfRE,232
|
|
2
|
-
bell_tag/decorators.py,sha256=bOYRofMWog9u4YKLfJaj__TAmfrKThNJSPygLdiSrxw,1695
|
|
3
|
-
bell_tag/exceptions.py,sha256=Z3iiOE_PXyM06cVrS531G_f3EH4DnC5QB5lcuiM-xng,94
|
|
4
|
-
bell_tag/middleware.py,sha256=oh7MvtZ8RxPoZ330jIVoELPnqvOGNzyD4CeqA6LRqMU,1099
|
|
5
|
-
bell_tag/py.typed,sha256=LeuNCoxZozlVi222NDN-i_wW5_jAlti_H1mOypLzovw,50
|
|
6
|
-
bell_tag/utils.py,sha256=vfXioF-VIu3Y1c_WkX12e0iYQsg_p4XuWlhg2TSmlII,869
|
|
7
|
-
bell_tag-1.0.7.dist-info/METADATA,sha256=1ZQrWtXIXdyluT0AvBwz7_ZsmiYU-52ve9rtOZuer7s,667
|
|
8
|
-
bell_tag-1.0.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
9
|
-
bell_tag-1.0.7.dist-info/top_level.txt,sha256=zNG3fCyKOmwKuKQz5PFEbzWq9T2tH4C1Tx3CvevSIRg,9
|
|
10
|
-
bell_tag-1.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|