ka-uts-com 1.0.0.240823__py3-none-any.whl → 1.0.1.250131__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.
- build/lib/dist/ka_uts_com-1.0.1.250131-py3-none-any.whl +0 -0
- build/lib/dist/ka_uts_com-1.0.1.250131.tar.gz +0 -0
- build/lib/ka_uts_com/__version__.py +1 -1
- build/lib/ka_uts_com/base/app_.py +51 -0
- build/lib/ka_uts_com/base/cfg_.py +27 -0
- build/lib/ka_uts_com/base/exit_.py +37 -0
- build/lib/ka_uts_com/base/log_.py +115 -0
- build/lib/ka_uts_com/com.py +42 -192
- build/lib/ka_uts_com/data/{log.standard.yml → log.std.yml} +3 -3
- build/lib/ka_uts_com/data/{log.personal.yml → log.usr.yml} +34 -42
- build/lib/ka_uts_com/decorators/dec.py +13 -0
- build/lib/ka_uts_com/fnc.py +29 -24
- build/lib/ka_uts_com/ioc/jinja2_.py +42 -0
- build/lib/ka_uts_com/ioc/yaml_.py +30 -0
- build/lib/ka_uts_com/log.py +32 -20
- build/lib/ka_uts_com/timer.py +17 -24
- build/lib/ka_uts_com/utils/aoeqstmt.py +39 -0
- build/lib/ka_uts_com/{date.py → utils/date.py} +4 -4
- build/lib/ka_uts_com/utils/doeq.py +99 -0
- {ka_uts_com → build/lib/ka_uts_com/utils}/pacmod.py +30 -34
- build/lib/ka_uts_com/utils/py.typed +0 -0
- build/lib/ka_uts_com/{str.py → utils/str.py} +36 -39
- dist/ka_uts_com-1.0.1.250131-py3-none-any.whl +0 -0
- dist/ka_uts_com-1.0.1.250131.tar.gz +0 -0
- ka_uts_com/__version__.py +1 -1
- ka_uts_com/base/app_.py +51 -0
- ka_uts_com/base/cfg_.py +27 -0
- ka_uts_com/base/exit_.py +37 -0
- ka_uts_com/base/log_.py +115 -0
- ka_uts_com/com.py +42 -192
- ka_uts_com/data/{log.standard.yml → log.std.yml} +3 -3
- ka_uts_com/data/{log.personal.yml → log.usr.yml} +34 -42
- ka_uts_com/decorators/dec.py +13 -0
- ka_uts_com/fnc.py +29 -24
- ka_uts_com/ioc/jinja2_.py +42 -0
- ka_uts_com/ioc/yaml_.py +30 -0
- ka_uts_com/log.py +32 -20
- ka_uts_com/timer.py +17 -24
- ka_uts_com/utils/aoeqstmt.py +39 -0
- ka_uts_com/{date.py → utils/date.py} +4 -4
- ka_uts_com/utils/doeq.py +99 -0
- {build/lib/ka_uts_com → ka_uts_com/utils}/pacmod.py +30 -34
- ka_uts_com/utils/py.typed +0 -0
- ka_uts_com/{str.py → utils/str.py} +36 -39
- ka_uts_com-1.0.1.250131.dist-info/METADATA +1628 -0
- ka_uts_com-1.0.1.250131.dist-info/RECORD +55 -0
- {ka_uts_com-1.0.0.240823.dist-info → ka_uts_com-1.0.1.250131.dist-info}/WHEEL +1 -1
- build/lib/dist/ka_uts_com-1.0.0.240823-py3-none-any.whl +0 -0
- build/lib/dist/ka_uts_com-1.0.0.240823.tar.gz +0 -0
- build/lib/ka_uts_com/aeq.py +0 -87
- build/lib/ka_uts_com/argv.py +0 -49
- build/lib/ka_uts_com/ioc.py +0 -57
- dist/ka_uts_com-1.0.0.240823-py3-none-any.whl +0 -0
- dist/ka_uts_com-1.0.0.240823.tar.gz +0 -0
- ka_uts_com/aeq.py +0 -87
- ka_uts_com/argv.py +0 -49
- ka_uts_com/ioc.py +0 -57
- ka_uts_com-1.0.0.240823.dist-info/METADATA +0 -943
- ka_uts_com-1.0.0.240823.dist-info/RECORD +0 -41
- {ka_uts_com-1.0.0.240823.dist-info → ka_uts_com-1.0.1.250131.dist-info/licenses}/LICENSE.txt +0 -0
- {ka_uts_com-1.0.0.240823.dist-info → ka_uts_com-1.0.1.250131.dist-info}/top_level.txt +0 -0
Binary file
|
Binary file
|
@@ -1,7 +1,7 @@
|
|
1
1
|
__title__ = 'ka_uts_com'
|
2
2
|
__description__ = 'Communication Utilities.'
|
3
3
|
__url__ = 'https://ka-ut-com.readthedocs.io/en/latest'
|
4
|
-
__version__ = '1.0.
|
4
|
+
__version__ = '1.0.1.250131'
|
5
5
|
__build__ = 0x022200
|
6
6
|
__author__ = 'Bernd Stroehle'
|
7
7
|
__author_email__ = 'bernd.stroehle@gmail.com'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# coding=utf-8
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
from logging import Logger
|
5
|
+
|
6
|
+
from ka_uts_com.utils.pacmod import PacMod
|
7
|
+
from ka_uts_com.ioc.yaml_ import Yaml_
|
8
|
+
|
9
|
+
TyAny = Any
|
10
|
+
TyArr = list[Any]
|
11
|
+
TyBool = bool
|
12
|
+
TyDic = dict[Any, Any]
|
13
|
+
TyLogger = Logger
|
14
|
+
|
15
|
+
TnAny = None | Any
|
16
|
+
TnArr = None | TyArr
|
17
|
+
TnBool = None | bool
|
18
|
+
TnDic = None | TyDic
|
19
|
+
|
20
|
+
|
21
|
+
class App_:
|
22
|
+
"""Aplication Class
|
23
|
+
"""
|
24
|
+
sw_init: TyBool = False
|
25
|
+
httpmod: TyAny = None
|
26
|
+
sw_replace_keys: TnBool = None
|
27
|
+
keys: TnArr = None
|
28
|
+
reqs: TyDic = {}
|
29
|
+
app: TyDic = {}
|
30
|
+
|
31
|
+
@classmethod
|
32
|
+
def init(cls, log: TyLogger, **kwargs) -> None:
|
33
|
+
if cls.sw_init:
|
34
|
+
return
|
35
|
+
cls.sw_init = True
|
36
|
+
cls.httpmod = kwargs.get('httpmod')
|
37
|
+
cls.sw_replace_keys = kwargs.get('sw_replace_keys', False)
|
38
|
+
try:
|
39
|
+
if cls.sw_replace_keys:
|
40
|
+
d_pacmod: TyDic = kwargs.get('d_pacmod', {})
|
41
|
+
cls.keys = Yaml_.read(PacMod.sh_path_keys_yaml(d_pacmod), log)
|
42
|
+
except Exception as exc:
|
43
|
+
log.error(exc, exc_info=True)
|
44
|
+
raise
|
45
|
+
|
46
|
+
@classmethod
|
47
|
+
def sh(cls, log: TyLogger, **kwargs) -> Any:
|
48
|
+
if cls.sw_init:
|
49
|
+
return cls
|
50
|
+
cls.init(log, **kwargs)
|
51
|
+
return cls
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding=utf-8
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
from logging import Logger
|
5
|
+
|
6
|
+
from ka_uts_com.utils.pacmod import PacMod
|
7
|
+
from ka_uts_com.ioc.yaml_ import Yaml_
|
8
|
+
|
9
|
+
TyAny = Any
|
10
|
+
TyTimeStamp = int
|
11
|
+
TyArr = list[Any]
|
12
|
+
TyBool = bool
|
13
|
+
TyDic = dict[Any, Any]
|
14
|
+
TyLogger = Logger
|
15
|
+
|
16
|
+
|
17
|
+
class Cfg_:
|
18
|
+
"""Configuration Class
|
19
|
+
"""
|
20
|
+
cfg: Any = None
|
21
|
+
|
22
|
+
@classmethod
|
23
|
+
def sh(cls, log: TyLogger, d_pacmod: TyDic) -> Any:
|
24
|
+
""" show configuration
|
25
|
+
"""
|
26
|
+
cls.cfg = Yaml_.read(PacMod.sh_path_cfg_yaml(d_pacmod), log)
|
27
|
+
return cls.cfg
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,115 @@
|
|
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.utils.pacmod import PacMod
|
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
|
+
TyLogger = Logger
|
24
|
+
|
25
|
+
TnAny = None | Any
|
26
|
+
TnArr = None | TyArr
|
27
|
+
TnBool = None | bool
|
28
|
+
TnDic = None | TyDic
|
29
|
+
TnTimeStamp = None | TyTimeStamp
|
30
|
+
TnDateTime = None | TyDateTime
|
31
|
+
|
32
|
+
|
33
|
+
class LogStandard:
|
34
|
+
"""Standard Logging
|
35
|
+
"""
|
36
|
+
|
37
|
+
|
38
|
+
class Log_:
|
39
|
+
|
40
|
+
sw_init: bool = False
|
41
|
+
log: TyLogger = logging.getLogger('dummy_logger')
|
42
|
+
username: str = psutil.Process().username()
|
43
|
+
|
44
|
+
@classmethod
|
45
|
+
def sh_run_dir(cls, com, **kwargs) -> TyDir:
|
46
|
+
"""Show run_dir
|
47
|
+
"""
|
48
|
+
tenant: str = com.d_pacmod['tenant']
|
49
|
+
package: str = com.d_pacmod['package']
|
50
|
+
module: str = com.d_pacmod['module']
|
51
|
+
log_type: str = kwargs.get('log_type', 'std')
|
52
|
+
if log_type == "std":
|
53
|
+
return f"/data/{tenant}/RUN/{package}/{module}"
|
54
|
+
return f"/data/{tenant}/RUN/{package}/{module}/{cls.username}"
|
55
|
+
|
56
|
+
@classmethod
|
57
|
+
def sh_cfg(cls, com, **kwargs) -> TyDic:
|
58
|
+
"""Read log file path with jinja2
|
59
|
+
"""
|
60
|
+
run_dir = kwargs.get('run_dir', cls.sh_run_dir(com, **kwargs))
|
61
|
+
run_dir_debug: str = kwargs.get('run_dir_debug', f"{run_dir}/debs")
|
62
|
+
run_dir_info: str = kwargs.get('run_dir_info', f"{run_dir}/logs")
|
63
|
+
run_dir_error: str = kwargs.get('run_dir_error', f"{run_dir}/errs")
|
64
|
+
|
65
|
+
if kwargs.get('sw_mklogdirs', True):
|
66
|
+
os.makedirs(run_dir_debug, exist_ok=True)
|
67
|
+
os.makedirs(run_dir_info, exist_ok=True)
|
68
|
+
os.makedirs(run_dir_error, exist_ok=True)
|
69
|
+
|
70
|
+
log_type = kwargs.get('log_type', 'std')
|
71
|
+
logcfg_file = f'log.{log_type}.yml'
|
72
|
+
logcfg_path: str = PacMod.sh_path_cfg_log(filename=logcfg_file)
|
73
|
+
cfg: TyDic = Jinja2_.read(
|
74
|
+
logcfg_path,
|
75
|
+
com.Log,
|
76
|
+
debug_dir=run_dir_debug,
|
77
|
+
info_dir=run_dir_info,
|
78
|
+
error_dir=run_dir_error,
|
79
|
+
module=com.d_pacmod['module'],
|
80
|
+
pid=com.pid,
|
81
|
+
ts=com.ts)
|
82
|
+
# ts=com.ts_start)
|
83
|
+
sw_debug: TyBool = kwargs.get('sw_debug', False)
|
84
|
+
if sw_debug:
|
85
|
+
level = logging.DEBUG
|
86
|
+
else:
|
87
|
+
level = logging.INFO
|
88
|
+
if log_type == 'std':
|
89
|
+
logger_name = 'main'
|
90
|
+
else:
|
91
|
+
logger_name = 'person'
|
92
|
+
cfg['handlers'][f"{logger_name}_debug_console"]['level'] = level
|
93
|
+
cfg['handlers'][f"{logger_name}_debug_file"]['level'] = level
|
94
|
+
|
95
|
+
return cfg
|
96
|
+
|
97
|
+
@classmethod
|
98
|
+
def init(cls, com, **kwargs) -> None:
|
99
|
+
"""Set static variable log level in log configuration handlers
|
100
|
+
"""
|
101
|
+
log_type = kwargs.get('log_type', 'std')
|
102
|
+
cls.sw_init = True
|
103
|
+
cfg = cls.sh_cfg(com, **kwargs)
|
104
|
+
logging.config.dictConfig(cfg)
|
105
|
+
if log_type == "std":
|
106
|
+
cls.log = logging.getLogger('main')
|
107
|
+
else:
|
108
|
+
cls.log = logging.getLogger(log_type)
|
109
|
+
|
110
|
+
@classmethod
|
111
|
+
def sh(cls, com, **kwargs) -> TyLogger:
|
112
|
+
if cls.sw_init:
|
113
|
+
return cls.log
|
114
|
+
cls.init(com, **kwargs)
|
115
|
+
return cls.log
|
build/lib/ka_uts_com/com.py
CHANGED
@@ -1,205 +1,52 @@
|
|
1
1
|
# coding=utf-8
|
2
|
+
from typing import Any
|
2
3
|
|
4
|
+
import os
|
5
|
+
import time
|
3
6
|
import calendar
|
4
7
|
import logging
|
5
8
|
import logging.config
|
6
9
|
from logging import Logger
|
7
|
-
|
8
|
-
import os
|
9
|
-
import time
|
10
10
|
from datetime import datetime
|
11
11
|
|
12
|
-
from ka_uts_com.
|
13
|
-
from ka_uts_com.
|
14
|
-
from ka_uts_com.
|
15
|
-
|
16
|
-
from
|
12
|
+
from ka_uts_com.utils.aoeqstmt import AoEqStmt
|
13
|
+
from ka_uts_com.base.app_ import App_
|
14
|
+
from ka_uts_com.base.cfg_ import Cfg_
|
15
|
+
from ka_uts_com.base.exit_ import Exit_
|
16
|
+
from ka_uts_com.base.log_ import Log_
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
TyAny = Any
|
19
|
+
TyDateTime = datetime
|
20
|
+
TyTimeStamp = int
|
21
|
+
TyArr = list[Any]
|
22
|
+
TyBool = bool
|
23
|
+
TyDic = dict[Any, Any]
|
24
|
+
TyLogger = Logger
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
class LogStandard:
|
30
|
-
"""Standard Logging
|
31
|
-
"""
|
32
|
-
sw_init: bool = False
|
33
|
-
cfg: T_Dic = {}
|
34
|
-
log: Logger = logging.getLogger('dummy_logger')
|
35
|
-
logfile: str = 'log.standard.yml'
|
36
|
-
|
37
|
-
@staticmethod
|
38
|
-
def read(pacmod: T_Dic, filename: str) -> Any:
|
39
|
-
"""Read log file path with jinja2
|
40
|
-
"""
|
41
|
-
# path: str = Pacmod.Path.Log.sh_cfg(filename=filename)
|
42
|
-
path: str = Pacmod.sh_path_cfg_log(filename=filename)
|
43
|
-
tenant: str = pacmod['tenant']
|
44
|
-
package: str = pacmod['package']
|
45
|
-
module: str = pacmod['module']
|
46
|
-
pid = Com.pid
|
47
|
-
ts: TN_DT = Com.ts_start
|
48
|
-
cfg = Jinja2.read(
|
49
|
-
path, tenant=tenant,
|
50
|
-
package=package, module=module,
|
51
|
-
pid=pid, ts=ts)
|
52
|
-
return cfg
|
53
|
-
|
54
|
-
@classmethod
|
55
|
-
def set_level(cls, sw_debug: bool) -> None:
|
56
|
-
"""Set static variable log level in log configuration handlers
|
57
|
-
"""
|
58
|
-
if sw_debug:
|
59
|
-
level = logging.DEBUG
|
60
|
-
else:
|
61
|
-
level = logging.INFO
|
62
|
-
cls.cfg['handlers']['main_debug_console']['level'] = level
|
63
|
-
cls.cfg['handlers']['main_debug_file']['level'] = level
|
64
|
-
|
65
|
-
@classmethod
|
66
|
-
def init(
|
67
|
-
cls, **kwargs) -> None:
|
68
|
-
cls.sw_init = True
|
69
|
-
cls.cfg = cls.read(Com.pacmod_curr, cls.logfile)
|
70
|
-
sw_debug: Any = kwargs.get('sw_debug')
|
71
|
-
cls.set_level(sw_debug)
|
72
|
-
logging.config.dictConfig(cls.cfg)
|
73
|
-
cls.log = logging.getLogger('main')
|
74
|
-
|
75
|
-
@classmethod
|
76
|
-
def sh(cls, **kwargs) -> Any:
|
77
|
-
if cls.sw_init:
|
78
|
-
return cls.log
|
79
|
-
cls.init(**kwargs)
|
80
|
-
return cls.log
|
81
|
-
|
82
|
-
|
83
|
-
class LogPersonal:
|
84
|
-
"""Personal Logging
|
85
|
-
"""
|
86
|
-
sw_init: bool = False
|
87
|
-
cfg: T_Dic = {}
|
88
|
-
logfile = 'log.person.yml'
|
89
|
-
log: Logger = logging.getLogger('dummy_logger')
|
90
|
-
|
91
|
-
@classmethod
|
92
|
-
def read(cls, pacmod: T_Dic, person: Any, filename: str) -> Any:
|
93
|
-
path: str = Pacmod.sh_path_cfg_log(filename=filename)
|
94
|
-
package: str = pacmod['package']
|
95
|
-
module: str = pacmod['module']
|
96
|
-
return Jinja2.read(
|
97
|
-
path, package=package, module=module, person=person,
|
98
|
-
pid=Com.pid, ts=Com.ts_start)
|
99
|
-
|
100
|
-
@classmethod
|
101
|
-
def set_level(cls, person: str, sw_debug: bool) -> None:
|
102
|
-
if sw_debug:
|
103
|
-
level = logging.DEBUG
|
104
|
-
else:
|
105
|
-
level = logging.INFO
|
106
|
-
cls.cfg['handlers'][f'{person}_debug_console']['level'] = level
|
107
|
-
cls.cfg['handlers'][f'{person}_debug_file']['level'] = level
|
108
|
-
|
109
|
-
@classmethod
|
110
|
-
def init(cls, pacmod: T_Dic, person: str, sw_debug: bool) -> None:
|
111
|
-
cls.cfg = cls.read(pacmod, person, cls.logfile)
|
112
|
-
cls.set_level(person, sw_debug)
|
113
|
-
logging.config.dictConfig(cls.cfg)
|
114
|
-
cls.log = logging.getLogger(person)
|
115
|
-
|
116
|
-
@classmethod
|
117
|
-
def sh(cls, **kwargs) -> Any:
|
118
|
-
if cls.sw_init:
|
119
|
-
return cls.log
|
120
|
-
cls.init(**kwargs)
|
121
|
-
return cls.log
|
122
|
-
|
123
|
-
|
124
|
-
class Cfg:
|
125
|
-
"""Configuration Class
|
126
|
-
"""
|
127
|
-
@classmethod
|
128
|
-
def init(cls, pacmod: T_Dic) -> TN_Dic:
|
129
|
-
""" the package data directory has to contain a __init__.py
|
130
|
-
file otherwise the objects notation {package}.data to
|
131
|
-
locate the package data directory is invalid
|
132
|
-
"""
|
133
|
-
_dic: TN_Dic = Yaml.read(Pacmod.sh_path_cfg_yaml(pacmod))
|
134
|
-
return _dic
|
135
|
-
|
136
|
-
|
137
|
-
class Mgo:
|
138
|
-
"""Mongo DB Class
|
139
|
-
"""
|
140
|
-
client = None
|
141
|
-
|
142
|
-
|
143
|
-
class App:
|
144
|
-
"""Aplication Class
|
145
|
-
"""
|
146
|
-
sw_init: T_Bool = False
|
147
|
-
httpmod: T_Any = None
|
148
|
-
sw_replace_keys: TN_Bool = None
|
149
|
-
keys: TN_Arr = None
|
150
|
-
reqs: T_Dic = {}
|
151
|
-
app: T_Dic = {}
|
152
|
-
|
153
|
-
@classmethod
|
154
|
-
def init(cls, **kwargs) -> Any:
|
155
|
-
cls.sw_init = True
|
156
|
-
cls.httpmod = kwargs.get('httpmod')
|
157
|
-
cls.sw_replace_keys = kwargs.get('sw_replace_keys', False)
|
158
|
-
try:
|
159
|
-
if cls.sw_replace_keys:
|
160
|
-
pacmod = kwargs.get('pacmod_curr')
|
161
|
-
# cls.keys = Yaml.read(Pacmod.Pmd.sh_path_keys(pacmod))
|
162
|
-
cls.keys = Yaml.read(Pacmod.sh_path_keys_yaml(pacmod))
|
163
|
-
except Exception as e:
|
164
|
-
if Com.Log is not None:
|
165
|
-
fnc_error: Callable = Com.Log.error
|
166
|
-
fnc_error(e, exc_info=True)
|
167
|
-
raise
|
168
|
-
return cls
|
169
|
-
|
170
|
-
@classmethod
|
171
|
-
def sh(cls, **kwargs) -> Any:
|
172
|
-
if cls.sw_init:
|
173
|
-
return cls
|
174
|
-
cls.init(**kwargs)
|
175
|
-
return cls
|
176
|
-
|
177
|
-
|
178
|
-
class Exit:
|
179
|
-
"""Exit Class
|
180
|
-
"""
|
181
|
-
sw_critical: bool = False
|
182
|
-
sw_stop: bool = False
|
183
|
-
sw_interactive: bool = False
|
26
|
+
TnAny = None | Any
|
27
|
+
TnArr = None | TyArr
|
28
|
+
TnDic = None | TyDic
|
29
|
+
TnTimeStamp = None | TyTimeStamp
|
30
|
+
TnDateTime = None | TyDateTime
|
184
31
|
|
185
32
|
|
186
33
|
class Com:
|
187
34
|
"""Communication Class
|
188
35
|
"""
|
189
36
|
sw_init: bool = False
|
190
|
-
cfg:
|
37
|
+
cfg: TnDic = None
|
191
38
|
pid = None
|
192
|
-
|
39
|
+
d_pacmod: TyDic = {}
|
193
40
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
41
|
+
ts: TnTimeStamp
|
42
|
+
ts_start: TnDateTime = None
|
43
|
+
ts_end: TnDateTime = None
|
44
|
+
ts_etime: TnDateTime = None
|
45
|
+
d_timer: TyDic = {}
|
198
46
|
|
199
|
-
# Log = None
|
200
47
|
Log: Logger = logging.getLogger('dummy_logger')
|
201
|
-
App = None
|
202
|
-
Exit =
|
48
|
+
App: Any = None
|
49
|
+
Exit: Any = None
|
203
50
|
|
204
51
|
@classmethod
|
205
52
|
def init(cls, **kwargs):
|
@@ -208,15 +55,18 @@ class Com:
|
|
208
55
|
if cls.sw_init:
|
209
56
|
return
|
210
57
|
cls.sw_init = True
|
211
|
-
|
212
|
-
cls.
|
213
|
-
cls.ts_start = calendar.timegm(time.gmtime())
|
58
|
+
cls.d_pacmod = kwargs.get('d_pacmod', {})
|
59
|
+
cls.ts = calendar.timegm(time.gmtime())
|
214
60
|
cls.pid = os.getpid()
|
215
61
|
|
216
|
-
cls.
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
62
|
+
cls.Log = Log_.sh(cls, **kwargs)
|
63
|
+
cls.cfg = Cfg_.sh(cls.Log, cls.d_pacmod)
|
64
|
+
cls.App = App_.sh(cls.Log, **kwargs)
|
65
|
+
cls.Exit = Exit_.sh(**kwargs)
|
66
|
+
|
67
|
+
@classmethod
|
68
|
+
def sh_kwargs(cls, root_cls, d_parms, *args) -> TyDic:
|
69
|
+
_kwargs: TyDic = AoEqStmt.sh_d_eq(
|
70
|
+
*args, d_parms=d_parms, root_cls=root_cls)
|
71
|
+
cls.init(**_kwargs)
|
72
|
+
return _kwargs
|
@@ -42,21 +42,21 @@ handlers:
|
|
42
42
|
class: 'logging.FileHandler'
|
43
43
|
level: DEBUG
|
44
44
|
formatter: main_error
|
45
|
-
filename: '
|
45
|
+
filename: '{{debug_dir}}/debs_{{pid}}_{{ts}}.log'
|
46
46
|
mode: 'a'
|
47
47
|
|
48
48
|
main_info_file:
|
49
49
|
class: 'logging.FileHandler'
|
50
50
|
level: INFO
|
51
51
|
formatter: main_info
|
52
|
-
filename: '
|
52
|
+
filename: '{{info_dir}}/logs_{{pid}}_{{ts}}.log'
|
53
53
|
mode: 'a'
|
54
54
|
|
55
55
|
main_error_file:
|
56
56
|
class: 'logging.FileHandler'
|
57
57
|
level: ERROR
|
58
58
|
formatter: main_error
|
59
|
-
filename: '
|
59
|
+
filename: '{{error_dir}}/errs_{{pid}}_{{ts}}.log'
|
60
60
|
mode: 'a'
|
61
61
|
|
62
62
|
main_critical_mail:
|
@@ -1,49 +1,33 @@
|
|
1
1
|
version: 1
|
2
|
-
|
3
2
|
disable_existing_loggers: False
|
4
3
|
|
5
|
-
root:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
# root:
|
5
|
+
# level: DEBUG
|
6
|
+
# handlers:
|
7
|
+
# - debug_console
|
8
|
+
# - debug_file
|
10
9
|
|
11
10
|
loggers:
|
12
11
|
|
13
|
-
# main logger
|
14
|
-
main:
|
15
|
-
level: 'NOTSET'
|
16
|
-
handlers:
|
17
|
-
- debug_console
|
18
|
-
- debug_file
|
19
|
-
- info_file
|
20
|
-
- error_file
|
21
|
-
|
22
12
|
# person logger
|
23
13
|
person:
|
24
|
-
level: NOTSET
|
14
|
+
# level: NOTSET
|
15
|
+
level: DEBUG
|
25
16
|
handlers:
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
17
|
+
- person_debug_console
|
18
|
+
- person_debug_file
|
19
|
+
- person_info_file
|
20
|
+
- person_error_file
|
30
21
|
|
31
22
|
handlers:
|
32
23
|
|
33
|
-
|
24
|
+
person_debug_console:
|
34
25
|
class: 'logging.StreamHandler'
|
35
26
|
level: DEBUG
|
36
|
-
formatter:
|
27
|
+
formatter: person_debug
|
37
28
|
stream: 'ext://sys.stderr'
|
38
29
|
|
39
|
-
|
40
|
-
class: 'logging.FileHandler'
|
41
|
-
level: DEBUG
|
42
|
-
formatter: error
|
43
|
-
filename: 'debug.log'
|
44
|
-
mode: 'a'
|
45
|
-
|
46
|
-
# info_rotating_file_handler:
|
30
|
+
# person_info_rotating_file_handler:
|
47
31
|
# class: 'logging.handlers.RotatingFileHandler'
|
48
32
|
# level: INFO
|
49
33
|
# formatter: info
|
@@ -53,24 +37,31 @@ handlers:
|
|
53
37
|
# backupCount: 10
|
54
38
|
# encoding: utf8
|
55
39
|
|
56
|
-
|
40
|
+
person_debug_file:
|
41
|
+
class: 'logging.FileHandler'
|
42
|
+
level: DEBUG
|
43
|
+
formatter: person_error
|
44
|
+
filename: '{{debug_dir}}/debs_{{pid}}_{{ts}}.log'
|
45
|
+
mode: 'a'
|
46
|
+
|
47
|
+
person_info_file:
|
57
48
|
class: 'logging.FileHandler'
|
58
49
|
level: INFO
|
59
|
-
formatter:
|
60
|
-
filename: '
|
50
|
+
formatter: person_info
|
51
|
+
filename: '{{info_dir}}/logs_{{pid}}_{{ts}}.log'
|
61
52
|
mode: 'a'
|
62
53
|
|
63
|
-
|
54
|
+
person_error_file:
|
64
55
|
class: 'logging.FileHandler'
|
65
56
|
level: ERROR
|
66
|
-
formatter:
|
67
|
-
filename: '
|
57
|
+
formatter: person_error
|
58
|
+
filename: '{{error_dir}}/errs_{{pid}}_{{ts}}.log'
|
68
59
|
mode: 'a'
|
69
60
|
|
70
|
-
|
61
|
+
person_critical_mail:
|
71
62
|
class: 'logging.handlers.SMTPHandler'
|
72
63
|
level: CRITICAL
|
73
|
-
formatter:
|
64
|
+
formatter: person_critical
|
74
65
|
mailhost : localhost
|
75
66
|
fromaddr: 'monitoring@domain.com'
|
76
67
|
toaddrs:
|
@@ -78,16 +69,17 @@ handlers:
|
|
78
69
|
- 'qa@domain.com'
|
79
70
|
subject: 'Critical error with application name'
|
80
71
|
|
72
|
+
|
81
73
|
formatters:
|
82
74
|
|
83
|
-
|
75
|
+
person_info:
|
84
76
|
format: '%(asctime)s-%(levelname)s-%(name)s::%(module)s|%(lineno)s:: %(message)s'
|
85
|
-
|
77
|
+
person_debug:
|
86
78
|
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
87
79
|
datefmt: '%Y-%m-%d %H:%M:%S'
|
88
|
-
|
80
|
+
person_error:
|
89
81
|
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
90
82
|
datefmt: '%Y-%m-%d %H:%M:%S'
|
91
|
-
|
83
|
+
person_critical:
|
92
84
|
format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
|
93
85
|
datefmt: '%Y-%m-%d %H:%M:%S'
|