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.
Files changed (48) hide show
  1. ka_uts_com/__version__.py +1 -1
  2. ka_uts_com/{base/app_.py → app.py} +8 -8
  3. ka_uts_com/{base/cfg_.py → cfg.py} +8 -7
  4. ka_uts_com/com.py +47 -47
  5. build/lib/ka_uts_com/base/exit_.py → ka_uts_com/exit.py +1 -1
  6. ka_uts_com/timer.py +1 -1
  7. ka_uts_com-2.1.1.250415.dist-info/METADATA +910 -0
  8. ka_uts_com-2.1.1.250415.dist-info/RECORD +14 -0
  9. {ka_uts_com-2.0.0.250407.dist-info → ka_uts_com-2.1.1.250415.dist-info}/top_level.txt +0 -1
  10. build/lib/ka_uts_com/__init__.py +0 -0
  11. build/lib/ka_uts_com/__version__.py +0 -10
  12. build/lib/ka_uts_com/base/app_.py +0 -50
  13. build/lib/ka_uts_com/base/cfg_.py +0 -35
  14. build/lib/ka_uts_com/base/log_.py +0 -131
  15. build/lib/ka_uts_com/com.py +0 -121
  16. build/lib/ka_uts_com/data/__init__.py +0 -0
  17. build/lib/ka_uts_com/data/log.std.yml +0 -107
  18. build/lib/ka_uts_com/data/log.usr.yml +0 -106
  19. build/lib/ka_uts_com/decorators/dec.py +0 -13
  20. build/lib/ka_uts_com/fnc.py +0 -42
  21. build/lib/ka_uts_com/ioc/jinja2_.py +0 -42
  22. build/lib/ka_uts_com/ioc/yaml_.py +0 -30
  23. build/lib/ka_uts_com/log.py +0 -86
  24. build/lib/ka_uts_com/py.typed +0 -0
  25. build/lib/ka_uts_com/timer.py +0 -69
  26. build/lib/ka_uts_com/utils/aoeqstmt.py +0 -37
  27. build/lib/ka_uts_com/utils/date.py +0 -15
  28. build/lib/ka_uts_com/utils/doeq.py +0 -99
  29. build/lib/ka_uts_com/utils/pacmod.py +0 -123
  30. build/lib/ka_uts_com/utils/str.py +0 -265
  31. ka_uts_com/base/exit_.py +0 -37
  32. ka_uts_com/base/log_.py +0 -131
  33. ka_uts_com/data/__init__.py +0 -0
  34. ka_uts_com/data/log.std.yml +0 -107
  35. ka_uts_com/data/log.usr.yml +0 -106
  36. ka_uts_com/fnc.py +0 -42
  37. ka_uts_com/ioc/jinja2_.py +0 -42
  38. ka_uts_com/ioc/yaml_.py +0 -30
  39. ka_uts_com/log.py +0 -86
  40. ka_uts_com/utils/aoeqstmt.py +0 -37
  41. ka_uts_com/utils/date.py +0 -15
  42. ka_uts_com/utils/doeq.py +0 -99
  43. ka_uts_com/utils/pacmod.py +0 -123
  44. ka_uts_com/utils/str.py +0 -265
  45. ka_uts_com-2.0.0.250407.dist-info/METADATA +0 -1611
  46. ka_uts_com-2.0.0.250407.dist-info/RECORD +0 -49
  47. {ka_uts_com-2.0.0.250407.dist-info → ka_uts_com-2.1.1.250415.dist-info}/WHEEL +0 -0
  48. {ka_uts_com-2.0.0.250407.dist-info → ka_uts_com-2.1.1.250415.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=Xl4-Q_1rFgGIeNNOQjoG9C9bX4YgjFerfGYQ-inehGo,365
3
+ ka_uts_com/app.py,sha256=XGsbQGR_IihCUKJPB__M6CvBPzeoaGOh4Z-kmAR5tE0,1167
4
+ ka_uts_com/cfg.py,sha256=xeg5UxdhYWWtr9qho8LDtZqrqVk3DI3d_HGOkCnmDKg,721
5
+ ka_uts_com/com.py,sha256=eXC9P45H6kxqNbDn5lnPS6vL6yM-46grRCDL7oGCnI4,3024
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.1.1.250415.dist-info/licenses/LICENSE.txt,sha256=BiT3QGI_2iRbdvgS3HDig57lnXJVk60Pj4xM9eeCczI,814
11
+ ka_uts_com-2.1.1.250415.dist-info/METADATA,sha256=PrhWtQiNwlPg7hTOqrvNsO7hqE0fNFALhP_f-xxrjcI,31944
12
+ ka_uts_com-2.1.1.250415.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
13
+ ka_uts_com-2.1.1.250415.dist-info/top_level.txt,sha256=cWCIrm1g6Jn-FbCQuB3wBrrNH1YwqVlc6mE0jV6vg74,21
14
+ ka_uts_com-2.1.1.250415.dist-info/RECORD,,
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.0.0.250407'
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,50 +0,0 @@
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
- sw_replace_keys: TnBool = None
26
- keys: TnArr = None
27
- httpmod: TyAny = None
28
- reqs: TyDic = {}
29
- app: TyDic = {}
30
-
31
- @classmethod
32
- def init(cls, com, **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
- if cls.sw_replace_keys:
39
- try:
40
- cls.keys = Yaml_.read(PacMod.sh_path_keys(com), com.Log)
41
- except Exception as exc:
42
- com.Log.error(exc, exc_info=True)
43
- raise
44
-
45
- @classmethod
46
- def sh(cls, com, **kwargs) -> Any:
47
- if cls.sw_init:
48
- return cls
49
- cls.init(com, **kwargs)
50
- return cls
@@ -1,35 +0,0 @@
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
- sw_init: TyBool = False
21
- cfg: Any = None
22
-
23
- @classmethod
24
- def init(cls, com, **kwargs) -> None:
25
- if cls.sw_init:
26
- return
27
- cls.sw_init = True
28
- cls.cfg = Yaml_.read(PacMod.sh_path_cfg(com), com.Log)
29
-
30
- @classmethod
31
- def sh(cls, com, **kwargs) -> Any:
32
- if cls.sw_init:
33
- return cls
34
- cls.init(com, **kwargs)
35
- 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
@@ -1,121 +0,0 @@
1
- # coding=utf-8
2
- from typing import Any
3
-
4
- import os
5
- import time
6
- import calendar
7
- import importlib.resources as resources
8
- import logging
9
- import logging.config
10
- from logging import Logger
11
- from datetime import datetime
12
-
13
- from ka_uts_com.utils.aoeqstmt import AoEqStmt
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
-
76
- cls.ts = calendar.timegm(time.gmtime())
77
- cls.pid = os.getpid()
78
-
79
- # print(f"Com.init cls.tenanat = {cls.tenant}")
80
- # print(f"Com.init cls.cmd = {cls.cmd}")
81
- # print(f"Com.init kwargs = {kwargs}")
82
-
83
- cls.set_path_bin()
84
- cls.set_path_log_cfg()
85
-
86
- cls.Log = Log_.sh(cls, **kwargs)
87
- cls.cfg = Cfg_.sh(cls, **kwargs)
88
- cls.App = App_.sh(cls, **kwargs)
89
- cls.Exit = Exit_.sh(**kwargs)
90
-
91
- @classmethod
92
- def sh_kwargs(cls, app_cls, d_parms, *args) -> TyDic:
93
- _kwargs: TyDic = AoEqStmt.sh_d_eq(*args, d_parms=d_parms)
94
- cls.init(app_cls, _kwargs)
95
- _kwargs['com'] = cls
96
- return _kwargs
97
-
98
- @classmethod
99
- def set_path_bin(cls):
100
- """ show directory
101
- """
102
- package = cls.d_app_pacmod['package']
103
- path = resources.files(package).joinpath("bin")
104
- if path.is_file():
105
- cls.path_bin = path
106
- # raise ModuleNotFoundError
107
-
108
- @classmethod
109
- def set_path_log_cfg(cls):
110
- """ show directory
111
- """
112
- package = cls.d_app_pacmod['package']
113
- path = resources.files(package).joinpath(f"data/log.{cls.log_type}.yml")
114
- if path.is_file():
115
- cls.path_log_cfg = path
116
- return
117
- package = cls.d_com_pacmod['package']
118
- path = resources.files(package).joinpath(f"data/log.{cls.log_type}.yml")
119
- if path.is_file():
120
- cls.path_log_cfg = path
121
- # raise ModuleNotFoundError
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'
@@ -1,13 +0,0 @@
1
- """
2
- Decorators
3
- """
4
- # coding=utf-8
5
- from ka_uts_com.timer import Timer
6
-
7
-
8
- def timer(fnc):
9
- def wrapper(*args, **kwargs):
10
- Timer.start(fnc)
11
- fnc(*args, **kwargs)
12
- Timer.end(fnc)
13
- return wrapper
@@ -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}")
42
- raise