atk-common 1.30.0__py3-none-any.whl → 1.32.0__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.
atk_common/__init__.py CHANGED
@@ -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',
@@ -1,4 +1,5 @@
1
- from datetime import datetime, timezone
1
+ from datetime import datetime, timezone, timedelta
2
+ from zoneinfo import ZoneInfo
2
3
 
3
4
  def get_utc_date_time():
4
5
  return str(datetime.now(timezone.utc))
@@ -10,3 +11,49 @@ def get_utc_date_from_iso(date_time):
10
11
  dt = datetime.fromisoformat(date_time)
11
12
  dt_utc = dt.astimezone(timezone.utc)
12
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]
@@ -6,6 +6,7 @@ from atk_common.enums.certificate_issuer_enum import CertificateIssuer
6
6
  from atk_common.enums.command_status_type_enum import CommandStatusType
7
7
  from atk_common.enums.detection_status_type_enum import DetectionStatusType
8
8
  from atk_common.enums.encryption_type_enum import EncryptionType
9
+ from atk_common.enums.file_exists_enum import FileExists
9
10
  from atk_common.enums.history_status_type_enum import HistoryStatusType
10
11
  from atk_common.enums.image_encoding_type_enum import ImageEncodingType
11
12
  from atk_common.enums.image_part_category_enum import ImagePartCategory
