atomicshop 2.11.14__py3-none-any.whl → 2.11.16__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.11.14'
4
+ __version__ = '2.11.16'
atomicshop/process.py CHANGED
@@ -163,7 +163,13 @@ def execute_in_new_window(
163
163
  return executed_process
164
164
 
165
165
 
166
- def execute_script(script: str, check: bool = True, shell: bool = False):
166
+ def execute_script(
167
+ script: str,
168
+ check: bool = True,
169
+ shell: bool = False,
170
+ executable: str = None,
171
+ as_regular_user: bool = False
172
+ ):
167
173
  """
168
174
  The function executes a batch script bash on Linux or CMD.exe on Windows.
169
175
  :param script: string, script to execute.
@@ -184,15 +190,28 @@ def execute_script(script: str, check: bool = True, shell: bool = False):
184
190
  'cd' is shell-specific functionality.
185
191
  Without shell=True, the Python subprocess module would not understand the command "cd <directory>" as it's
186
192
  not an executable but a shell built-in command.
193
+ :param executable: string, the executable that will be used to run the script.
194
+ If not provided, the default shell will be used.
195
+ :param as_regular_user: boolean, if True, the script will be executed as a regular user with:
196
+ 'sudo -u <username> <script>'
197
+ but in this context as:
198
+ 'sudo -u {os.getlogin()} <script>'
199
+ This is useful when you want to execute a script as a regular user, but you are running the script with sudo.
200
+ Sometimes even if you try to use os.setuid() to change the user, it will not work, since the script is executed
201
+ with sudo.
187
202
  :return: None if execution was successful, subprocess.CalledProcessError string if not.
188
203
  """
189
204
 
190
- if os.name == 'nt':
191
- executable = 'cmd.exe'
192
- elif os.name == 'posix':
193
- executable = '/bin/bash'
194
- else:
195
- raise OSError(f'OS not supported: {os.name}')
205
+ if not executable:
206
+ if os.name == 'nt':
207
+ executable = 'cmd.exe'
208
+ elif os.name == 'posix':
209
+ executable = '/bin/bash'
210
+ else:
211
+ raise OSError(f'OS not supported: {os.name}')
212
+
213
+ if as_regular_user:
214
+ script = f'sudo -u {os.getlogin()} {script}'
196
215
 
197
216
  try:
198
217
  subprocess.run(script, check=check, shell=shell, executable=executable)
@@ -121,7 +121,7 @@ def install_docker_ubuntu(
121
121
  sudo apt-get update
122
122
 
123
123
  # Step 2: Install the Docker packages
124
- sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
124
+ sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
125
125
 
126
126
  # Step 3: Verify the installation
127
127
  # sudo docker run hello-world
@@ -139,7 +139,7 @@ def install_docker_ubuntu(
139
139
 
140
140
  with permissions.temporary_regular_permissions():
141
141
  # After 'get-docker.sh' execution, we will install docker in rootless mode.
142
- process.execute_script('dockerd-rootless-setuptool.sh install', shell=True)
142
+ process.execute_script('dockerd-rootless-setuptool.sh install', shell=True, as_regular_user=True)
143
143
 
144
144
  # # Start and enable the docker service in user mode.
145
145
  # ubuntu_terminal.start_enable_service_check_availability('docker.service', user_mode=True, sudo=False)
@@ -148,7 +148,8 @@ def install_docker_ubuntu(
148
148
  subprocess.run(['sudo', 'loginctl', 'enable-linger', os.getlogin()], shell=True)
149
149
 
150
150
  # Add $HOME/bin to your PATH if it's not already there.
151
- ubuntu_terminal.add_path_to_bashrc()
151
+ with permissions.temporary_regular_permissions():
152
+ ubuntu_terminal.add_path_to_bashrc()
152
153
 
153
154
  if add_current_user_to_docker_group_bool:
154
155
  # Check if current user that executed the script is a sudo user. If not, use the current user.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.11.14
3
+ Version: 2.11.16
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=-Iv9wTs_77MOM4m3nu0VxFmmIxJpXdPOYoc5vKsgJEY,124
1
+ atomicshop/__init__.py,sha256=eAsq_cjIOGhh6JncibhUbypzp2z_j4OpMwx5qdL_uTY,124
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
@@ -24,7 +24,7 @@ atomicshop/keyboard_press.py,sha256=1W5kRtOB75fulVx-uF2yarBhW0_IzdI1k73AnvXstk0,
24
24
  atomicshop/pbtkmultifile_argparse.py,sha256=aEk8nhvoQVu-xyfZosK3ma17CwIgOjzO1erXXdjwtS4,4574
25
25
  atomicshop/permissions.py,sha256=y63kcxU6GAmnVXqWhs_N29XorOD2xYWlK_CjZ1PpHgA,2897
26
26
  atomicshop/print_api.py,sha256=DhbCQd0MWZZ5GYEk4oTu1opRFC-b31g1VWZgTGewG2Y,11568
27
- atomicshop/process.py,sha256=iP9H9Tr51o98REVjcFJ8D0BJUcjRpOVsD9yaEWoJ_h4,14686
27
+ atomicshop/process.py,sha256=_aDmnQBwpQAD6LO5VPGFFQxkywq5gK7m8N9Z_FHwdDo,15535
28
28
  atomicshop/process_name_cmd.py,sha256=TNAK6kQZm5JKWzEW6QLqVHEG98ZLNDQiSS4YwDk8V8c,3830
29
29
  atomicshop/process_poller.py,sha256=WfmwCLALfTYOq8ri0vkPeqq8ruEyA_43DaN--CU2_XY,10854
30
30
  atomicshop/python_file_patcher.py,sha256=kd3rBWvTcosLEk-7TycNdfKW9fZbe161iVwmH4niUo0,5515
@@ -164,7 +164,7 @@ atomicshop/wrappers/ctyping/msi_windows_installer/extract_msi_main.py,sha256=eyF
164
164
  atomicshop/wrappers/ctyping/msi_windows_installer/tables.py,sha256=ajiFiLXl1prg2kOhatfT8E2RKX7F8JjUJpwkVuKu1GY,16263
165
165
  atomicshop/wrappers/dockerw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
166
  atomicshop/wrappers/dockerw/dockerw.py,sha256=w8zSJr5C7cbvbuG09ORCpAe0BOcibqqL_Z2EKEBHYK4,6266
167
- atomicshop/wrappers/dockerw/install_docker.py,sha256=_F2dGMgsywR0gdQn8LNYELyJtIjjxs-Qw4QArrdoUpE,7478
167
+ atomicshop/wrappers/dockerw/install_docker.py,sha256=SFA2LYVE0uwILGe8SeIRm-3taqEXCWwQNZVNyn-T4UU,7589
168
168
  atomicshop/wrappers/elasticsearchw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
169
169
  atomicshop/wrappers/elasticsearchw/config_basic.py,sha256=fDujtrjEjbWiYh_WQ3OcYp_8mXhXPYeKLy4wSPL5qM0,1177
170
170
  atomicshop/wrappers/elasticsearchw/elasticsearchw.py,sha256=7TqFdEFznO8NlligJhEKk1vm641ALpCYdaRl1uoXdzM,9768
@@ -242,8 +242,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
242
242
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
243
243
  atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
244
244
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
245
- atomicshop-2.11.14.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
246
- atomicshop-2.11.14.dist-info/METADATA,sha256=Q8g2O2SjKgyHypZR5sdhX6agrS9EAm4UWmnFcx-hXMc,10448
247
- atomicshop-2.11.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
248
- atomicshop-2.11.14.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
249
- atomicshop-2.11.14.dist-info/RECORD,,
245
+ atomicshop-2.11.16.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
246
+ atomicshop-2.11.16.dist-info/METADATA,sha256=Bq1ANFEtTCbncyJJmsul1ibe66c7CCRby48oV1Qgk_s,10448
247
+ atomicshop-2.11.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
248
+ atomicshop-2.11.16.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
249
+ atomicshop-2.11.16.dist-info/RECORD,,