pyxecm 1.5__py3-none-any.whl → 2.0.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 pyxecm might be problematic. Click here for more details.
- pyxecm/__init__.py +6 -2
- pyxecm/avts.py +1492 -0
- pyxecm/coreshare.py +1075 -960
- pyxecm/customizer/__init__.py +16 -4
- pyxecm/customizer/__main__.py +58 -0
- pyxecm/customizer/api/__init__.py +5 -0
- pyxecm/customizer/api/__main__.py +6 -0
- pyxecm/customizer/api/app.py +914 -0
- pyxecm/customizer/api/auth.py +154 -0
- pyxecm/customizer/api/metrics.py +92 -0
- pyxecm/customizer/api/models.py +13 -0
- pyxecm/customizer/api/payload_list.py +865 -0
- pyxecm/customizer/api/settings.py +103 -0
- pyxecm/customizer/browser_automation.py +332 -139
- pyxecm/customizer/customizer.py +1075 -1057
- pyxecm/customizer/exceptions.py +35 -0
- pyxecm/customizer/guidewire.py +322 -0
- pyxecm/customizer/k8s.py +787 -338
- pyxecm/customizer/log.py +107 -0
- pyxecm/customizer/m365.py +3424 -2270
- pyxecm/customizer/nhc.py +1169 -0
- pyxecm/customizer/openapi.py +258 -0
- pyxecm/customizer/payload.py +18201 -7030
- pyxecm/customizer/pht.py +1047 -210
- pyxecm/customizer/salesforce.py +836 -727
- pyxecm/customizer/sap.py +58 -41
- pyxecm/customizer/servicenow.py +851 -383
- pyxecm/customizer/settings.py +442 -0
- pyxecm/customizer/successfactors.py +408 -346
- pyxecm/customizer/translate.py +83 -48
- pyxecm/helper/__init__.py +5 -2
- pyxecm/helper/assoc.py +98 -38
- pyxecm/helper/data.py +2482 -742
- pyxecm/helper/logadapter.py +27 -0
- pyxecm/helper/web.py +229 -101
- pyxecm/helper/xml.py +528 -172
- pyxecm/maintenance_page/__init__.py +5 -0
- pyxecm/maintenance_page/__main__.py +6 -0
- pyxecm/maintenance_page/app.py +51 -0
- pyxecm/maintenance_page/settings.py +28 -0
- pyxecm/maintenance_page/static/favicon.avif +0 -0
- pyxecm/maintenance_page/templates/maintenance.html +165 -0
- pyxecm/otac.py +234 -140
- pyxecm/otawp.py +2689 -0
- pyxecm/otcs.py +12344 -7547
- pyxecm/otds.py +3166 -2219
- pyxecm/otiv.py +36 -21
- pyxecm/otmm.py +1363 -296
- pyxecm/otpd.py +231 -127
- pyxecm-2.0.0.dist-info/METADATA +145 -0
- pyxecm-2.0.0.dist-info/RECORD +54 -0
- {pyxecm-1.5.dist-info → pyxecm-2.0.0.dist-info}/WHEEL +1 -1
- pyxecm-1.5.dist-info/METADATA +0 -51
- pyxecm-1.5.dist-info/RECORD +0 -30
- {pyxecm-1.5.dist-info → pyxecm-2.0.0.dist-info/licenses}/LICENSE +0 -0
- {pyxecm-1.5.dist-info → pyxecm-2.0.0.dist-info}/top_level.txt +0 -0
pyxecm/customizer/log.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Common logging handler for VictoriaLogs and the LogCountFilter."""
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import logging
|
|
5
|
+
import socket
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
import pandas as pd
|
|
12
|
+
|
|
13
|
+
pandas_installed = True
|
|
14
|
+
except ModuleNotFoundError:
|
|
15
|
+
pandas_installed = False
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class VictoriaLogsHandler(logging.Handler):
|
|
19
|
+
"""Logging handler for VictoriaLogs.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
logging (_type_): _description_
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
host: str,
|
|
29
|
+
port: int = 9428,
|
|
30
|
+
accountid: int = 0,
|
|
31
|
+
projectid: int = 0,
|
|
32
|
+
**kwargs: str | int,
|
|
33
|
+
) -> None:
|
|
34
|
+
"""Initialize the log handler.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
host (_type_): _description_
|
|
38
|
+
port (int, optional): _description_. Defaults to 9428.
|
|
39
|
+
accountid (int, optional): _description_. Defaults to 0.
|
|
40
|
+
projectid (int, optional): _description_. Defaults to 0.
|
|
41
|
+
kwargs (dict[str, Any]): ability to add additional arguments into the request body
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
logging.Handler.__init__(self)
|
|
45
|
+
self.url = f"http://{host}:{port}/insert/jsonline?_stream_fields=host,app&_msg_field=msg&_time_field=time"
|
|
46
|
+
self.accountid = accountid
|
|
47
|
+
self.projectid = projectid
|
|
48
|
+
self.kwargs = kwargs
|
|
49
|
+
|
|
50
|
+
def emit(self, record: logging.LogRecord) -> None:
|
|
51
|
+
"""Send request to VictoriaLogs.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
record (_type_): _description_
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
payload = {
|
|
58
|
+
"host": socket.gethostname(),
|
|
59
|
+
"processid": record.process,
|
|
60
|
+
"logger": record.name,
|
|
61
|
+
"level": record.levelname,
|
|
62
|
+
"thread": record.threadName,
|
|
63
|
+
"threadid": record.thread,
|
|
64
|
+
"time": datetime.now(timezone.utc).isoformat(),
|
|
65
|
+
"msg": f"[{record.levelname}] {record.getMessage()}",
|
|
66
|
+
"module": record.module,
|
|
67
|
+
}
|
|
68
|
+
payload.update(self.kwargs)
|
|
69
|
+
|
|
70
|
+
headers = {
|
|
71
|
+
"Content-type": "application/json",
|
|
72
|
+
"AccountID": str(self.accountid),
|
|
73
|
+
"ProjectID": str(self.projectid),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
with contextlib.suppress(Exception):
|
|
77
|
+
requests.post(self.url, headers=headers, json=payload, timeout=1)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class LogCountFilter(logging.Filter):
|
|
81
|
+
"""LogFilter to be assinged to thread_logger to count the number os messages by level."""
|
|
82
|
+
|
|
83
|
+
def __init__(self, payload_items: pd.DataFrame, index: int) -> None:
|
|
84
|
+
"""LogCountFilter initializer.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
payload_items (pd.DataFrame): _description_
|
|
88
|
+
index (int): _description_
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
super().__init__()
|
|
92
|
+
self.index = index
|
|
93
|
+
self.payload_items = payload_items
|
|
94
|
+
|
|
95
|
+
def filter(self, record: logging.LogRecord) -> bool:
|
|
96
|
+
"""Filter method.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
record (_type_): _description_
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
bool: _description_
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
level_name = (record.levelname).lower()
|
|
106
|
+
self.payload_items.loc[self.index, f"log_{level_name}"] += 1
|
|
107
|
+
return True
|