ka-uts-com 2.0.0.250407__py3-none-any.whl → 2.1.1.250415__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.
- ka_uts_com/__version__.py +1 -1
- ka_uts_com/{base/app_.py → app.py} +8 -8
- ka_uts_com/{base/cfg_.py → cfg.py} +8 -7
- ka_uts_com/com.py +47 -47
- build/lib/ka_uts_com/base/exit_.py → ka_uts_com/exit.py +1 -1
- ka_uts_com/timer.py +1 -1
- ka_uts_com-2.1.1.250415.dist-info/METADATA +910 -0
- ka_uts_com-2.1.1.250415.dist-info/RECORD +14 -0
- {ka_uts_com-2.0.0.250407.dist-info → ka_uts_com-2.1.1.250415.dist-info}/top_level.txt +0 -1
- build/lib/ka_uts_com/__init__.py +0 -0
- build/lib/ka_uts_com/__version__.py +0 -10
- build/lib/ka_uts_com/base/app_.py +0 -50
- build/lib/ka_uts_com/base/cfg_.py +0 -35
- build/lib/ka_uts_com/base/log_.py +0 -131
- build/lib/ka_uts_com/com.py +0 -121
- build/lib/ka_uts_com/data/__init__.py +0 -0
- build/lib/ka_uts_com/data/log.std.yml +0 -107
- build/lib/ka_uts_com/data/log.usr.yml +0 -106
- build/lib/ka_uts_com/decorators/dec.py +0 -13
- build/lib/ka_uts_com/fnc.py +0 -42
- build/lib/ka_uts_com/ioc/jinja2_.py +0 -42
- build/lib/ka_uts_com/ioc/yaml_.py +0 -30
- build/lib/ka_uts_com/log.py +0 -86
- build/lib/ka_uts_com/py.typed +0 -0
- build/lib/ka_uts_com/timer.py +0 -69
- build/lib/ka_uts_com/utils/aoeqstmt.py +0 -37
- build/lib/ka_uts_com/utils/date.py +0 -15
- build/lib/ka_uts_com/utils/doeq.py +0 -99
- build/lib/ka_uts_com/utils/pacmod.py +0 -123
- build/lib/ka_uts_com/utils/str.py +0 -265
- ka_uts_com/base/exit_.py +0 -37
- ka_uts_com/base/log_.py +0 -131
- ka_uts_com/data/__init__.py +0 -0
- ka_uts_com/data/log.std.yml +0 -107
- ka_uts_com/data/log.usr.yml +0 -106
- ka_uts_com/fnc.py +0 -42
- ka_uts_com/ioc/jinja2_.py +0 -42
- ka_uts_com/ioc/yaml_.py +0 -30
- ka_uts_com/log.py +0 -86
- ka_uts_com/utils/aoeqstmt.py +0 -37
- ka_uts_com/utils/date.py +0 -15
- ka_uts_com/utils/doeq.py +0 -99
- ka_uts_com/utils/pacmod.py +0 -123
- ka_uts_com/utils/str.py +0 -265
- ka_uts_com-2.0.0.250407.dist-info/METADATA +0 -1611
- ka_uts_com-2.0.0.250407.dist-info/RECORD +0 -49
- {ka_uts_com-2.0.0.250407.dist-info → ka_uts_com-2.1.1.250415.dist-info}/WHEEL +0 -0
- {ka_uts_com-2.0.0.250407.dist-info → ka_uts_com-2.1.1.250415.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,265 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
from typing import Any
|
3
|
-
import traceback
|
4
|
-
|
5
|
-
from datetime import datetime
|
6
|
-
import re
|
7
|
-
import orjson
|
8
|
-
import simplejson
|
9
|
-
|
10
|
-
TyArr = list[Any]
|
11
|
-
TyDic = dict[Any, Any]
|
12
|
-
TyAoA = list[TyArr]
|
13
|
-
|
14
|
-
TnInt = None | int
|
15
|
-
TnFloat = None | float
|
16
|
-
TnStr = None | str
|
17
|
-
TnAoA = None | TyAoA
|
18
|
-
TnArr = None | TyArr
|
19
|
-
TnDic = None | TyDic
|
20
|
-
TnDatetime = None | datetime
|
21
|
-
|
22
|
-
|
23
|
-
class Str:
|
24
|
-
""" Manage String Class
|
25
|
-
"""
|
26
|
-
@staticmethod
|
27
|
-
def sh_date(string: str, fmt: TnStr = None) -> TnDatetime:
|
28
|
-
""" show string as date using the format string
|
29
|
-
"""
|
30
|
-
try:
|
31
|
-
if fmt is None:
|
32
|
-
fmt = "%m/%d/%Y"
|
33
|
-
_date: TnDatetime = datetime.strptime(string, fmt)
|
34
|
-
return _date
|
35
|
-
except Exception:
|
36
|
-
print(traceback.format_exc())
|
37
|
-
return None
|
38
|
-
|
39
|
-
@staticmethod
|
40
|
-
def lchop(string: str, prefix: str) -> str:
|
41
|
-
""" return substring of string which starts at the
|
42
|
-
end of the contained prefix
|
43
|
-
"""
|
44
|
-
if string.startswith(prefix):
|
45
|
-
return string[len(prefix):]
|
46
|
-
return string
|
47
|
-
|
48
|
-
@staticmethod
|
49
|
-
def rchop(string: str, suffix: str) -> str:
|
50
|
-
""" return substring of string which ends at the
|
51
|
-
beginning of the contained suffix
|
52
|
-
"""
|
53
|
-
if suffix and string.endswith(suffix):
|
54
|
-
return string[:-len(suffix)]
|
55
|
-
return string
|
56
|
-
|
57
|
-
@staticmethod
|
58
|
-
def strip_multiple_chars(string: str, chars: str) -> str:
|
59
|
-
""" replace multiple characters in string
|
60
|
-
"""
|
61
|
-
return string.translate(str.maketrans("", "", chars))
|
62
|
-
|
63
|
-
@staticmethod
|
64
|
-
def is_odd(string: str) -> bool:
|
65
|
-
""" check if string is odd number
|
66
|
-
"""
|
67
|
-
if string.isnumeric():
|
68
|
-
if int(string) % 2 == 0:
|
69
|
-
return False
|
70
|
-
return True
|
71
|
-
return False
|
72
|
-
|
73
|
-
@staticmethod
|
74
|
-
def is_integer(string: str) -> bool:
|
75
|
-
""" check if string is integer
|
76
|
-
"""
|
77
|
-
if string[0] in ('-', '+'):
|
78
|
-
return string[1:].isdigit()
|
79
|
-
return string.isdigit()
|
80
|
-
|
81
|
-
@staticmethod
|
82
|
-
def is_boolean(string: str) -> bool:
|
83
|
-
""" check if string is boolean
|
84
|
-
"""
|
85
|
-
if string.strip().lower() in ['true', 'false']:
|
86
|
-
return True
|
87
|
-
return False
|
88
|
-
|
89
|
-
@staticmethod
|
90
|
-
def is_undefined(string: TnStr) -> bool:
|
91
|
-
""" check if string is undefined (None or empty)
|
92
|
-
"""
|
93
|
-
if string is None or string == '':
|
94
|
-
return True
|
95
|
-
return False
|
96
|
-
|
97
|
-
@staticmethod
|
98
|
-
def nvl(string: TnStr) -> TnStr:
|
99
|
-
""" nvl function similar to SQL NVL function
|
100
|
-
"""
|
101
|
-
if string is None:
|
102
|
-
return ''
|
103
|
-
return string
|
104
|
-
|
105
|
-
@staticmethod
|
106
|
-
def strip_n(string: str) -> str:
|
107
|
-
""" Replace new line characters by Blanks and strip Blanks
|
108
|
-
"""
|
109
|
-
return string.replace('\n', ' ').strip()
|
110
|
-
|
111
|
-
@staticmethod
|
112
|
-
def remove(string: str, a_to_remove: TyArr) -> str:
|
113
|
-
""" remove all character of a list
|
114
|
-
"""
|
115
|
-
for to_remove in a_to_remove:
|
116
|
-
string = string.replace(to_remove, '')
|
117
|
-
return string
|
118
|
-
|
119
|
-
@staticmethod
|
120
|
-
def sh_boolean(string: str) -> bool:
|
121
|
-
""" Show string as boolean if string is a boolean
|
122
|
-
"""
|
123
|
-
match string.lower():
|
124
|
-
case 'true':
|
125
|
-
return True
|
126
|
-
case 'false':
|
127
|
-
return False
|
128
|
-
case _:
|
129
|
-
raise ValueError
|
130
|
-
|
131
|
-
@staticmethod
|
132
|
-
def sh_float(string: str) -> TnFloat:
|
133
|
-
""" Returns Float if string is of Type Float
|
134
|
-
otherwise None
|
135
|
-
"""
|
136
|
-
try:
|
137
|
-
return float(string)
|
138
|
-
except Exception:
|
139
|
-
print(traceback.format_exc())
|
140
|
-
return None
|
141
|
-
|
142
|
-
@staticmethod
|
143
|
-
def sh_int(string: str) -> TnInt:
|
144
|
-
""" Returns Int if string is of Type Int
|
145
|
-
otherwise None
|
146
|
-
"""
|
147
|
-
try:
|
148
|
-
return int(string)
|
149
|
-
except ValueError:
|
150
|
-
return None
|
151
|
-
|
152
|
-
@staticmethod
|
153
|
-
def sh_dic(string: str, sw_decimal=False) -> Any:
|
154
|
-
""" Returns Dic if string is of Type Json-String
|
155
|
-
otherwise None
|
156
|
-
"""
|
157
|
-
try:
|
158
|
-
if sw_decimal:
|
159
|
-
return simplejson.loads(string, use_decimal=True)
|
160
|
-
else:
|
161
|
-
return orjson.loads(string)
|
162
|
-
except Exception:
|
163
|
-
print(traceback.format_exc())
|
164
|
-
return None
|
165
|
-
|
166
|
-
@staticmethod
|
167
|
-
def sh_arr(string: str) -> Any:
|
168
|
-
""" Show valid Array string as Array
|
169
|
-
"""
|
170
|
-
try:
|
171
|
-
return orjson.loads(string)
|
172
|
-
except Exception:
|
173
|
-
print(traceback.format_exc())
|
174
|
-
return None
|
175
|
-
|
176
|
-
@staticmethod
|
177
|
-
def sh_aoa(string: str) -> Any:
|
178
|
-
""" Show valid Array string as Array
|
179
|
-
"""
|
180
|
-
try:
|
181
|
-
return orjson.loads(string)
|
182
|
-
except Exception:
|
183
|
-
print(traceback.format_exc())
|
184
|
-
return None
|
185
|
-
|
186
|
-
@staticmethod
|
187
|
-
def sh_first_item(string: str) -> Any:
|
188
|
-
""" Show first substring of string
|
189
|
-
"""
|
190
|
-
return string.split()[0]
|
191
|
-
|
192
|
-
@classmethod
|
193
|
-
def sh_a_int(cls, string: str, sep: str) -> TyArr:
|
194
|
-
""" Show first substring of string
|
195
|
-
"""
|
196
|
-
# arr = string.split(sep)
|
197
|
-
arr = re.split(sep, string)
|
198
|
-
arr_new = []
|
199
|
-
for item in arr:
|
200
|
-
_item = item.strip()
|
201
|
-
if not isinstance(_item, str):
|
202
|
-
continue
|
203
|
-
if not _item.isdigit():
|
204
|
-
continue
|
205
|
-
arr_new.append(cls.sh_int(_item))
|
206
|
-
return arr_new
|
207
|
-
|
208
|
-
@classmethod
|
209
|
-
def sh_a_str(
|
210
|
-
cls, string: str, sep: str, a_exclude: TnArr = None) -> Any:
|
211
|
-
""" Show first substring of string
|
212
|
-
"""
|
213
|
-
# arr = string.split(sep)
|
214
|
-
arr = re.split(sep, string)
|
215
|
-
|
216
|
-
if a_exclude is None:
|
217
|
-
_arr = arr
|
218
|
-
else:
|
219
|
-
_arr = []
|
220
|
-
for item in arr:
|
221
|
-
_item = item.strip()
|
222
|
-
if _item not in a_exclude:
|
223
|
-
_arr.append(_item)
|
224
|
-
|
225
|
-
arr_new = []
|
226
|
-
for item in _arr:
|
227
|
-
if isinstance(item, str):
|
228
|
-
arr_new.append(item.strip())
|
229
|
-
elif isinstance(item, int):
|
230
|
-
arr_new.append(str(item))
|
231
|
-
else:
|
232
|
-
arr_new.append(item)
|
233
|
-
|
234
|
-
return arr_new
|
235
|
-
|
236
|
-
@classmethod
|
237
|
-
def sh_a_obj(
|
238
|
-
cls, string: str, sep: str, a_exclude: TnArr = None) -> Any:
|
239
|
-
""" Show first substring of string
|
240
|
-
"""
|
241
|
-
# arr = string.split(sep)
|
242
|
-
arr = re.split(sep, string)
|
243
|
-
|
244
|
-
if a_exclude is None:
|
245
|
-
_arr = arr
|
246
|
-
else:
|
247
|
-
_arr = []
|
248
|
-
for item in arr:
|
249
|
-
_item = item.strip()
|
250
|
-
if _item not in a_exclude:
|
251
|
-
_arr.append(_item)
|
252
|
-
|
253
|
-
arr_new: TyArr = []
|
254
|
-
for item in _arr:
|
255
|
-
if isinstance(item, str):
|
256
|
-
_item = item.strip()
|
257
|
-
if _item.isdigit():
|
258
|
-
_item = cls.sh_int(_item)
|
259
|
-
arr_new.append(_item)
|
260
|
-
else:
|
261
|
-
arr_new.append(_item)
|
262
|
-
else:
|
263
|
-
arr_new.append(item)
|
264
|
-
|
265
|
-
return arr_new
|
ka_uts_com/base/exit_.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
TyAny = Any
|
5
|
-
TyArr = list[Any]
|
6
|
-
TyBool = bool
|
7
|
-
TyDic = dict[Any, Any]
|
8
|
-
|
9
|
-
TnAny = None | Any
|
10
|
-
TnArr = None | TyArr
|
11
|
-
TnBool = None | bool
|
12
|
-
TnDic = None | TyDic
|
13
|
-
|
14
|
-
|
15
|
-
class Exit_:
|
16
|
-
"""Exit Class
|
17
|
-
"""
|
18
|
-
sw_init: TyBool = False
|
19
|
-
sw_critical: bool = False
|
20
|
-
sw_stop: bool = False
|
21
|
-
sw_interactive: bool = False
|
22
|
-
|
23
|
-
@classmethod
|
24
|
-
def init(cls, **kwargs) -> None:
|
25
|
-
if cls.sw_init:
|
26
|
-
return
|
27
|
-
cls.sw_init = True
|
28
|
-
cls.sw_critical = kwargs.get('sw_critical', False)
|
29
|
-
cls.sw_stop = kwargs.get('sw_stop', False)
|
30
|
-
cls.sw_interactive = kwargs.get('sw_interactive', False)
|
31
|
-
|
32
|
-
@classmethod
|
33
|
-
def sh(cls, **kwargs) -> Any:
|
34
|
-
if cls.sw_init:
|
35
|
-
return cls
|
36
|
-
cls.init(**kwargs)
|
37
|
-
return cls
|
ka_uts_com/base/log_.py
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
from collections.abc import Callable
|
3
|
-
from typing import Any
|
4
|
-
|
5
|
-
import os
|
6
|
-
import logging
|
7
|
-
import logging.config
|
8
|
-
from logging import Logger
|
9
|
-
from datetime import datetime
|
10
|
-
import psutil
|
11
|
-
|
12
|
-
# from ka_uts_com.com import Com
|
13
|
-
from ka_uts_com.ioc.jinja2_ import Jinja2_
|
14
|
-
|
15
|
-
TyAny = Any
|
16
|
-
TyCallable = Callable[..., Any]
|
17
|
-
TyDateTime = datetime
|
18
|
-
TyTimeStamp = int
|
19
|
-
TyArr = list[Any]
|
20
|
-
TyBool = bool
|
21
|
-
TyDic = dict[Any, Any]
|
22
|
-
TyDir = str
|
23
|
-
TyPath = str
|
24
|
-
TyLogger = Logger
|
25
|
-
|
26
|
-
TnAny = None | Any
|
27
|
-
TnArr = None | TyArr
|
28
|
-
TnBool = None | bool
|
29
|
-
TnDic = None | TyDic
|
30
|
-
TnTimeStamp = None | TyTimeStamp
|
31
|
-
TnDateTime = None | TyDateTime
|
32
|
-
|
33
|
-
|
34
|
-
class Log_:
|
35
|
-
|
36
|
-
sw_init: bool = False
|
37
|
-
log: TyLogger = logging.getLogger('dummy_logger')
|
38
|
-
username: str = psutil.Process().username()
|
39
|
-
|
40
|
-
@classmethod
|
41
|
-
def sh_dir_run(cls, com) -> TyDir:
|
42
|
-
"""Show run_dir
|
43
|
-
"""
|
44
|
-
# print(f"sh_dir_run com.dir_dat = {com.dir_dat}")
|
45
|
-
# print(f"sh_dir_run com.cmd = {com.cmd}")
|
46
|
-
# print(f"sh_dir_run com.tenant = {com.tenant}")
|
47
|
-
# print(f"sh_dir_run com = {com}")
|
48
|
-
dir_dat: str = com.dir_dat
|
49
|
-
tenant: str = com.tenant
|
50
|
-
cmd: str = com.cmd
|
51
|
-
package: str = com.d_app_pacmod['package']
|
52
|
-
# module: str = com.d_app_pacmod['module']
|
53
|
-
if tenant is not None:
|
54
|
-
path = f"{dir_dat}/{tenant}/RUN/{package}"
|
55
|
-
else:
|
56
|
-
path = f"{dir_dat}/RUN/{package}"
|
57
|
-
if com.log_type == "usr":
|
58
|
-
path = f"{path}/{cls.username}"
|
59
|
-
if cmd is not None:
|
60
|
-
path = f"{path}/{cmd}"
|
61
|
-
# print(f"sh_dir_run path = {path}")
|
62
|
-
# print("==================================")
|
63
|
-
return path
|
64
|
-
|
65
|
-
@classmethod
|
66
|
-
def sh_d_log_cfg(cls, com, **kwargs) -> TyDic:
|
67
|
-
"""Read log file path with jinja2
|
68
|
-
"""
|
69
|
-
dir_run = cls.sh_dir_run(com)
|
70
|
-
if kwargs.get('sw_single_dir_run', True):
|
71
|
-
# print("---sw_single_dir_run = True --------------")
|
72
|
-
dir_run_errs = f"{dir_run}/logs"
|
73
|
-
dir_run_wrns = f"{dir_run}/logs"
|
74
|
-
dir_run_infs = f"{dir_run}/logs"
|
75
|
-
dir_run_logs = f"{dir_run}/logs"
|
76
|
-
dir_run_debs = f"{dir_run}/logs"
|
77
|
-
if kwargs.get('sw_mk_dir_run', True):
|
78
|
-
os.makedirs(dir_run_logs, exist_ok=True)
|
79
|
-
else:
|
80
|
-
# print("---sw_single_dir_run = False -------------")
|
81
|
-
dir_run_errs = f"{dir_run}/errs"
|
82
|
-
dir_run_wrns = f"{dir_run}/wrns"
|
83
|
-
dir_run_infs = f"{dir_run}/infs"
|
84
|
-
dir_run_logs = f"{dir_run}/logs"
|
85
|
-
dir_run_debs = f"{dir_run}/debs"
|
86
|
-
if kwargs.get('sw_mk_dir_run', True):
|
87
|
-
os.makedirs(dir_run_errs, exist_ok=True)
|
88
|
-
os.makedirs(dir_run_wrns, exist_ok=True)
|
89
|
-
os.makedirs(dir_run_infs, exist_ok=True)
|
90
|
-
os.makedirs(dir_run_logs, exist_ok=True)
|
91
|
-
os.makedirs(dir_run_debs, exist_ok=True)
|
92
|
-
# path_log_cfg: TyPath = PacMod.sh_path_log_cfg(com)
|
93
|
-
module = com.d_app_pacmod['module']
|
94
|
-
# print(f"sh_d_log_cfg cls.path_log_cfg = {cls.path_log_cfg}")
|
95
|
-
d_log_cfg: TyDic = Jinja2_.read(
|
96
|
-
com.path_log_cfg, com.Log,
|
97
|
-
dir_run_errs=dir_run_errs,
|
98
|
-
dir_run_wrns=dir_run_wrns,
|
99
|
-
dir_run_infs=dir_run_infs,
|
100
|
-
dir_run_logs=dir_run_logs,
|
101
|
-
dir_run_debs=dir_run_debs,
|
102
|
-
module=module,
|
103
|
-
pid=com.pid,
|
104
|
-
ts=com.ts)
|
105
|
-
# print(f"sh_d_log_cfg d_log_cfg = {d_log_cfg}")
|
106
|
-
sw_debug: TyBool = kwargs.get('sw_debug', False)
|
107
|
-
if sw_debug:
|
108
|
-
level = logging.DEBUG
|
109
|
-
else:
|
110
|
-
level = logging.INFO
|
111
|
-
logger_name = com.log_type
|
112
|
-
d_log_cfg['handlers'][f"{logger_name}_debug_console"]['level'] = level
|
113
|
-
d_log_cfg['handlers'][f"{logger_name}_debug_file"]['level'] = level
|
114
|
-
|
115
|
-
return d_log_cfg
|
116
|
-
|
117
|
-
@classmethod
|
118
|
-
def init(cls, com, **kwargs) -> None:
|
119
|
-
"""Set static variable log level in log configuration handlers
|
120
|
-
"""
|
121
|
-
cls.sw_init = True
|
122
|
-
d_log_cfg = cls.sh_d_log_cfg(com, **kwargs)
|
123
|
-
logging.config.dictConfig(d_log_cfg)
|
124
|
-
cls.log = logging.getLogger(com.log_type)
|
125
|
-
|
126
|
-
@classmethod
|
127
|
-
def sh(cls, com, **kwargs) -> TyLogger:
|
128
|
-
if cls.sw_init:
|
129
|
-
return cls.log
|
130
|
-
cls.init(com, **kwargs)
|
131
|
-
return cls.log
|
ka_uts_com/data/__init__.py
DELETED
File without changes
|
ka_uts_com/data/log.std.yml
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
version: 1
|
2
|
-
|
3
|
-
disable_existing_loggers: False
|
4
|
-
|
5
|
-
# root:
|
6
|
-
# level: DEBUG
|
7
|
-
# handlers:
|
8
|
-
# - debug_console
|
9
|
-
# - debug_file
|
10
|
-
|
11
|
-
loggers:
|
12
|
-
|
13
|
-
# standard logger
|
14
|
-
std:
|
15
|
-
# level: NOTSET
|
16
|
-
level: DEBUG
|
17
|
-
handlers:
|
18
|
-
- std_debug_console
|
19
|
-
- std_error_file
|
20
|
-
- std_warning_file
|
21
|
-
- std_debug_file
|
22
|
-
- std_info_file
|
23
|
-
- std_log_file
|
24
|
-
|
25
|
-
handlers:
|
26
|
-
|
27
|
-
std_debug_console:
|
28
|
-
class: 'logging.StreamHandler'
|
29
|
-
level: DEBUG
|
30
|
-
formatter: std_debug
|
31
|
-
stream: 'ext://sys.stderr'
|
32
|
-
|
33
|
-
# std_info_rotating_file_handler:
|
34
|
-
# class: 'logging.handlers.RotatingFileHandler'
|
35
|
-
# level: INFO
|
36
|
-
# formatter: info
|
37
|
-
# filename: 'info.rotating.log'
|
38
|
-
# mode: 'a'
|
39
|
-
# maxBytes: 1048576 # 1MB
|
40
|
-
# backupCount: 10
|
41
|
-
# encoding: utf8
|
42
|
-
|
43
|
-
std_error_file:
|
44
|
-
class: 'logging.FileHandler'
|
45
|
-
level: ERROR
|
46
|
-
formatter: std_error
|
47
|
-
filename: '{{dir_run_errs}}/errs_{{pid}}_{{ts}}.log'
|
48
|
-
mode: 'a'
|
49
|
-
|
50
|
-
std_warning_file:
|
51
|
-
class: 'logging.FileHandler'
|
52
|
-
level: WARNING
|
53
|
-
formatter: std_warning
|
54
|
-
filename: '{{dir_run_wrns}}/wrns_{{pid}}_{{ts}}.log'
|
55
|
-
mode: 'a'
|
56
|
-
|
57
|
-
std_debug_file:
|
58
|
-
class: 'logging.FileHandler'
|
59
|
-
level: DEBUG
|
60
|
-
formatter: std_debug
|
61
|
-
filename: '{{dir_run_debs}}/debs_{{pid}}_{{ts}}.log'
|
62
|
-
mode: 'a'
|
63
|
-
|
64
|
-
std_info_file:
|
65
|
-
class: 'logging.FileHandler'
|
66
|
-
level: INFO
|
67
|
-
formatter: std_info
|
68
|
-
filename: '{{dir_run_infs}}/infs_{{pid}}_{{ts}}.log'
|
69
|
-
mode: 'a'
|
70
|
-
|
71
|
-
std_log_file:
|
72
|
-
class: 'logging.FileHandler'
|
73
|
-
level: INFO
|
74
|
-
formatter: std_log
|
75
|
-
filename: '{{dir_run_logs}}/logs_{{pid}}_{{ts}}.log'
|
76
|
-
mode: 'a'
|
77
|
-
|
78
|
-
std_critical_mail:
|
79
|
-
class: 'logging.handlers.SMTPHandler'
|
80
|
-
level: CRITICAL
|
81
|
-
formatter: std_critical
|
82
|
-
mailhost : localhost
|
83
|
-
fromaddr: 'monitoring@domain.com'
|
84
|
-
toaddrs:
|
85
|
-
- 'dev@domain.com'
|
86
|
-
- 'qa@domain.com'
|
87
|
-
subject: 'Critical error with application name'
|
88
|
-
|
89
|
-
|
90
|
-
formatters:
|
91
|
-
|
92
|
-
std_warning:
|
93
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
94
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
95
|
-
std_error:
|
96
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
97
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
98
|
-
std_debug:
|
99
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
100
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
101
|
-
std_info:
|
102
|
-
format: '%(asctime)s-%(levelname)s-%(name)s::%(module)s|%(lineno)s:: %(message)s'
|
103
|
-
std_log:
|
104
|
-
format: '%(asctime)s-%(levelname)s-%(name)s::%(module)s|%(lineno)s:: %(message)s'
|
105
|
-
std_critical:
|
106
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
107
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
ka_uts_com/data/log.usr.yml
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
version: 1
|
2
|
-
disable_existing_loggers: False
|
3
|
-
|
4
|
-
# root:
|
5
|
-
# level: DEBUG
|
6
|
-
# handlers:
|
7
|
-
# - debug_console
|
8
|
-
# - debug_file
|
9
|
-
|
10
|
-
loggers:
|
11
|
-
|
12
|
-
# user logger
|
13
|
-
usr:
|
14
|
-
# level: NOTSET
|
15
|
-
level: DEBUG
|
16
|
-
handlers:
|
17
|
-
- usr_debug_console
|
18
|
-
- usr_error_file
|
19
|
-
- usr_warning_file
|
20
|
-
- usr_debug_file
|
21
|
-
- usr_info_file
|
22
|
-
- usr_log_file
|
23
|
-
|
24
|
-
handlers:
|
25
|
-
|
26
|
-
usr_debug_console:
|
27
|
-
class: 'logging.StreamHandler'
|
28
|
-
level: DEBUG
|
29
|
-
formatter: usr_debug
|
30
|
-
stream: 'ext://sys.stderr'
|
31
|
-
|
32
|
-
# person_info_rotating_file_handler:
|
33
|
-
# class: 'logging.handlers.RotatingFileHandler'
|
34
|
-
# level: INFO
|
35
|
-
# formatter: info
|
36
|
-
# filename: 'info.rotating.log'
|
37
|
-
# mode: 'a'
|
38
|
-
# maxBytes: 1048576 # 1MB
|
39
|
-
# backupCount: 10
|
40
|
-
# encoding: utf8
|
41
|
-
|
42
|
-
usr_error_file:
|
43
|
-
class: 'logging.FileHandler'
|
44
|
-
level: ERROR
|
45
|
-
formatter: usr_error
|
46
|
-
filename: '{{dir_run_errs}}/errs_{{pid}}_{{ts}}.log'
|
47
|
-
mode: 'a'
|
48
|
-
|
49
|
-
usr_warning_file:
|
50
|
-
class: 'logging.FileHandler'
|
51
|
-
level: ERROR
|
52
|
-
formatter: usr_warning
|
53
|
-
filename: '{{dir_run_wrns}}/wrns_{{pid}}_{{ts}}.log'
|
54
|
-
mode: 'a'
|
55
|
-
|
56
|
-
usr_debug_file:
|
57
|
-
class: 'logging.FileHandler'
|
58
|
-
level: DEBUG
|
59
|
-
formatter: usr_debug
|
60
|
-
filename: '{{dir_run_debs}}/debs_{{pid}}_{{ts}}.log'
|
61
|
-
mode: 'a'
|
62
|
-
|
63
|
-
usr_info_file:
|
64
|
-
class: 'logging.FileHandler'
|
65
|
-
level: INFO
|
66
|
-
formatter: usr_info
|
67
|
-
filename: '{{dir_run_infs}}/infs_{{pid}}_{{ts}}.log'
|
68
|
-
mode: 'a'
|
69
|
-
|
70
|
-
usr_log_file:
|
71
|
-
class: 'logging.FileHandler'
|
72
|
-
level: INFO
|
73
|
-
formatter: usr_log
|
74
|
-
filename: '{{dir_run_logs}}/logs_{{pid}}_{{ts}}.log'
|
75
|
-
mode: 'a'
|
76
|
-
|
77
|
-
usr_critical_mail:
|
78
|
-
class: 'logging.handlers.SMTPHandler'
|
79
|
-
level: CRITICAL
|
80
|
-
formatter: usr_critical
|
81
|
-
mailhost : localhost
|
82
|
-
fromaddr: 'monitoring@domain.com'
|
83
|
-
toaddrs:
|
84
|
-
- 'dev@domain.com'
|
85
|
-
- 'qa@domain.com'
|
86
|
-
subject: 'Critical error with application name'
|
87
|
-
|
88
|
-
|
89
|
-
formatters:
|
90
|
-
|
91
|
-
usr_errs:
|
92
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
93
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
94
|
-
usr_wrns:
|
95
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
96
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
97
|
-
usr_debs:
|
98
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
99
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
100
|
-
usr_infs:
|
101
|
-
format: '%(asctime)s-%(levelname)s-%(name)s::%(module)s|%(lineno)s:: %(message)s'
|
102
|
-
usr_logs:
|
103
|
-
format: '%(asctime)s-%(levelname)s-%(name)s::%(module)s|%(lineno)s:: %(message)s'
|
104
|
-
usr_critical:
|
105
|
-
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
106
|
-
datefmt: '%Y-%m-%d %H:%M:%S'
|
ka_uts_com/fnc.py
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
from collections.abc import Callable
|
3
|
-
from typing import Any
|
4
|
-
|
5
|
-
TyArr = list[Any]
|
6
|
-
TyCallable = Callable[..., Any]
|
7
|
-
TyDic = dict[Any, Any]
|
8
|
-
TyArrDic = TyArr | TyDic
|
9
|
-
TyDoC = dict[str, TyCallable]
|
10
|
-
TyMsg = str
|
11
|
-
|
12
|
-
TnStr = None | str
|
13
|
-
TnDoC = None | TyDoC
|
14
|
-
TnCallable = None | TyCallable
|
15
|
-
|
16
|
-
|
17
|
-
class Fnc:
|
18
|
-
"""
|
19
|
-
Functions
|
20
|
-
"""
|
21
|
-
@staticmethod
|
22
|
-
def identity(obj: Any) -> Any:
|
23
|
-
return obj
|
24
|
-
|
25
|
-
@staticmethod
|
26
|
-
def sh(doc: TnDoC, key: TnStr) -> TyCallable:
|
27
|
-
if not doc:
|
28
|
-
msg = f"function table: {doc} is not defined"
|
29
|
-
raise Exception(msg)
|
30
|
-
if not key:
|
31
|
-
msg = f"key: {key} is not defined"
|
32
|
-
raise Exception(msg)
|
33
|
-
fnc: TnCallable = doc.get(key)
|
34
|
-
if not fnc:
|
35
|
-
msg = f"key: {key} is not defined in function table: {doc}"
|
36
|
-
raise Exception(msg)
|
37
|
-
return fnc
|
38
|
-
|
39
|
-
@classmethod
|
40
|
-
def ex(cls, doc: TnDoC, key: TnStr, args_kwargs: TyArrDic) -> Any:
|
41
|
-
fnc: TyCallable = cls.sh(doc, key)
|
42
|
-
return fnc(args_kwargs)
|