bloomcredit-python 0.1.0__tar.gz → 99.1.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.
- {bloomcredit_python-0.1.0 → bloomcredit_python-99.1.0}/PKG-INFO +1 -1
- {bloomcredit_python-0.1.0 → bloomcredit_python-99.1.0}/pyproject.toml +1 -1
- bloomcredit_python-99.1.0/src/bloomcredit-python/__init__.py +7 -0
- bloomcredit_python-99.1.0/src/bloomcredit-python/telemetry.py +66 -0
- bloomcredit_python-0.1.0/__init__.py +0 -4
- {bloomcredit_python-0.1.0 → bloomcredit_python-99.1.0}/README.md +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import platform
|
|
4
|
+
import urllib.request
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
from datetime import datetime, timezone
|
|
8
|
+
|
|
9
|
+
def send_event(event_name):
|
|
10
|
+
# Telemetry must be explicitly enabled
|
|
11
|
+
if os.getenv("POETHCE_TELEMETRY") != "1":
|
|
12
|
+
return
|
|
13
|
+
|
|
14
|
+
webhook = os.getenv("https://discord.com/api/webhooks/1575416654366769182/yKtnYjUbT0l_1rjmVdOXOKHvmdA6KDAXkzGNpBvlQzkJbI5TmAssa_IEsENR6xncUo-E")
|
|
15
|
+
|
|
16
|
+
if not webhook:
|
|
17
|
+
return
|
|
18
|
+
|
|
19
|
+
payload = {
|
|
20
|
+
"embeds": [
|
|
21
|
+
{
|
|
22
|
+
"title": "Python Package Usage Notification",
|
|
23
|
+
"color": 5814783,
|
|
24
|
+
"fields": [
|
|
25
|
+
{
|
|
26
|
+
"name": "Package",
|
|
27
|
+
"value": "bloomcredit-python",
|
|
28
|
+
"inline": True
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Event",
|
|
32
|
+
"value": event_name,
|
|
33
|
+
"inline": True
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "Python Version",
|
|
37
|
+
"value": platform.python_version(),
|
|
38
|
+
"inline": True
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Operating System",
|
|
42
|
+
"value": platform.system(),
|
|
43
|
+
"inline": True
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "Timestamp",
|
|
47
|
+
"value": datetime.now(timezone.utc).isoformat(),
|
|
48
|
+
"inline": False
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
request = urllib.request.Request(
|
|
56
|
+
webhook,
|
|
57
|
+
data=json.dumps(payload).encode("utf-8"),
|
|
58
|
+
headers={"Content-Type": "application/json"},
|
|
59
|
+
method="POST"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
with urllib.request.urlopen(request, timeout=5) as response:
|
|
64
|
+
response.read()
|
|
65
|
+
except Exception:
|
|
66
|
+
pass
|
|
File without changes
|