atomicshop 2.18.5__py3-none-any.whl → 2.18.6__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.

Potentially problematic release.


This version of atomicshop might be problematic. Click here for more details.

atomicshop/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '2.18.5'
4
+ __version__ = '2.18.6'
@@ -99,3 +99,52 @@ def expand_user_path(user_name, path):
99
99
  pwnam = pwd.getpwnam(user_name)
100
100
  home_dir = pwnam.pw_dir
101
101
  return path.replace("~", home_dir)
102
+
103
+
104
+ def set_folder_permissions(
105
+ folder_path: str,
106
+ username: str = None,
107
+ logged_in_non_sudo_user: bool = False
108
+ ):
109
+ """
110
+ Set ownership and permissions for an existing folder.
111
+
112
+ :param folder_path: Path to the folder (must already exist)
113
+ :param username: Username to assign ownership to (ignored if non_sudo_user=True)
114
+ :param logged_in_non_sudo_user: If True, use the current logged-in user unless running under sudo
115
+ """
116
+
117
+ if not username and not logged_in_non_sudo_user:
118
+ raise ValueError("A username must be provided, or 'non_sudo_user' must be set to True.")
119
+
120
+ # Handle non_sudo_user case
121
+ if logged_in_non_sudo_user:
122
+ # Get the current logged-in user
123
+ username = os.getlogin()
124
+
125
+ # Get the UID and GID of the specified user
126
+ user_info = pwd.getpwnam(username)
127
+ user_uid = user_info.pw_uid
128
+ user_gid = user_info.pw_gid
129
+
130
+ # Change ownership of the folder to the specified user
131
+ # print(f"Changing ownership of {folder_path} to user '{username}'...")
132
+ os.chown(folder_path, user_uid, user_gid)
133
+
134
+ # Set appropriate permissions (read, write, execute for the owner)
135
+ # print(f"Setting permissions for {folder_path}...")
136
+ os.chmod(folder_path, 0o755) # Owner rwx, group r-x, others r-x
137
+
138
+ # print(f"Ownership and permissions updated for folder: '{folder_path}'")
139
+
140
+
141
+ def is_directory_owner(directory_path: str, username: str) -> bool:
142
+ """
143
+ Function checks if the directory is owned by the specified user.
144
+ :param directory_path: str, path to the directory.
145
+ :param username: str, username of the user.
146
+ :return: bool, True / False.
147
+ """
148
+
149
+ uid = pwd.getpwnam(username).pw_uid
150
+ return os.stat(directory_path).st_uid == uid
@@ -25,13 +25,21 @@ def add_reusable_address_option(socket_instance):
25
25
  socket_instance.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
26
26
 
27
27
 
28
- def create_ssl_context_for_server():
28
+ def create_ssl_context_for_server() -> ssl.SSLContext:
29
29
  # Creating context with SSL certificate and the private key before the socket
30
30
  # https://docs.python.org/3/library/ssl.html
31
31
  # Creating context for SSL wrapper, specifying "PROTOCOL_TLS_SERVER" will pick the best TLS version protocol for
32
32
  # the server.
33
- return ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
33
+
34
+ ssl_context: ssl.SSLContext = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
35
+
36
+ # # Enforce the use of TLS 1.2 only (disable TLS 1.0, TLS 1.1, and TLS 1.3)
37
+ # ssl_context.options |= ssl.OP_NO_TLSv1 # Disable TLS 1.0
38
+ # ssl_context.options |= ssl.OP_NO_TLSv1_1 # Disable TLS 1.1
39
+ # ssl_context.options |= ssl.OP_NO_TLSv1_3 # Disable TLS 1.3
40
+
34
41
  # return ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
42
+ return ssl_context
35
43
 
36
44
 
