atk-common 1.29.0__tar.gz → 1.31.0__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.
- {atk_common-1.29.0 → atk_common-1.31.0}/PKG-INFO +1 -1
- {atk_common-1.29.0 → atk_common-1.31.0}/setup.py +1 -1
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/__init__.py +5 -1
- atk_common-1.31.0/src/atk_common/datetime_utils.py +59 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/db_utils.py +2 -3
- atk_common-1.31.0/src/atk_common/file_utils.py +4 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common.egg-info/PKG-INFO +1 -1
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common.egg-info/SOURCES.txt +1 -0
- atk_common-1.29.0/src/atk_common/datetime_utils.py +0 -12
- {atk_common-1.29.0 → atk_common-1.31.0}/README.md +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/license.txt +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/pyproject.toml +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/setup.cfg +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/docker_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/__init__.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/api_error_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/camera_cabinet_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/camera_role_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/certificate_issuer_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/command_status_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/detection_status_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/encryption_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/history_status_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/image_encoding_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/image_part_category_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/image_part_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/metering_direction_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/piezo_vehicle_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/process_status_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/response_status_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/section_role_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/sensor_order_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/sensor_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/speed_control_status_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/violation_type_enum.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/env_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/error_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/http_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/log_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/mq_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/rabbitmq_consumer.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/response_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common.egg-info/dependency_links.txt +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common.egg-info/requires.txt +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common.egg-info/top_level.txt +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/src/shared_python_atk_enforcement/__init__.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/tests/test_docker_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/tests/test_error_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/tests/test_http_utils.py +0 -0
- {atk_common-1.29.0 → atk_common-1.31.0}/tests/test_log_utils.py +0 -0
@@ -36,7 +36,7 @@ setup(
|
|
36
36
|
# For a discussion on single-sourcing the version across setup.py and the
|
37
37
|
# project code, see
|
38
38
|
# https://packaging.python.org/guides/single-sourcing-package-version/
|
39
|
-
version="1.
|
39
|
+
version="1.31.0", # Required
|
40
40
|
# This is a one-line description or tagline of what your project does. This
|
41
41
|
# corresponds to the "Summary" metadata field:
|
42
42
|
# https://packaging.python.org/specifications/core-metadata/#summary
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# __init__.py
|
2
|
-
from atk_common.datetime_utils import get_utc_date_time, seconds_to_utc_timestamp, get_utc_date_from_iso
|
2
|
+
from atk_common.datetime_utils import get_utc_date_time, seconds_to_utc_timestamp, get_utc_date_from_iso, adjust_millisescond, convert_to_utc
|
3
3
|
from atk_common.db_utils import sql, sql_with_record, convert_none_to_null, date_time_utc_column
|
4
4
|
from atk_common.env_utils import get_env_value
|
5
5
|
from atk_common.error_utils import get_message, create_error_log, get_error_entity, handle_error, get_response_error, get_error_type
|
6
6
|
from atk_common.http_utils import is_http_status_ok, is_http_status_internal, get_test_response
|
7
|
+
from atk_common.file_utils import get_image_file_type
|
7
8
|
from atk_common.log_utils import add_log_item, add_log_item_http
|
8
9
|
from atk_common.rabbitmq_consumer import RabbitMQConsumer
|
9
10
|
from atk_common.response_utils import create_response, is_response_ok
|
@@ -13,6 +14,8 @@ __all__ = [
|
|
13
14
|
'get_utc_date_time',
|
14
15
|
'seconds_to_utc_timestamp',
|
15
16
|
'get_utc_date_from_iso',
|
17
|
+
'adjust_millisescond',
|
18
|
+
'convert_to_utc',
|
16
19
|
'sql',
|
17
20
|
'sql_with_record',
|
18
21
|
'convert_none_to_null',
|
@@ -27,6 +30,7 @@ __all__ = [
|
|
27
30
|
'is_http_status_ok',
|
28
31
|
'is_http_status_internal',
|
29
32
|
'get_test_response',
|
33
|
+
'get_image_file_type',
|
30
34
|
'add_log_item',
|
31
35
|
'add_log_item_http',
|
32
36
|
'RabbitMQConsumer',
|
@@ -0,0 +1,59 @@
|
|
1
|
+
from datetime import datetime, timezone, timedelta
|
2
|
+
from zoneinfo import ZoneInfo
|
3
|
+
|
4
|
+
def get_utc_date_time():
|
5
|
+
return str(datetime.now(timezone.utc))
|
6
|
+
|
7
|
+
def seconds_to_utc_timestamp(seconds):
|
8
|
+
return str(datetime.fromtimestamp(seconds, tz=timezone.utc))
|
9
|
+
|
10
|
+
def get_utc_date_from_iso(date_time):
|
11
|
+
dt = datetime.fromisoformat(date_time)
|
12
|
+
dt_utc = dt.astimezone(timezone.utc)
|
13
|
+
return str(dt_utc.date())
|
14
|
+
|
15
|
+
def adjust_millisescond(dt_str):
|
16
|
+
if '.' in dt_str:
|
17
|
+
dt_part, frac = dt_str.split('.')
|
18
|
+
frac = frac[:6] # keep only the first 6 digits
|
19
|
+
dt_str_clean = f"{dt_part}.{frac}"
|
20
|
+
return dt_str_clean
|
21
|
+
else:
|
22
|
+
dt_str_clean = dt_str
|
23
|
+
return dt_str_clean
|
24
|
+
|
25
|
+
# Original datetime string, handles:
|
26
|
+
# dt_str = '2023-02-01T14:13:08.653133+01:00'
|
27
|
+
# dt_str = '2023-02-01T14:13:08.653133 01:00'
|
28
|
+
# dt_str = '2024-01-03T08:13:52.705474147'
|
29
|
+
def convert_to_utc(dt_str):
|
30
|
+
# Split datetime and offset
|
31
|
+
if '+' in dt_str:
|
32
|
+
parts = dt_str.split('+')
|
33
|
+
else:
|
34
|
+
parts = dt_str.split(' ')
|
35
|
+
if len(parts) == 2:
|
36
|
+
dt_part, offset_part = parts
|
37
|
+
else:
|
38
|
+
dt_part = parts[0]
|
39
|
+
offset_part = None # or set a default if needed
|
40
|
+
|
41
|
+
dt_part = adjust_millisescond(dt_part)
|
42
|
+
dt_naive = datetime.fromisoformat(dt_part)
|
43
|
+
|
44
|
+
if offset_part is None:
|
45
|
+
dt_aware = dt_naive.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
46
|
+
dt_utc = dt_aware.astimezone(ZoneInfo("UTC"))
|
47
|
+
return dt_utc.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
48
|
+
else:
|
49
|
+
# Create a timezone object using the offset
|
50
|
+
hours_offset = int(offset_part.split(':')[0])
|
51
|
+
minutes_offset = int(offset_part.split(':')[1])
|
52
|
+
tzinfo = timezone(timedelta(hours=hours_offset, minutes=minutes_offset))
|
53
|
+
|
54
|
+
# Assign the timezone to the datetime
|
55
|
+
dt_with_tz = dt_naive.replace(tzinfo=tzinfo)
|
56
|
+
|
57
|
+
# Convert to UTC
|
58
|
+
dt_utc =dt_with_tz.astimezone(timezone.utc)
|
59
|
+
return dt_utc.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
@@ -1,7 +1,5 @@
|
|
1
|
-
import psycopg2
|
2
|
-
from psycopg2.extras import RealDictCursor
|
3
|
-
|
4
1
|
def sql(connection, sql, get_one):
|
2
|
+
from psycopg2.extras import RealDictCursor
|
5
3
|
with connection:
|
6
4
|
with connection.cursor(cursor_factory=RealDictCursor) as cursor:
|
7
5
|
cursor.execute(sql)
|
@@ -10,6 +8,7 @@ def sql(connection, sql, get_one):
|
|
10
8
|
return cursor.fetchall()
|
11
9
|
|
12
10
|
def sql_with_record(connection, sql, record):
|
11
|
+
from psycopg2.extras import RealDictCursor
|
13
12
|
with connection:
|
14
13
|
with connection.cursor(cursor_factory=RealDictCursor) as cursor:
|
15
14
|
cursor.execute(sql, record)
|
@@ -1,12 +0,0 @@
|
|
1
|
-
from datetime import datetime, timezone
|
2
|
-
|
3
|
-
def get_utc_date_time():
|
4
|
-
return str(datetime.now(timezone.utc))
|
5
|
-
|
6
|
-
def seconds_to_utc_timestamp(seconds):
|
7
|
-
return str(datetime.fromtimestamp(seconds, tz=timezone.utc))
|
8
|
-
|
9
|
-
def get_utc_date_from_iso(date_time):
|
10
|
-
dt = datetime.fromisoformat(date_time)
|
11
|
-
dt_utc = dt.astimezone(timezone.utc)
|
12
|
-
return str(dt_utc.date())
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{atk_common-1.29.0 → atk_common-1.31.0}/src/atk_common/enums/speed_control_status_type_enum.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|