python-sdk-remote 0.0.64__py3-none-any.whl → 0.0.66__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.
@@ -1,27 +1,28 @@
1
1
  import os
2
+
2
3
  from dotenv import load_dotenv
3
4
 
4
- from logger_local.LoggerComponentEnum import LoggerComponentEnum
5
+ # from logger_local.LoggerComponentEnum import LoggerComponentEnum
5
6
 
6
- PYTHON_SDK_LOCAL_COMPONENT_ID = 184
7
- PYTHON_SDK_LOCAL_COMPONENT_NAME = 'python_sdk_local'
7
+ # PYTHON_SDK_LOCAL_COMPONENT_ID = 184
8
+ # PYTHON_SDK_LOCAL_COMPONENT_NAME = 'python_sdk_local'
8
9
 
9
10
  load_dotenv()
10
11
  ENVIRONMENT_NAME = os.getenv("ENVIRONMENT_NAME")
11
12
  BRAND_NAME = os.getenv("BRAND_NAME")
12
13
  LOGZIO_TOKEN = os.getenv("LOGZIO_TOKEN")
13
14
 
14
- OBJECT_TO_INSERT_CODE = {
15
- 'component_id': PYTHON_SDK_LOCAL_COMPONENT_ID,
16
- 'component_name': PYTHON_SDK_LOCAL_COMPONENT_NAME,
17
- 'component_category': LoggerComponentEnum.ComponentCategory.Code.value,
18
- 'developer_email': 'sahar.g@circ.zone'
19
- }
20
-
21
- OBJECT_TO_INSERT_TEST = {
22
- 'component_id': PYTHON_SDK_LOCAL_COMPONENT_ID,
23
- 'component_name': PYTHON_SDK_LOCAL_COMPONENT_NAME,
24
- 'component_category': LoggerComponentEnum.ComponentCategory.Unit_Test.value,
25
- 'testing_framework': LoggerComponentEnum.testingFramework.pytest.value,
26
- 'developer_email': 'sahar.g@circ.zone'
27
- }
15
+ # OBJECT_TO_INSERT_CODE = {
16
+ # 'component_id': PYTHON_SDK_LOCAL_COMPONENT_ID,
17
+ # 'component_name': PYTHON_SDK_LOCAL_COMPONENT_NAME,
18
+ # 'component_category': LoggerComponentEnum.ComponentCategory.Code.value,
19
+ # 'developer_email': 'sahar.g@circ.zone'
20
+ # }
21
+ #
22
+ # OBJECT_TO_INSERT_TEST = {
23
+ # 'component_id': PYTHON_SDK_LOCAL_COMPONENT_ID,
24
+ # 'component_name': PYTHON_SDK_LOCAL_COMPONENT_NAME,
25
+ # 'component_category': LoggerComponentEnum.ComponentCategory.Unit_Test.value,
26
+ # 'testing_framework': LoggerComponentEnum.testingFramework.pytest.value,
27
+ # 'developer_email': 'sahar.g@circ.zone'
28
+ # }
@@ -17,7 +17,7 @@ class MiniLogger:
17
17
  if object is None:
18
18
  print(f"{datetime.now()} - START - {message}")
19
19
  else:
20
- print(f"{datetime.now()} - START - {message} - {str(object)}")
20
+ print(f"{datetime.now()} - START - {message} - {object}")
21
21
 
22
22
  @staticmethod
23
23
  def end(message: str = "", object: dict = None):
@@ -30,7 +30,7 @@ class MiniLogger:
30
30
  if object is None:
31
31
  print(f"{datetime.now()} - END - {message}")
32
32
  else:
33
- print(f"{datetime.now()} - END - {message} - {str(object)}")
33
+ print(f"{datetime.now()} - END - {message} - {object}")
34
34
 
35
35
  @staticmethod
36
36
  def info(message: str = "", object: dict = None):
@@ -44,7 +44,7 @@ class MiniLogger:
44
44
  if object is None:
45
45
  print(f"{datetime.now()} - INFO - {message}")