37
45
  def create_ssl_context_for_client(
@@ -130,9 +138,9 @@ def load_certificate_and_key_into_server_ssl_context(
130
138
  print_api(message, error_type=True, logger_method="critical", **print_kwargs)
131
139
 
132
140
 
133
- def create_server_ssl_context___load_certificate_and_key(certificate_file_path: str, key_file_path):
141
+ def create_server_ssl_context___load_certificate_and_key(certificate_file_path: str, key_file_path) -> ssl.SSLContext:
134
142
  # Create and set ssl context for server.
135
- ssl_context = create_ssl_context_for_server()
143
+ ssl_context: ssl.SSLContext = create_ssl_context_for_server()
136
144
  # Load certificate into context.
137
145
  load_certificate_and_key_into_server_ssl_context(ssl_context, certificate_file_path, key_file_path)
138
146
  # Return ssl context only.
@@ -82,7 +82,7 @@ class SNISetup:
82
82
  ):
83
83
 
84
84
  # Create SSL Socket to wrap the raw socket with.
85
- ssl_context = creator.create_ssl_context_for_server()
85
+ ssl_context: ssl.SSLContext = creator.create_ssl_context_for_server()
86
86
 
87
87
  self.certificator_instance = certificator.Certificator(
88
88
  ca_certificate_name=self.ca_certificate_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.18.5
3
+ Version: 2.18.6
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -38,6 +38,8 @@ Requires-Dist: cryptography
38
38
  Requires-Dist: dnslib
39
39
  Requires-Dist: dnspython
40
40
  Requires-Dist: docker
41
+ Requires-Dist: google-api-python-client
42
+ Requires-Dist: google-generativeai
41
43
  Requires-Dist: numpy
42
44
  Requires-Dist: olefile
43
45
  Requires-Dist: openpyxl
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=djTLkiQczxSrBfseOQFp0kfiVNR7-UsGEJSqlifxWfA,123
1
+ atomicshop/__init__.py,sha256=MFXW2AXFnL4Ju9Vx1r8oICO19rBqtQx1mgjqa83ULSM,123
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
4
4
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
@@ -159,7 +159,7 @@ atomicshop/monitor/checks/process_running.py,sha256=x66wd6-l466r8sbRQaIli0yswyGt
159
159
  atomicshop/monitor/checks/url.py,sha256=1PvKt_d7wFg7rDMFpUejAQhj0mqWsmlmrNfjNAV2G4g,4123
160
160
  atomicshop/permissions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
161
161
  atomicshop/permissions/permissions.py,sha256=CYTDVOI0jh9ks0ZLnnOuPzppgCszFEc9-92DTkVTYi4,522
162
- atomicshop/permissions/ubuntu_permissions.py,sha256=nMmr8ywwS0or8qJdg4ztMeqB2vppE_aytQTRQrg6lFc,2842
162
+ atomicshop/permissions/ubuntu_permissions.py,sha256=bKxZ0hl6cIOJzU1AF8EaLyscQ957_eOe7lEw4UvqKhY,4634
163
163
  atomicshop/permissions/win_permissions.py,sha256=eDQm1jfK9x_hkbLqIJjFTwfqinAWQ0iSr0kW3XrF1BE,1272
164
164
  atomicshop/process_poller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
165
  atomicshop/process_poller/process_pool.py,sha256=4Qs427qd7OcBxu5PMFU5PTmyuxRy0vgj2GLsRt0IoEw,9565
@@ -305,13 +305,13 @@ atomicshop/wrappers/socketw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
305
305
  atomicshop/wrappers/socketw/accepter.py,sha256=hZZKVYlF3LOHQJsSIEKXZUf6QXXWm-AtqXZevvaYigE,1732
306
306
  atomicshop/wrappers/socketw/base.py,sha256=zYwFxiEzTcItFi1RZQCMxMTLBvECVUiKwivPYKcu44g,2713
307
307
  atomicshop/wrappers/socketw/certificator.py,sha256=mtWPJ_ew3OSwt0-1W4jaoco1VIY4NRCrMv3mDUxb_Cc,12418
308
- atomicshop/wrappers/socketw/creator.py,sha256=zMWLsOF07vX-xQZR720LeHQVndUT8q-ytdCrKF5tt9I,12835
308
+ atomicshop/wrappers/socketw/creator.py,sha256=aSwfN_IwXXf4Hob35vHXUxD_OPeshZcRDZU2hMyfKs0,13243
309
309
  atomicshop/wrappers/socketw/dns_server.py,sha256=RklzINNuoMQn4PGGQEI5hiAldprbVwwvikY6u9X-jTY,49067
310
310
  atomicshop/wrappers/socketw/exception_wrapper.py,sha256=B-X5SHLSUIWToihH2MKnOB1F4A81_X0DpLLfnYKYbEc,7067
311
311
  atomicshop/wrappers/socketw/get_process.py,sha256=aJC-_qFUv3NgWCSUzDI72E4z8_-VTZE9NVZ0CwUoNlM,5698
312
312
  atomicshop/wrappers/socketw/receiver.py,sha256=LRQO-RIY0ZRjSMGVHLVJAXFTVO1zvjgIKSefEngPFfc,8186
313
313
  atomicshop/wrappers/socketw/sender.py,sha256=aX_K8l_rHjd5AWb8bi5mt8-YTkMYVRDB6DnPqK_XDUE,4754
314
- atomicshop/wrappers/socketw/sni.py,sha256=Nc8WMZZR21o5GXILQLVWbf7OzNPXAfE8trJY153e9Qk,17591
314
+ atomicshop/wrappers/socketw/sni.py,sha256=T9PXROiTYYxrd_7X4Hoj9hoNPXXTQpa2HdvmBJJIoeA,17607
315
315
  atomicshop/wrappers/socketw/socket_client.py,sha256=oa3GwS4OPgokrJE5_Oc4-5_wlXHxSH9J5f2DKebms8k,22035
316
316
  atomicshop/wrappers/socketw/socket_server_tester.py,sha256=Qobmh4XV8ZxLUaw-eW4ESKAbeSLecCKn2OWFzMhadk0,6420
317
317
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=WtylpezgIIBuz-A6PfM0hO1sm9Exd4j3qhDXcFc74-E,35567
@@ -319,8 +319,8 @@ atomicshop/wrappers/socketw/ssl_base.py,sha256=kmiif84kMhBr5yjQW17p935sfjR5JKG0L
319
319
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh30KAV-jOpoFKT-m8,3395
320
320
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
321
321
  atomicshop/wrappers/winregw/winreg_network.py,sha256=zZQfps-CdODQaTUADbHAwKHr5RUg7BLafnKWBbKaLN4,8728
322
- atomicshop-2.18.5.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
323
- atomicshop-2.18.5.dist-info/METADATA,sha256=jFNipJDLDZS4YVzhPI5lVuaMh1xDHuH2Fohc6wyNjy8,10499
324
- atomicshop-2.18.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
325
- atomicshop-2.18.5.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
326
- atomicshop-2.18.5.dist-info/RECORD,,
322
+ atomicshop-2.18.6.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
323
+ atomicshop-2.18.6.dist-info/METADATA,sha256=sMVjybxEDSWZC48hrJM-Md_y3VH4v5p9UbmQEc1XdOg,10576
324
+ atomicshop-2.18.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
325
+ atomicshop-2.18.6.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
326
+ atomicshop-2.18.6.dist-info/RECORD,,