python-sdk-remote 0.0.150__py3-none-any.whl → 0.0.151__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.
- python_sdk_remote/constants.py +3 -0
- python_sdk_remote/constants_src_mini_logger.py +18 -0
- python_sdk_remote/mini_logger.py +67 -58
- python_sdk_remote/utilities.py +2 -1
- {python_sdk_remote-0.0.150.dist-info → python_sdk_remote-0.0.151.dist-info}/METADATA +1 -1
- {python_sdk_remote-0.0.150.dist-info → python_sdk_remote-0.0.151.dist-info}/RECORD +8 -7
- {python_sdk_remote-0.0.150.dist-info → python_sdk_remote-0.0.151.dist-info}/WHEEL +0 -0
- {python_sdk_remote-0.0.150.dist-info → python_sdk_remote-0.0.151.dist-info}/top_level.txt +0 -0
python_sdk_remote/constants.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from logger_local.LoggerComponentEnum import LoggerComponentEnum
|
|
2
2
|
|
|
3
|
+
# TODO Add SmartDatastoreAttributes Class which includes seller_sales_organization_id, seller_delivery_organization_id, buyer_organization_id, distribution_organization_id, end_customer_organization_id, organization_project_id, seller_case_id, customer_case_id, location_id, knowledge_base, segment_id, vertical_id, industry_id, practice_id, segment_id, vertical_id, business_unit_id, driver_id, distribution_line_id, (Add it to python-sdk-remote as both Storage, SmartDataStore should use it) # noqa E501
|
|
4
|
+
|
|
3
5
|
PYTHON_SDK_REMOTE_COMPONENT_ID = 184
|
|
4
6
|
PYTHON_SDK_REMOTE_COMPONENT_NAME = 'python_sdk_remote'
|
|
5
7
|
|
|
@@ -10,6 +12,7 @@ OBJECT_TO_INSERT_CODE = {
|
|
|
10
12
|
'developer_email_address': 'sahar.g@circ.zone'
|
|
11
13
|
}
|
|
12
14
|
|
|
15
|
+
# Move this to the constants_test_python_sdk_remote file (based on the python-package-template)
|
|
13
16
|
OBJECT_TO_INSERT_TEST = {
|
|
14
17
|
'component_id': PYTHON_SDK_REMOTE_COMPONENT_ID,
|
|
15
18
|
'component_name': PYTHON_SDK_REMOTE_COMPONENT_NAME,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# TODO I think enum values should be in uppercase
|
|
5
|
+
class LogMessageSeverity(Enum):
|
|
6
|
+
Debug = 100
|
|
7
|
+
Verbose = 200
|
|
8
|
+
Init = 300
|
|
9
|
+
Info = 500
|
|
10
|
+
Warning = 600
|
|
11
|
+
Error = 700
|
|
12
|
+
Critical = 800
|
|
13
|
+
Exception = 900
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class StartEndEnum(Enum):
|
|
17
|
+
Start = 400
|
|
18
|
+
End = 402
|
python_sdk_remote/mini_logger.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
3
|
import sys
|
|
4
|
+
# from enum import Enum
|
|
5
|
+
import inspect
|
|
6
|
+
from .constants_src_mini_logger import LogMessageSeverity, StartEndEnum
|
|
4
7
|
|
|
5
8
|
# TODO LOGGER_MINIMAL_SEVERITY_DEFAULT
|
|
6
9
|
LOGGER_MINIMUM_SEVERITY = os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO").upper()
|
|
@@ -9,18 +12,18 @@ if LOGGER_MINIMUM_SEVERITY.isdigit():
|
|
|
9
12
|
# TODO logger_minimal_severity_default_value
|
|
10
13
|
logger_minimum_severity = int(LOGGER_MINIMUM_SEVERITY)
|
|
11
14
|
# TODO Change Magic Numbers and use the values from Logger.MessageSeverity
|
|
12
|
-
if logger_minimum_severity <
|
|
15
|
+
if logger_minimum_severity < LogMessageSeverity.Start.value:
|
|
13
16
|
# TODO LOGGER_MINIMAL_SEVERITY_DEFAULT_NAME =
|
|
14
|
-
# TODO Change "DEBUG", "INFO", "WARNING" ... into enum values from Logger.
|
|
15
|
-
LOGGER_MINIMUM_SEVERITY =
|
|
16
|
-
elif logger_minimum_severity <
|
|
17
|
-
LOGGER_MINIMUM_SEVERITY =
|
|
18
|
-
elif logger_minimum_severity <
|
|
19
|
-
LOGGER_MINIMUM_SEVERITY =
|
|
20
|
-
elif logger_minimum_severity <
|
|
21
|
-
LOGGER_MINIMUM_SEVERITY =
|
|
17
|
+
# TODO Change "DEBUG", "INFO", "WARNING" ... into enum values from Logger.LogMessageSeverity
|
|
18
|
+
LOGGER_MINIMUM_SEVERITY = LogMessageSeverity.Debug
|
|
19
|
+
elif logger_minimum_severity < LogMessageSeverity.WARNING.value:
|
|
20
|
+
LOGGER_MINIMUM_SEVERITY = LogMessageSeverity.Info
|
|
21
|
+
elif logger_minimum_severity < LogMessageSeverity.Error.value:
|
|
22
|
+
LOGGER_MINIMUM_SEVERITY = LogMessageSeverity.WARNING
|
|
23
|
+
elif logger_minimum_severity < LogMessageSeverity.Critical.value:
|
|
24
|
+
LOGGER_MINIMUM_SEVERITY = LogMessageSeverity.Error
|
|
22
25
|
else:
|
|
23
|
-
LOGGER_MINIMUM_SEVERITY =
|
|
26
|
+
LOGGER_MINIMUM_SEVERITY = LogMessageSeverity.Critical
|
|
24
27
|
|
|
25
28
|
logging.basicConfig(level=LOGGER_MINIMUM_SEVERITY, stream=sys.stdout,
|
|
26
29
|
format="%(asctime)s - %(message)s")
|
|
@@ -28,105 +31,108 @@ logger = logging.getLogger(__name__)
|
|
|
28
31
|
|
|
29
32
|
|
|
30
33
|
class MiniLogger:
|
|
31
|
-
# TODO Can we
|
|
34
|
+
# TODO Can we so one generic function call by all
|
|
32
35
|
|
|
33
|
-
#
|
|
36
|
+
_is_write_to_sql = False # Should be always False in MiniLogger
|
|
34
37
|
|
|
35
38
|
@staticmethod
|
|
36
|
-
def
|
|
39
|
+
def _log(level: LogMessageSeverity, start_or_end: StartEndEnum = None, log_message: str = None, **kwargs):
|
|
37
40
|
"""
|
|
38
|
-
|
|
41
|
+
Private method to unify all log methods
|
|
39
42
|
|
|
40
43
|
Parameters:
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
level (MessageSeverity): log level
|
|
45
|
+
log_message (str): The message to be printed.
|
|
43
46
|
"""
|
|
47
|
+
object = kwargs.get("object")
|
|
48
|
+
method_name = level.name.lower()
|
|
49
|
+
method = getattr(logger, method_name)
|
|
50
|
+
if not start_or_end:
|
|
51
|
+
action_name = level.name
|
|
52
|
+
else:
|
|
53
|
+
action_name = start_or_end.name
|
|
54
|
+
stk = inspect.stack()[2]
|
|
55
|
+
function = stk.function
|
|
56
|
+
line = stk.lineno
|
|
44
57
|
if object is None:
|
|
45
|
-
|
|
58
|
+
method(f"Function: {function}, Line: {line}; {action_name} - {log_message}")
|
|
46
59
|
else:
|
|
47
|
-
|
|
60
|
+
method(f"Function: {function}, Line: {line}; {action_name} - {log_message} - {object}")
|
|
48
61
|
|
|
49
62
|
@staticmethod
|
|
50
|
-
|
|
63
|
+
# TODO Add a new file called align_logger_and_minilogger_test.py, which makes sure the signature of all methods of MiniLogger and Logger are the same and we can change from MiniLogger to Logger and vice versa by changing only one line in our code. If we should change the signatures, we should make them backward compatible. # noqa E501
|
|
64
|
+
def start(log_message: str = None, **kwargs):
|
|
51
65
|
"""
|
|
52
66
|
Print a log message with the current time.
|
|
53
67
|
|
|
54
68
|
Parameters:
|
|
55
|
-
|
|
69
|
+
log_message (str): The message to be printed.
|
|
56
70
|
"""
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
MiniLogger._log(LogMessageSeverity.Debug, StartEndEnum.Start, log_message, **kwargs)
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def end(log_message: str = None, **kwargs):
|
|
75
|
+
"""
|
|
76
|
+
Print a log message with the current time.
|
|
77
|
+
|
|
78
|
+
Parameters:
|
|
79
|
+
log_message (str): The message to be printed.
|
|
80
|
+
"""
|
|
81
|
+
MiniLogger._log(LogMessageSeverity.Debug, StartEndEnum.End, log_message, **kwargs)
|
|
61
82
|
|
|
62
83
|
# TODO convert all those methods (debug, info, warning, error) into one unified private method
|
|
63
|
-
# TODO Add to the unified private method print of the name of method, version
|
|
84
|
+
# TODO Add to the unified private method print of the name of method, version
|
|
85
|
+
# and line number of the calling function/method to the mini_logger methods
|
|
64
86
|
@staticmethod
|
|
65
|
-
def debug(
|
|
87
|
+
def debug(log_message: str = None, **kwargs):
|
|
66
88
|
"""
|
|
67
89
|
Print a log message with the current time.
|
|
68
90
|
|
|
69
91
|
Parameters:
|
|
70
|
-
|
|
71
|
-
object (dict): The object to be printed.
|
|
92
|
+
log_message (str): The message to be printed.
|
|
72
93
|
"""
|
|
73
|
-
|
|
74
|
-
logger.debug(f"DEBUG - {message}")
|
|
75
|
-
else:
|
|
76
|
-
logger.debug(f"DEBUG {message} - {object}")
|
|
94
|
+
MiniLogger._log(LogMessageSeverity.Debug, log_message=log_message, **kwargs)
|
|
77
95
|
|
|
78
96
|
@staticmethod
|
|
79
|
-
def info(
|
|
97
|
+
def info(log_message: str = None, **kwargs):
|
|
80
98
|
"""
|
|
81
99
|
Print a log message with the current time.
|
|
82
100
|
|
|
83
101
|
Parameters:
|
|
84
|
-
|
|
85
|
-
object (dict): The object to be printed.
|
|
102
|
+
log_message (str): The message to be printed.
|
|
86
103
|
"""
|
|
87
|
-
|
|
88
|
-
logger.info(f"INFO - {message}")
|
|
89
|
-
else:
|
|
90
|
-
logger.info(f"INFO {message} - {object}")
|
|
104
|
+
MiniLogger._log(LogMessageSeverity.Info, log_message=log_message, **kwargs)
|
|
91
105
|
|
|
92
106
|
@staticmethod
|
|
93
|
-
def warning(
|
|
107
|
+
def warning(log_message: str = None, **kwargs):
|
|
94
108
|
"""
|
|
95
109
|
Print a log message with the current time.
|
|
96
110
|
|
|
97
111
|
Parameters:
|
|
98
|
-
|
|
99
|
-
object (dict): The object to be printed.
|
|
112
|
+
log_message (str): The message to be printed.
|
|
100
113
|
"""
|
|
101
114
|
# TODO Add the source of the message - We should add the object or atleast some parts of it
|
|
102
|
-
|
|
103
|
-
logger.warning(f"WARNING - {message}")
|
|
104
|
-
else:
|
|
105
|
-
logger.warning(f"WARNING {message} - {object}")
|
|
115
|
+
MiniLogger._log(LogMessageSeverity.WARNING, log_message=log_message, **kwargs)
|
|
106
116
|
|
|
107
117
|
@staticmethod
|
|
108
|
-
def error(
|
|
118
|
+
def error(log_message: str = None, **kwargs):
|
|
109
119
|
"""
|
|
110
120
|
Print a log error message with the current time.
|
|
111
121
|
|
|
112
122
|
Parameters:
|
|
113
|
-
|
|
114
|
-
object (dict): The object to be printed.
|
|
123
|
+
log_message (str): The message to be printed.
|
|
115
124
|
"""
|
|
116
|
-
|
|
117
|
-
logger.error(f"ERROR - {message}")
|
|
118
|
-
else:
|
|
119
|
-
logger.error(f"ERROR - {message} - {object}")
|
|
125
|
+
MiniLogger._log(LogMessageSeverity.Error, log_message=log_message, **kwargs)
|
|
120
126
|
|
|
121
127
|
@staticmethod
|
|
122
|
-
def exception(
|
|
128
|
+
def exception(log_message: str = None, **kwargs):
|
|
123
129
|
"""
|
|
124
130
|
Print a log error message with the current time.
|
|
125
131
|
|
|
126
132
|
Parameters:
|
|
127
|
-
|
|
128
|
-
object (dict / Exception): The object / Exception to be printed.
|
|
133
|
+
log_message (str): The message to be printed.
|
|
129
134
|
"""
|
|
135
|
+
object = kwargs.get("object")
|
|
130
136
|
if isinstance(object, Exception):
|
|
131
137
|
exception = object
|
|
132
138
|
elif isinstance(object, dict):
|
|
@@ -135,6 +141,9 @@ class MiniLogger:
|
|
|
135
141
|
exception = None
|
|
136
142
|
|
|
137
143
|
if object is None:
|
|
138
|
-
logger.exception(f"EXCEPTION - {
|
|
144
|
+
logger.exception(f"EXCEPTION - {log_message}")
|
|
139
145
|
else:
|
|
140
|
-
logger.exception(f"EXCEPTION- {
|
|
146
|
+
logger.exception(f"EXCEPTION- {log_message} - {object}", exc_info=exception)
|
|
147
|
+
|
|
148
|
+
def is_write_to_sql(self):
|
|
149
|
+
return self._is_write_to_sql
|
python_sdk_remote/utilities.py
CHANGED
|
@@ -30,6 +30,7 @@ DEFAULT_LANG_CODE_STR = "en"
|
|
|
30
30
|
# TODO If no one is using DEFAULT_DATETIME_FORMAT, let's comment it
|
|
31
31
|
# TODO Let's split DEFAULT_DATETIME_FORMAT into two const 1. Displayable to Humans (MMM) 2. Internal (sortable) with %m
|
|
32
32
|
DEFAULT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
|
|
33
|
+
PRINT_STARS = "*** "
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
def append_if_not_exist(lst: list, item: object) -> None:
|
|
@@ -435,7 +436,7 @@ def validate_arguments(args: dict) -> None:
|
|
|
435
436
|
:return: True if all arguments are not None or '', False otherwise
|
|
436
437
|
"""
|
|
437
438
|
for arg, value in args.items():
|
|
438
|
-
if not
|
|
439
|
+
if not value:
|
|
439
440
|
raise ValueError(f"Argument {arg} is cannot be empty (got {value})")
|
|
440
441
|
|
|
441
442
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
python_sdk_remote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
python_sdk_remote/constants.py,sha256=
|
|
2
|
+
python_sdk_remote/constants.py,sha256=UBJta5-UdA1Y-owTesMB4TMht-ZvHApYwXAG8EtL6uE,1372
|
|
3
|
+
python_sdk_remote/constants_src_mini_logger.py,sha256=LnQ2Rkz1lEVDmL0yIxfoCwlkSgzCm8si0Cv7sbCTbbQ,301
|
|
3
4
|
python_sdk_remote/http_response.py,sha256=5_h9xOtUhsMzxUiLT4wkYBpL0StA7XYtaqKF4esGwis,6370
|
|
4
5
|
python_sdk_remote/is_test_data.py,sha256=zbUz-Juj7vOPG9TtIttMIBWFxbsOs4-TuR1RYfGNkp4,92
|
|
5
6
|
python_sdk_remote/item.py,sha256=6DQs1nBKbEmnHjE50vZtkMr14ECS_9b8cvE7ItPAbhE,322
|
|
6
|
-
python_sdk_remote/mini_logger.py,sha256=
|
|
7
|
+
python_sdk_remote/mini_logger.py,sha256=evQW5h9cXp0xAnp0RjqfzfzuJfthyriwU1Uckqs1auA,5801
|
|
7
8
|
python_sdk_remote/our_object.py,sha256=Db3_CbM4e1VtDU97VDesnBNMXNuYvnuDL7QqHv4MgJo,4618
|
|
8
9
|
python_sdk_remote/unified_json.py,sha256=zk4Lo9t9MSHXW8UKdo50YCYmFv5FgTsmHf6l2AWqLWU,961
|
|
9
|
-
python_sdk_remote/utilities.py,sha256=
|
|
10
|
+
python_sdk_remote/utilities.py,sha256=1tJ4PQ-T4oVIlCkmsl8B41vApxV_H2E43_N1xEfjQOU,18095
|
|
10
11
|
python_sdk_remote/valid_json_versions.py,sha256=-ZU65JYI6gTEfK8o6gu9Dmm9SQmwzj5pDbEXiyUbBhQ,138
|
|
11
12
|
python_sdk_remote/validate_environment.py,sha256=nzCHZDw56G56ekrTQT3gG48utjsU4VCwQi9dVsBDas0,2268
|
|
12
|
-
python_sdk_remote-0.0.
|
|
13
|
-
python_sdk_remote-0.0.
|
|
14
|
-
python_sdk_remote-0.0.
|
|
15
|
-
python_sdk_remote-0.0.
|
|
13
|
+
python_sdk_remote-0.0.151.dist-info/METADATA,sha256=zCTBiou8C0-6yc6vaji3Sk6lgVOa1MB5Ma-VHspOdL4,729
|
|
14
|
+
python_sdk_remote-0.0.151.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
+
python_sdk_remote-0.0.151.dist-info/top_level.txt,sha256=JTpEq_svPlI5hTlPq30Ne-NkR-u5464gjVDP2U74PvE,18
|
|
16
|
+
python_sdk_remote-0.0.151.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|