46
46
  else:
47
- print(f"{datetime.now()} - INFO {message} - {str(object)}")
47
+ print(f"{datetime.now()} - INFO {message} - {object}")
48
48
 
49
49
  @staticmethod
50
50
  def warning(message: str = "", object: dict = None):
@@ -58,7 +58,7 @@ class MiniLogger:
58
58
  if object is None:
59
59
  print(f"{datetime.now()} - WARNING - {message}")
60
60
  else:
61
- print(f"{datetime.now()} - WARNING {message} - {str(object)}")
61
+ print(f"{datetime.now()} - WARNING {message} - {object}")
62
62
 
63
63
  @staticmethod
64
64
  def error(message: str = "", object: dict = None):
@@ -73,19 +73,19 @@ class MiniLogger:
73
73
  print(f"{datetime.now()} - ERROR - {message}", file=sys.stderr)
74
74
  else:
75
75
  print(
76
- f"{datetime.now()} - ERROR - {message} - {str(object)}", file=sys.stderr)
76
+ f"{datetime.now()} - ERROR - {message} - {object}", file=sys.stderr)
77
77
 
78
78
  @staticmethod
79
- def exception(message: str = "", object: dict = None):
79
+ def exception(message: str = "", object: Exception | dict = None):
80
80
  """
81
81
  Print a log error message with the current time.
82
82
 
83
83
  Parameters:
84
84
  message (str): The message to be printed.
85
- object (dict): The object to be printed.
85
+ object (dict / Exception): The object / Exception to be printed.
86
86
  """
87
87
  if object is None:
88
88
  print(f"{datetime.now()} - EXCEPTION - {message}", file=sys.stderr)
89
89
  else:
90
90
  print(
91
- f"{datetime.now()} - EXCEPTION- {message} - {str(object)}", file=sys.stderr)
91
+ f"{datetime.now()} - EXCEPTION- {message} - {object}", file=sys.stderr)
@@ -1,11 +1,7 @@
1
1
  import json
2
2
  from abc import ABC, abstractmethod
3
3
 
4
- from logger_local.Logger import Logger # TODO Shouldn't we use mini logger?
5
-
6
- from .constants import OBJECT_TO_INSERT_CODE
7
-
8
- logger = Logger.create_logger(object=OBJECT_TO_INSERT_CODE)
4
+ from .mini_logger import MiniLogger as logger
9
5
 
10
6
 
11
7
  class OurObject(ABC):
@@ -1,15 +1,24 @@
1
- from .valid_json_version import valid_json_versions
1
+ from .valid_json_versions import valid_json_versions
2
+
3
+
2
4
  class UnifiedJson:
3
- def __init__(self, data: dict, version: str):
4
- if version not in valid_json_versions:
5
+ def __init__(self, data: dict, json_version: str):
6
+ if json_version not in valid_json_versions:
5
7
  raise Exception(
6
- f"version {version} is not in valid_json_versions {valid_json_versions}"
8
+ f"version {json_version} is not in valid_json_versions {valid_json_versions}, "
9
+ f"please make sure you run sql2code."
7
10
  )
8
- self.version = version
11
+ self.json_version = json_version
9
12
  self.data = data
10
13
 
11
14
  def get_unified_json(self):
12
- return {"version": self.version, "data": self.data}
15
+ return {"version": self.json_version, "data": self.data}
16
+
17
+ def get_data(self):
18
+ return self.data
19
+
20
+ def get_json_version(self):
21
+ return self.json_version
13
22
 
14
23
  def __str__(self):
15
24
  return self.get_unified_json()
@@ -4,15 +4,12 @@ from datetime import date, datetime, time, timedelta
4
4
  from urllib.parse import urlparse
5
5
 
6
6
  from dotenv import load_dotenv
7
- from logger_local.Logger import Logger
8
7
 
9
- from .constants import (BRAND_NAME, ENVIRONMENT_NAME, # noqa: E402
10
- OBJECT_TO_INSERT_CODE)
11
- from .validate_environment import validate_brand_name # noqa: E402
8
+ from .mini_logger import MiniLogger as logger
9
+ from .validate_environment import validate_brand_name
12
10
  from .validate_environment import validate_environment_name
