python-sdk-local 0.0.147__tar.gz → 0.0.149__tar.gz
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_local-0.0.147 → python_sdk_local-0.0.149}/PKG-INFO +1 -1
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/utilities.py +57 -11
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/PKG-INFO +1 -1
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/setup.py +1 -1
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/README.md +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/pyproject.toml +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/__init__.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/constants.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/http_response.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/item.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/our_object.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/service_response.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/unified_json.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/valid_json_versions.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/validate_environment.py +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/SOURCES.txt +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/dependency_links.txt +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/requires.txt +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/top_level.txt +0 -0
- {python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/setup.cfg +0 -0
|
@@ -11,12 +11,15 @@ import requests
|
|
|
11
11
|
from dotenv import load_dotenv
|
|
12
12
|
|
|
13
13
|
from python_sdk_remote.mini_logger import MiniLogger as logger
|
|
14
|
+
from python_sdk_remote.utilities import our_get_env
|
|
14
15
|
|
|
15
16
|
load_dotenv()
|
|
16
17
|
# If DOTENV_PATH is defined, load the environment variables from the specified file
|
|
17
18
|
# If OVERRIDE_DOTENV is set to True, override the existing environment variables
|
|
18
|
-
override = True if os.getenv("OVERRIDE_DOTENV", "").lower() in (
|
|
19
|
-
|
|
19
|
+
override = True if os.getenv("OVERRIDE_DOTENV", "").lower() in (
|
|
20
|
+
"t", "true", "0") else False
|
|
21
|
+
load_dotenv(dotenv_path=os.environ.get("DOTENV_PATH"),
|
|
22
|
+
override=override) # add another .env file if needed
|
|
20
23
|
|
|
21
24
|
# raise Exception("Failed to load environment variables from .env file\n"
|
|
22
25
|
# "Please check if the file exists, maybe you are not in the right venv?")
|
|
@@ -72,7 +75,8 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
|
|
|
72
75
|
"02:30:45"
|
|
73
76
|
"""
|
|
74
77
|
TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME = "timedelta_to_time_format"
|
|
75
|
-
logger.start(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME,
|
|
78
|
+
logger.start(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME,
|
|
79
|
+
object={'time_delta': time_delta})
|
|
76
80
|
|
|
77
81
|
# Calculate the total seconds and convert to HH:MM:SS format
|
|
78
82
|
total_seconds = int(time_delta.total_seconds())
|
|
@@ -94,7 +98,8 @@ def is_valid_time_range(time_range: tuple) -> bool:
|
|
|
94
98
|
"""
|
|
95
99
|
logger.start(object={"time_range": time_range.__str__()})
|
|
96
100
|
if len(time_range) != 2:
|
|
97
|
-
logger.end(object={"is_valid_time_range_result": False,
|
|
101
|
+
logger.end(object={"is_valid_time_range_result": False,
|
|
102
|
+
"reason": "len(time_range) != 2"})
|
|
98
103
|
return False
|
|
99
104
|
|
|
100
105
|
for time_obj in time_range:
|
|
@@ -131,7 +136,8 @@ def is_valid_date_range(date_range: tuple) -> bool:
|
|
|
131
136
|
"""
|
|
132
137
|
logger.start(object={"date_range": date_range.__str__()})
|
|
133
138
|
if len(date_range) != 2:
|
|
134
|
-
logger.end(object={"is_valid_date_range_result": False,
|
|
139
|
+
logger.end(object={"is_valid_date_range_result": False,
|
|
140
|
+
"reason": "len(date_range) != 2"})
|
|
135
141
|
return False
|
|
136
142
|
|
|
137
143
|
for date_obj in date_range:
|
|
@@ -149,7 +155,8 @@ def is_valid_datetime_range(datetime_range: tuple[datetime, datetime]) -> bool:
|
|
|
149
155
|
"""
|
|
150
156
|
logger.start(object={"datetime_range": datetime_range.__str__()})
|
|
151
157
|
if len(datetime_range) != 2:
|
|
152
|
-
logger.end(object={"is_valid_datetime_range_result": False,
|
|
158
|
+
logger.end(object={"is_valid_datetime_range_result": False,
|
|
159
|
+
"reason": "len(datetime_range) != 2"})
|
|
153
160
|
return False
|
|
154
161
|
|
|
155
162
|
if not all(isinstance(datetime_obj, datetime) for datetime_obj in datetime_range):
|
|
@@ -186,7 +193,8 @@ def is_list_of_dicts(obj: object) -> bool:
|
|
|
186
193
|
try:
|
|
187
194
|
if not isinstance(obj, list):
|
|
188
195
|
is_list_of_dicts_result = False
|
|
189
|
-
logger.end(
|
|
196
|
+
logger.end(
|
|
197
|
+
object={"is_list_of_dicts_result": is_list_of_dicts_result})
|
|
190
198
|
return is_list_of_dicts_result
|
|
191
199
|
for item in obj:
|
|
192
200
|
if not isinstance(item, dict):
|
|
@@ -324,7 +332,8 @@ def validate_arguments(args: dict) -> None:
|
|
|
324
332
|
"""
|
|
325
333
|
for arg, value in args.items():
|
|
326
334
|
if not arg:
|
|
327
|
-
raise ValueError(
|
|
335
|
+
raise ValueError(
|
|
336
|
+
f"Argument {arg} is cannot be empty (got {value})")
|
|
328
337
|
|
|
329
338
|
|
|
330
339
|
def reformat_time_string(input_str: str) -> str:
|
|
@@ -342,12 +351,31 @@ def reformat_time_string(input_str: str) -> str:
|
|
|
342
351
|
|
|
343
352
|
@lru_cache(maxsize=1)
|
|
344
353
|
def get_ip_v4():
|
|
345
|
-
|
|
354
|
+
# Switched from ipv4.seeip.org to api.ipify.org to avoid SSL handshake issues with OpenSSL 3 in subprocess/multiprocessing environments.
|
|
355
|
+
# return requests.get('https://ipv4.seeip.org/jsonip').json()['ip']
|
|
356
|
+
default_ipv4 = "127.0.0.1"
|
|
357
|
+
try:
|
|
358
|
+
response = requests.get('https://api.ipify.org?format=json').json()
|
|
359
|
+
ipv4_address = response.get('ip', default_ipv4)
|
|
360
|
+
return ipv4_address
|
|
361
|
+
except requests.exceptions.SSLError:
|
|
362
|
+
logger.error("SSL Error while fetching IPv4 address. "
|
|
363
|
+
f"Defaulting to{default_ipv4}")
|
|
364
|
+
return default_ipv4
|
|
346
365
|
|
|
347
366
|
|
|
348
367
|
@lru_cache(maxsize=1)
|
|
349
368
|
def get_ip_v6():
|
|
350
|
-
return requests.get('https://api.seeip.org/jsonip').json()['ip']
|
|
369
|
+
# return requests.get('https://api.seeip.org/jsonip').json()['ip']
|
|
370
|
+
default_ipv6 = "::1"
|
|
371
|
+
try:
|
|
372
|
+
response = requests.get('https://api64.ipify.org?format=json').json()
|
|
373
|
+
ipv6_address = response.get('ip', default_ipv6)
|
|
374
|
+
return ipv6_address
|
|
375
|
+
except requests.exceptions.SSLError:
|
|
376
|
+
logger.error("SSL Error while fetching IPv6 address. "
|
|
377
|
+
f"Defaulting to {default_ipv6}")
|
|
378
|
+
return default_ipv6
|
|
351
379
|
|
|
352
380
|
|
|
353
381
|
def snake_to_camel(snake_str: str) -> str:
|
|
@@ -363,7 +391,7 @@ def camel_to_snake(camel_str: str) -> str:
|
|
|
363
391
|
return snake_str
|
|
364
392
|
|
|
365
393
|
|
|
366
|
-
def strtobool(val):
|
|
394
|
+
def strtobool(val) -> bool:
|
|
367
395
|
"""Convert a string representation of truth to true (1) or false (0).
|
|
368
396
|
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
|
|
369
397
|
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
|
|
@@ -378,3 +406,21 @@ def strtobool(val):
|
|
|
378
406
|
return 0
|
|
379
407
|
else:
|
|
380
408
|
raise ValueError("invalid truth value %r" % (val,))
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
def is_debug() -> bool:
|
|
412
|
+
"""
|
|
413
|
+
Check if the application is running in debug mode.
|
|
414
|
+
Returns True if DEBUG environment variable is set to 'true', '1', or 't'.
|
|
415
|
+
"""
|
|
416
|
+
|
|
417
|
+
is_debug_result = strtobool(our_get_env("DEBUG", "false"))
|
|
418
|
+
|
|
419
|
+
if is_debug_result:
|
|
420
|
+
logger.info("Debug mode is enabled.")
|
|
421
|
+
|
|
422
|
+
return is_debug_result
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
if __name__ == "__main__":
|
|
426
|
+
is_debug()
|
|
@@ -7,7 +7,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
|
|
|
7
7
|
# python -m build needs pyproject.toml or setup.py
|
|
8
8
|
setuptools.setup(
|
|
9
9
|
name=PACKAGE_NAME,
|
|
10
|
-
version='0.0.
|
|
10
|
+
version='0.0.149', # https://pypi.org/project/python-sdk-local/
|
|
11
11
|
author="Circles",
|
|
12
12
|
author_email="info@circlez.ai",
|
|
13
13
|
description="PyPI Package for Circles Python SDK Local Python",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/service_response.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/valid_json_versions.py
RENAMED
|
File without changes
|
{python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local/src/validate_environment.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/requires.txt
RENAMED
|
File without changes
|
{python_sdk_local-0.0.147 → python_sdk_local-0.0.149}/python_sdk_local.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|