ka-uts-com 2.1.0.250408__py3-none-any.whl → 2.2.0.250427__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 +2 -2
- build/lib/ka_uts_com/base/app_.py → ka_uts_com/app.py +9 -11
- ka_uts_com/{base/cfg_.py → cfg.py} +7 -10
- ka_uts_com/com.py +47 -39
- 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.2.0.250427.dist-info/METADATA +929 -0
- ka_uts_com-2.2.0.250427.dist-info/RECORD +14 -0
- {ka_uts_com-2.1.0.250408.dist-info → ka_uts_com-2.2.0.250427.dist-info}/WHEEL +1 -1
- {ka_uts_com-2.1.0.250408.dist-info → ka_uts_com-2.2.0.250427.dist-info}/top_level.txt +0 -1
- build/lib/dist/ka_uts_com-2.0.0.250407-py3-none-any.whl +0 -0
- build/lib/dist/ka_uts_com-2.0.0.250407.tar.gz +0 -0
- build/lib/ka_uts_com/__init__.py +0 -0
- build/lib/ka_uts_com/__version__.py +0 -10
- build/lib/ka_uts_com/base/cfg_.py +0 -36
- build/lib/ka_uts_com/base/log_.py +0 -131
- build/lib/ka_uts_com/com.py +0 -115
- 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 -31
- 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/pac.py +0 -35
- build/lib/ka_uts_com/utils/pacmod.py +0 -109
- build/lib/ka_uts_com/utils/str.py +0 -265
- dist/ka_uts_com-2.0.0.250407-py3-none-any.whl +0 -0
- dist/ka_uts_com-2.0.0.250407.tar.gz +0 -0
- ka_uts_com/base/app_.py +0 -50
- 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 -31
- 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/pac.py +0 -35
- ka_uts_com/utils/pacmod.py +0 -109
- ka_uts_com/utils/str.py +0 -265
- ka_uts_com-2.1.0.250408.dist-info/METADATA +0 -1611
- ka_uts_com-2.1.0.250408.dist-info/RECORD +0 -55
- {ka_uts_com-2.1.0.250408.dist-info → ka_uts_com-2.2.0.250427.dist-info}/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
ka_uts_com/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
ka_uts_com/__version__.py,sha256=X178HytYJn2nJ_3u7ZEbA14WN68VJsJ-_HnHbi62DTE,365
|
3
|
+
ka_uts_com/app.py,sha256=3ns3q-nmPArmKEwitIp4xHR5cEl5tU-Q6QM1NHkM9Wc,1147
|
4
|
+
ka_uts_com/cfg.py,sha256=RQoOwiPRyElO40lu7GqXDcOV-G0Sx_9i09sxkZVK6mI,678
|
5
|
+
ka_uts_com/com.py,sha256=DvlZo5FBtVPJlNa4LIX_7x4kgFpRsPBPa0OGOre7aK0,3075
|
6
|
+
ka_uts_com/exit.py,sha256=RIpFKwEGeBCBBPPQXIcLsrYeNY2dTF8BDlESe6UhdMo,791
|
7
|
+
ka_uts_com/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
ka_uts_com/timer.py,sha256=hSNDh5qV6stSRLLEv-G_eMRoglsOU9N2HvRPUQ-s7yU,2153
|
9
|
+
ka_uts_com/decorators/dec.py,sha256=NHerkpjOYpJXz2CIh9HlN3_YCyLv-SbyQL4ldyGUSpM,217
|
10
|
+
ka_uts_com-2.2.0.250427.dist-info/licenses/LICENSE.txt,sha256=BiT3QGI_2iRbdvgS3HDig57lnXJVk60Pj4xM9eeCczI,814
|
11
|
+
ka_uts_com-2.2.0.250427.dist-info/METADATA,sha256=8NKVY_1kbxdJnkEAxJrbpYdftQpl29nzfS_aALTE8gM,32848
|
12
|
+
ka_uts_com-2.2.0.250427.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
13
|
+
ka_uts_com-2.2.0.250427.dist-info/top_level.txt,sha256=cWCIrm1g6Jn-FbCQuB3wBrrNH1YwqVlc6mE0jV6vg74,21
|
14
|
+
ka_uts_com-2.2.0.250427.dist-info/RECORD,,
|
Binary file
|
Binary file
|
build/lib/ka_uts_com/__init__.py
DELETED
File without changes
|
@@ -1,10 +0,0 @@
|
|
1
|
-
__title__ = 'ka_uts_com'
|
2
|
-
__description__ = 'Communication Utilities.'
|
3
|
-
__url__ = 'https://ka-ut-com.readthedocs.io/en/latest'
|
4
|
-
__version__ = '2.1.0.250408'
|
5
|
-
__build__ = 0x022200
|
6
|
-
__author__ = 'Bernd Stroehle'
|
7
|
-
__author_email__ = 'bernd.stroehle@gmail.com'
|
8
|
-
__license__ = 'Apache-2.0'
|
9
|
-
__copyright__ = 'Copyright 2024 Bernd Stroehle'
|
10
|
-
__cake__ = u'\u2728 \U0001f370 \u2728'
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
from logging import Logger
|
5
|
-
|
6
|
-
from ka_uts_com.ioc.yaml_ import Yaml_
|
7
|
-
|
8
|
-
TyAny = Any
|
9
|
-
TyTimeStamp = int
|
10
|
-
TyArr = list[Any]
|
11
|
-
TyBool = bool
|
12
|
-
TyDic = dict[Any, Any]
|
13
|
-
TyLogger = Logger
|
14
|
-
|
15
|
-
|
16
|
-
class Cfg_:
|
17
|
-
"""Configuration Class
|
18
|
-
"""
|
19
|
-
sw_init: TyBool = False
|
20
|
-
cfg: Any = None
|
21
|
-
|
22
|
-
@classmethod
|
23
|
-
def init(cls, com, **kwargs) -> None:
|
24
|
-
if cls.sw_init:
|
25
|
-
return
|
26
|
-
cls.sw_init = True
|
27
|
-
_path = com.sh_path_cfg()
|
28
|
-
if _path:
|
29
|
-
cls.cfg = Yaml_.read(_path, com.Log)
|
30
|
-
|
31
|
-
@classmethod
|
32
|
-
def sh(cls, com, **kwargs) -> Any:
|
33
|
-
if cls.sw_init:
|
34
|
-
return cls
|
35
|
-
cls.init(com, **kwargs)
|
36
|
-
return cls.cfg
|
@@ -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
|
build/lib/ka_uts_com/com.py
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
import os
|
5
|
-
import time
|
6
|
-
import calendar
|
7
|
-
import logging
|
8
|
-
import logging.config
|
9
|
-
from logging import Logger
|
10
|
-
from datetime import datetime
|
11
|
-
|
12
|
-
from ka_uts_com.utils.aoeqstmt import AoEqStmt
|
13
|
-
from ka_uts_com.utils.pac import Pac
|
14
|
-
from ka_uts_com.utils.pacmod import PacMod
|
15
|
-
from ka_uts_com.base.app_ import App_
|
16
|
-
from ka_uts_com.base.cfg_ import Cfg_
|
17
|
-
from ka_uts_com.base.exit_ import Exit_
|
18
|
-
from ka_uts_com.base.log_ import Log_
|
19
|
-
|
20
|
-
TyAny = Any
|
21
|
-
TyDateTime = datetime
|
22
|
-
TyTimeStamp = int
|
23
|
-
TyArr = list[Any]
|
24
|
-
TyBool = bool
|
25
|
-
TyDic = dict[Any, Any]
|
26
|
-
TyLogger = Logger
|
27
|
-
|
28
|
-
TnAny = None | Any
|
29
|
-
TnArr = None | TyArr
|
30
|
-
TnDic = None | TyDic
|
31
|
-
TnTimeStamp = None | TyTimeStamp
|
32
|
-
TnDateTime = None | TyDateTime
|
33
|
-
TnStr = None | str
|
34
|
-
|
35
|
-
|
36
|
-
class Com:
|
37
|
-
"""Communication Class
|
38
|
-
"""
|
39
|
-
sw_init: bool = False
|
40
|
-
dir_dat: TnStr = None
|
41
|
-
tenant: TnStr = None
|
42
|
-
log_type: TnStr = None
|
43
|
-
cmd: TnStr = None
|
44
|
-
d_com_pacmod: TyDic = {}
|
45
|
-
d_app_pacmod: TyDic = {}
|
46
|
-
path_bin = None
|
47
|
-
path_log_cfg = None
|
48
|
-
|
49
|
-
pid = None
|
50
|
-
|
51
|
-
ts: TnTimeStamp
|
52
|
-
ts_start: TnDateTime = None
|
53
|
-
ts_end: TnDateTime = None
|
54
|
-
ts_etime: TnDateTime = None
|
55
|
-
d_timer: TyDic = {}
|
56
|
-
|
57
|
-
cfg: TnDic = None
|
58
|
-
Log = logging.getLogger('dummy_logger')
|
59
|
-
App: Any = None
|
60
|
-
Exit: Any = None
|
61
|
-
|
62
|
-
@classmethod
|
63
|
-
def init(cls, app_cls, kwargs: TyDic):
|
64
|
-
""" set log and application (module) configuration
|
65
|
-
"""
|
66
|
-
if cls.sw_init:
|
67
|
-
return
|
68
|
-
cls.sw_init = True
|
69
|
-
cls.dir_dat = kwargs.get('dir_dat', '/data')
|
70
|
-
cls.tenant = kwargs.get('tenant')
|
71
|
-
cls.log_type = kwargs.get('log_type', 'std')
|
72
|
-
cls.cmd = kwargs.get('cmd')
|
73
|
-
cls.d_com_pacmod = PacMod.sh_d_pacmod(cls)
|
74
|
-
cls.d_app_pacmod = PacMod.sh_d_pacmod(app_cls)
|
75
|
-
cls.ts = calendar.timegm(time.gmtime())
|
76
|
-
cls.pid = os.getpid()
|
77
|
-
|
78
|
-
cls.path_bin = cls.sh_path_bin()
|
79
|
-
cls.path_log_cfg = cls.sh_path_log_cfg()
|
80
|
-
|
81
|
-
cls.Log = Log_.sh(cls, **kwargs)
|
82
|
-
cls.cfg = Cfg_.sh(cls, **kwargs)
|
83
|
-
cls.App = App_.sh(cls, **kwargs)
|
84
|
-
cls.Exit = Exit_.sh(**kwargs)
|
85
|
-
|
86
|
-
@classmethod
|
87
|
-
def sh_kwargs(cls, app_cls, d_parms, *args) -> TyDic:
|
88
|
-
_kwargs: TyDic = AoEqStmt.sh_d_eq(*args, d_parms=d_parms)
|
89
|
-
cls.init(app_cls, _kwargs)
|
90
|
-
_kwargs['com'] = cls
|
91
|
-
return _kwargs
|
92
|
-
|
93
|
-
@classmethod
|
94
|
-
def sh_path_bin(cls) -> Any:
|
95
|
-
""" show directory
|
96
|
-
"""
|
97
|
-
package = cls.d_app_pacmod['package']
|
98
|
-
path = "bin"
|
99
|
-
return Pac.sh_path_by_package(package, path)
|
100
|
-
|
101
|
-
@classmethod
|
102
|
-
def sh_path_log_cfg(cls) -> Any:
|
103
|
-
""" show directory
|
104
|
-
"""
|
105
|
-
_packages = [cls.d_app_pacmod['package'], cls.d_com_pacmod['package']]
|
106
|
-
_path = f"data/log.{cls.log_type}.yml"
|
107
|
-
return Pac.sh_path_by_packages(_packages, _path)
|
108
|
-
|
109
|
-
@classmethod
|
110
|
-
def sh_path_cfg(cls) -> Any:
|
111
|
-
""" show directory
|
112
|
-
"""
|
113
|
-
package = cls.d_app_pacmod['package']
|
114
|
-
path = 'data/cfg.yml'
|
115
|
-
return Pac.sh_path_by_package(package, path)
|
File without changes
|
@@ -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'
|
@@ -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'
|
build/lib/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)
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
# from collections.abc import Callable
|
3
|
-
from typing import Any
|
4
|
-
|
5
|
-
import os
|
6
|
-
import yaml
|
7
|
-
import jinja2
|
8
|
-
# import logging
|
9
|
-
# import logging.config
|
10
|
-
from logging import Logger
|
11
|
-
|
12
|
-
TyAny = Any
|
13
|
-
TyDic = dict[Any, Any]
|
14
|
-
TyLogger = Logger
|
15
|
-
|
16
|
-
TnDic = None | TyDic
|
17
|
-
|
18
|
-
|
19
|
-
class Jinja2_:
|
20
|
-
|
21
|
-
""" Manage Object to Json file affilitation
|
22
|
-
"""
|
23
|
-
@staticmethod
|
24
|
-
def read_template(path: str) -> Any:
|
25
|
-
directory, file = os.path.split(path)
|
26
|
-
env = jinja2.Environment(loader=jinja2.FileSystemLoader(directory))
|
27
|
-
return env.get_template(file)
|
28
|
-
|
29
|
-
@classmethod
|
30
|
-
def read(cls, path: str, log: TyLogger, **kwargs) -> Any:
|
31
|
-
try:
|
32
|
-
# read jinja template from file
|
33
|
-
template = cls.read_template(path)
|
34
|
-
# render template as yaml string
|
35
|
-
template_rendered = template.render(kwargs)
|
36
|
-
# load yaml string into object
|
37
|
-
obj: Any = yaml.safe_load(template_rendered)
|
38
|
-
return obj
|
39
|
-
except IOError as exc:
|
40
|
-
log.error(exc, exc_info=True)
|
41
|
-
# log.error(f"No such file or directory: path='{path'}")
|
42
|
-
raise
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# coding=utf-8
|
2
|
-
import yaml
|
3
|
-
|
4
|
-
from typing import Any
|
5
|
-
TyAny = Any
|
6
|
-
TyArr = list[Any]
|
7
|
-
TyDic = dict[Any, Any]
|
8
|
-
|
9
|
-
TnAny = None | Any
|
10
|
-
|
11
|
-
|
12
|
-
class Yaml_:
|
13
|
-
""" Manage Object to Yaml file affilitation
|
14
|
-
"""
|
15
|
-
@staticmethod
|
16
|
-
def read(path: str, log) -> TnAny:
|
17
|
-
try:
|
18
|
-
with open(path) as fd:
|
19
|
-
# The Loader parameter handles the conversion from YAML
|
20
|
-
# scalar values to Python object format
|
21
|
-
obj = yaml.load(fd, Loader=yaml.SafeLoader)
|
22
|
-
return obj
|
23
|
-
except FileNotFoundError:
|
24
|
-
log.error(f"No such file or directory: path='{path}'")
|
25
|
-
raise
|
26
|
-
except IOError:
|
27
|
-
# if Com.Log is not None:
|
28
|
-
# fnc_error = Com.Log.error
|
29
|
-
# fnc_error(exc, exc_info=True)
|
30
|
-
raise
|
31
|
-
return None
|