13
11
 
14
- load_dotenv() # for our_get_env
15
- logger = Logger.create_logger(object=OBJECT_TO_INSERT_CODE)
12
+ load_dotenv()
16
13
 
17
14
 
18
15
  def timedelta_to_time_format(time_delta: timedelta) -> str:
@@ -171,9 +168,10 @@ def is_list_of_dicts(obj):
171
168
  logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
172
169
  "is_list_of_dicts_result": is_list_of_dicts_result})
173
170
  return is_list_of_dicts_result
174
- except Exception as e:
175
- logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, exception=e)
176
- raise e
171
+ except Exception as exception:
172
+ logger.exception(IS_LIST_OF_DICTS_FUNCTION_NAME, exception)
173
+ logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME)
174
+ raise
177
175
 
178
176
 
179
177
  def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
@@ -279,25 +277,25 @@ def create_http_body(body):
279
277
 
280
278
  def get_brand_name():
281
279
  validate_brand_name()
282
- return BRAND_NAME
280
+ return our_get_env("BRAND_NAME")
283
281
 
284
282
 
285
283
  def get_environment_name():
286
284
  validate_environment_name()
287
- return ENVIRONMENT_NAME
285
+ return our_get_env("ENVIRONMENT_NAME")
288
286
 
289
287
 
290
- def our_get_env(key: str) -> str:
291
- return os.getenv(key)
288
+ def our_get_env(key: str, default: str = None) -> str:
289
+ return os.getenv(key, default)
292
290
 
293
291
 
294
- def get_sql_hostname():
292
+ def get_sql_hostname() -> str:
295
293
  return our_get_env("RDS_HOSTNAME")
296
294
 
297
295
 
298
- def get_sql_username():
296
+ def get_sql_username() -> str:
299
297
  return our_get_env("RDS_USERNAME")
300
298
 
301
299
 
302
- def get_sql_password():
300
+ def get_sql_password() -> str:
303
301
  return our_get_env("RDS_PASSWORD")
@@ -1,4 +1,4 @@
1
1
  # Later we'll generate this file using Sql2Code (from json_version database schema)
2
2
  valid_json_versions = {
3
- "240109"
4
- }
3
+ "240109": "Description"
4
+ }
@@ -1,6 +1,7 @@
1
1
  from .constants import BRAND_NAME, ENVIRONMENT_NAME, LOGZIO_TOKEN
2
2
 
3
3
 
4
+ # TODO: I think this should be in logger-local, not here (akiva)
4
5
  # TODO Align with https://github.com/circles-zone/typescript-sdk-remote-typescript-package/edit/dev/typescript-sdk/src/utils/index.ts validateTenantEnvironmentVariables() # noqa501
5
6
  def validate_enviroment_variables(brand_name: str = BRAND_NAME, environment_name: str = ENVIRONMENT_NAME,
6
7
  logzio_token: str = LOGZIO_TOKEN):