@@ -28,6 +29,7 @@ __all__ = [
28
29
  'CommandStatusType',
29
30
  'DetectionStatusType',
30
31
  'EncryptionType',
32
+ 'FileExists',
31
33
  'HistoryStatusType',
32
34
  'ImageEncodingType',
33
35
  'ImagePartCategory',
@@ -0,0 +1,5 @@
1
+ from enum import Enum
2
+
3
+ class FileExists(Enum):
4
+ FILEEXIST = 1
5
+ FILENOTEXIST = 2
@@ -0,0 +1,4 @@
1
+ def get_image_file_type(encoding):
2
+ if (encoding == 'Raw'):
3
+ return '.ATKIMAGE'
4
+ return '.jpg'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atk_common
3
- Version: 1.30.0
3
+ Version: 1.32.0
4
4
  Summary: ATK common methods
5
5
  Home-page: https://github.com/pypa/atk_common
6
6
  Author: Roger
@@ -1,15 +1,16 @@
1
- atk_common/__init__.py,sha256=G2r5JTcOHLwHFrvpLC4L-t3JlilWQq8-oSDMeUF3AYA,1360
2
- atk_common/datetime_utils.py,sha256=tMXB3ZuRG8GyA25YLaNXhs4cVHF5zWdw9fXOh0Z9kQw,379
1
+ atk_common/__init__.py,sha256=OuZhyf-yBBSnpTnwg5Mr8OOwAXFvv3zr4_B-9w5hdhk,1531
2
+ atk_common/datetime_utils.py,sha256=3OIzPCt7W3vA4HvjnlfV0KJjRAjXuTaJ_QOa-cCMNns,2044
3
3
  atk_common/db_utils.py,sha256=odUtXcS7Mumw5eGyVyVimL_U_lP7TqMX9v8nWO5nMvg,902
4
4
  atk_common/docker_utils.py,sha256=nkUhp2OhwJsm41JDujHDY-JxQfdDjy91duprH59Esfk,2084
5
5
  atk_common/env_utils.py,sha256=66v-S0vlkJNaun6ay1XcOGRtYJb4Ce4odJsWxuaHsQc,373
6
6
  atk_common/error_utils.py,sha256=7SN-Jz3i2MGIPqsexnjgbZg5poMnALLEiCJQ4za5im4,2398
7
+ atk_common/file_utils.py,sha256=UDwcRquO9IrqRrlUM0t-_g4R1-FKt8ZqQinSEqXOAk8,112
7
8
  atk_common/http_utils.py,sha256=M1Qz2Cus3Ek8nUOqraT-30GKSj7nkAvJx2f7rnpX5Pk,656
8
9
  atk_common/log_utils.py,sha256=k7VaknmSGvHQV6-eznltNUa3BOAywjFHkhVzDT1P0Hs,496
9
10
  atk_common/mq_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
11
  atk_common/rabbitmq_consumer.py,sha256=4MhuwZs47Jt1fX4sUxr1MKRe7o2QRbPe9_utXEsa8QE,1907
11
12
  atk_common/response_utils.py,sha256=tGnIbPRbRwPRSN-Oii18S0jwBcKWqspjjYVkxU7JjOc,362
12
- atk_common/enums/__init__.py,sha256=aY-N-fCLOTP1d5wOng-gNMKH9kYNW5Shouu9a8SXoc4,1901
13
+ atk_common/enums/__init__.py,sha256=BNjTua9I3tkGzZKdI5QZTTXrQWia3OtRHo39TjAx9FY,1978
13
14
  atk_common/enums/api_error_type_enum.py,sha256=9oW6ZaZ3lhMwR8r2sVNWGliS9C_jV-otiOYdezAuTp0,91
14
15
  atk_common/enums/camera_cabinet_type_enum.py,sha256=U2NVrsTCBgaMRwYJamnjshAW8Y7xlOVjvUzakdgVH9A,90
15
16
  atk_common/enums/camera_role_enum.py,sha256=E0TH6zXj5EA889D7UndGP7xsgg5W23SneqJCFkA6BII,82
@@ -19,6 +20,7 @@ atk_common/enums/command_status_type_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087
19
20
  atk_common/enums/detection_status_enum.py,sha256=852t9-LaQAzcTELtHtiGPfgwhX58q4uWMvgzq2Spyzs,84
20
21
  atk_common/enums/detection_status_type_enum.py,sha256=oHmoOP2zhcWQBBchj7CwECf99EdT8QSY6T8l5n8Kvcg,88
21
22
  atk_common/enums/encryption_type_enum.py,sha256=jlrKeH2-Iakkuby8pwq8uXhX8A2FTvdULe633edGOc4,91
23
+ atk_common/enums/file_exists_enum.py,sha256=5qAl-bHzFwArxE5sVRFsteyg6eCsgi-SVrO72A_hzpY,92
22
24
  atk_common/enums/history_status_type_enum.py,sha256=itxQEQL8zQhkCR-fzKk3PcMDN1YcrbrcDlLcNCQDNHs,152
23
25
  atk_common/enums/http_status_enum.py,sha256=bJSTmkLxHnb04fWSDKuhTWrh_v9iCQM7otAVr731JDk,139
24
26
  atk_common/enums/image_encoding_type_enum.py,sha256=s32PjcrprGUf7MG4UQNE3ssH-y9RiLtbwtNwKQxWMvE,98
@@ -39,7 +41,7 @@ atk_common/enums/sensor_type_enum.py,sha256=UBa3LPyGTKgEJV578CqFlwXjnlXqVlybrvzd
39
41
  atk_common/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
40
42
  atk_common/enums/speed_control_status_type_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
41
43
  atk_common/enums/violation_type_enum.py,sha256=01qTHOj-O8bOc-nwIHVnxLosm4cusD_YuqXM3ZsiRRk,86
42
- atk_common-1.30.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
44
+ atk_common-1.32.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
43
45
  atk_package/__init__.py,sha256=EceDa352WFHTdC_LxYANXf_TS9pGzK3MCx87bwAKTvg,811
44
46
  atk_package/datetime_utils.py,sha256=qsVF7l90P1-xukG2tV_jLqG9J_Yfl5wTpyfrdPBlyMo,239
45
47
  atk_package/env_utils.py,sha256=bXOrxM3fZUslqfmZt75iphbEJHbG4riJa8XOVzPwIII,313
@@ -52,7 +54,7 @@ atk_package/enums/__init__.py,sha256=EtUr_--MQj1Rc_R0sF_ELXIThmhpfmhDWq3YaK9oQMk
52
54
  atk_package/enums/command_status_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087JhkU6Fmard5qVHs,127
53
55
  atk_package/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
54
56
  shared_python_atk_enforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- atk_common-1.30.0.dist-info/METADATA,sha256=VtCMZuZzh9HMtrZ43VKDH3w71hhSdIxqfu5JU85yOaU,1464
56
- atk_common-1.30.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
57
- atk_common-1.30.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
58
- atk_common-1.30.0.dist-info/RECORD,,
57
+ atk_common-1.32.0.dist-info/METADATA,sha256=nv254KC22GIHtb9mad2VvccKYMpZm6f14DYpN3gf4kU,1464
58
+ atk_common-1.32.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
59
+ atk_common-1.32.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
60
+ atk_common-1.32.0.dist-info/RECORD,,