@@ -17,8 +18,9 @@ def validate_enviroment_variables(brand_name: str = BRAND_NAME, environment_name
17
18
 
18
19
  def validate_environment_name(environment_name: str = ENVIRONMENT_NAME):
19
20
  if environment_name is None:
20
- raise Exception("logger-local-python-package LoggerLocal.py please add Environment Variable called "
21
- "ENVIRONMENT_NAME=local or play1 (instead of ENVIRONMENT)")
21
+ raise Exception(
22
+ "logger-local-python-package LoggerLocal.py in case of Play1 environment, please add Environment Variable called "
23
+ "ENVIRONMENT_NAME=local or play1 (instead of ENVIRONMENT)")
22
24
 
23
25
 
24
26
  def validate_brand_name(brand_name: str = BRAND_NAME):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.64
3
+ Version: 0.0.66
4
4
  Summary: PyPI Package for Circles Python SDK Local Python
5
5
  Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
6
6
  Author: Circles
@@ -9,5 +9,6 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: Other/Proprietary License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
+ Requires-Dist: python-dotenv
12
13
 
13
14
  This is a package for sharing common functions used in different repositories
@@ -0,0 +1,13 @@
1
+ python_sdk_remote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ python_sdk_remote/constants.py,sha256=x8lavZy0egJw9GGQBJlACrC5OjmpM174meeiLhbciII,962
3
+ python_sdk_remote/item.py,sha256=HnSLHkZTKTLNhlaZoPhKAwqG-yHPsd7zvqPPOqnrKVg,287
4
+ python_sdk_remote/mini_logger.py,sha256=ajBalf_chM027FkjIYRv6qi54RqK-bvSIwaQScEPIkc,2898
5
+ python_sdk_remote/our_object.py,sha256=7EA0E43GYJSc2C4ren-1pnALYWUJ2Wm9KQlHUFMpS_k,1997
6
+ python_sdk_remote/unified_json.py,sha256=z26ewUJIJg9duYVcfHMs29ZEJ1iZ6stSO84klKNYC7g,772
7
+ python_sdk_remote/utilities.py,sha256=u2VAco_-ZyB8Kly66eBPJfxygfNlRZ94QlMHt_7Kme4,11344
8
+ python_sdk_remote/valid_json_versions.py,sha256=-ZU65JYI6gTEfK8o6gu9Dmm9SQmwzj5pDbEXiyUbBhQ,138
9
+ python_sdk_remote/validate_environment.py,sha256=HI1Quey-EuaWU27o46F7wOi_qQ4Jpm_Olz_BVTxnXS8,1937
10
+ python_sdk_remote-0.0.66.dist-info/METADATA,sha256=rxr6dIqBvH1LT6NqcK_D45opGYfaUCiaMthx8poHXoI,536
11
+ python_sdk_remote-0.0.66.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
12
+ python_sdk_remote-0.0.66.dist-info/top_level.txt,sha256=JTpEq_svPlI5hTlPq30Ne-NkR-u5464gjVDP2U74PvE,18
13
+ python_sdk_remote-0.0.66.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- python_sdk_remote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- python_sdk_remote/constants.py,sha256=603AC6wrRx6Zwr-Uog1rOKx4ZKmMirbVkpAtCFl01Sc,928
3
- python_sdk_remote/item.py,sha256=HnSLHkZTKTLNhlaZoPhKAwqG-yHPsd7zvqPPOqnrKVg,287
4
- python_sdk_remote/mini_logger.py,sha256=nZRkEB-auNcR3-BlqHYkQirIiQ0QEy6Guak5qz4Wzx0,2892
5
- python_sdk_remote/our_object.py,sha256=YQvxUbtnTA6dTzYXSrro7szjJzP5P9StZ32kZ6orEbU,2135
6
- python_sdk_remote/unified_json.py,sha256=GQcT9l2UWcslf-KpYaXM72hE0xQYqxC53dWso51TMBY,567
7
- python_sdk_remote/utilities.py,sha256=Dv589VxJRjwke-dWE7HqaVvtyq4JDmU0O3xFooN7ZEA,11403
8
- python_sdk_remote/valid_json_versions.py,sha256=YwbNIX9YE4JP0Seo7OOWHJtWE6CbQgX1WeYusUpZE84,122
9
- python_sdk_remote/validate_environment.py,sha256=7B-qtV7vYWTHYOKpjG_d1gWUpmiGASxrm0T7KzzpMtk,1841
10
- python_sdk_remote-0.0.64.dist-info/METADATA,sha256=9fNCVb8da5rO5FuYxg-EZwj3svVcCikmfPJyX5wgrnc,507
11
- python_sdk_remote-0.0.64.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
12
- python_sdk_remote-0.0.64.dist-info/top_level.txt,sha256=JTpEq_svPlI5hTlPq30Ne-NkR-u5464gjVDP2U74PvE,18
13
- python_sdk_remote-0.0.64.dist-info/RECORD,,