atomicshop 2.11.20__py3-none-any.whl → 2.11.22__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.20'
4
+ __version__ = '2.11.22'
atomicshop/process.py CHANGED
@@ -8,6 +8,7 @@ import shutil
8
8
  from .print_api import print_api
9
9
  from .inspect_wrapper import get_target_function_default_args_and_combine_with_current
10
10
  from .basics.strings import match_pattern_against_string
11
+ from .wrappers import ubuntu_terminal
11
12
 
12
13
  if os.name == 'nt':
13
14
  from .process_poller import GetProcessList
@@ -211,7 +212,7 @@ def execute_script(
211
212
  raise OSError(f'OS not supported: {os.name}')
212
213
 
213
214
  if as_regular_user:
214
- script = f'su {os.getlogin()} -c "/bin/bash {script}"'
215
+ script = ubuntu_terminal.get_command_execution_as_sudo_executer(script)
215
216
  # script = f'sudo -u {os.getlogin()} {script}'
216
217
 
217
218
  try:
@@ -134,16 +134,28 @@ def install_docker_ubuntu(
134
134
 
135
135
  if rootless:
136
136
  # Install uidmap package.
137
- ubuntu_terminal.update_system_packages()
138
- ubuntu_terminal.install_packages(['uidmap'])
137
+ if not ubuntu_terminal.is_executable_exists('uidmap'):
138
+ print_api('uidmap is not installed, installing...', color='yellow')
139
+ ubuntu_terminal.update_system_packages()
140
+ ubuntu_terminal.install_packages(['uidmap'])
139
141
 
140
142
  with permissions.temporary_regular_permissions():
141
143
  # After 'get-docker.sh' execution, we will install docker in rootless mode.
142
144
  # process.execute_script('dockerd-rootless-setuptool.sh install', shell=True, as_regular_user=True)
143
- process.execute_script('/usr/bin/dockerd-rootless-setuptool.sh install', as_regular_user=True, executable=None)
145
+ process.execute_script(
146
+ '/usr/bin/dockerd-rootless-setuptool.sh install',
147
+ as_regular_user=True,
148
+ shell=True,
149
+ executable=None)
144
150
 
145
151
  # Start and enable the docker service in user mode.
146
- ubuntu_terminal.start_enable_service_check_availability('docker.service', user_mode=True, sudo=False)
152
+ docker_start_command = ubuntu_terminal.get_command_execution_as_sudo_executer(
153
+ 'systemctl --user start docker.service')
154
+ docker_enable_command = ubuntu_terminal.get_command_execution_as_sudo_executer(
155
+ 'systemctl --user enable docker.service')
156
+ process.execute_script(docker_start_command, shell=True, executable=None)
157
+ process.execute_script(docker_enable_command, shell=True, executable=None)
158
+
147
159
  input("Press Enter to continue...")
148
160
 
149
161
  with permissions.temporary_regular_permissions():
@@ -13,11 +13,11 @@ def is_elastic_service_running():
13
13
 
14
14
 
15
15
  def enable_elastic_service():
16
- ubuntu_terminal.enable_service(config_basic.UBUNTU_ELASTIC_SERVICE_NAME)
16
+ ubuntu_terminal.enable_service(config_basic.UBUNTU_ELASTIC_SERVICE_NAME, sudo=True)
17
17
 
18
18
 
19
19
  def start_elastic_service():
20
- ubuntu_terminal.start_service(config_basic.UBUNTU_ELASTIC_SERVICE_NAME)
20
+ ubuntu_terminal.start_service(config_basic.UBUNTU_ELASTIC_SERVICE_NAME, sudo=True)
21
21
 
22
22
 
23
23
  def is_kibana_service_running():
@@ -25,11 +25,11 @@ def is_kibana_service_running():
25
25
 
26
26
 
27
27
  def enable_kibana_service():
28
- ubuntu_terminal.enable_service(config_basic.UBUNTU_KIBANA_SERVICE_NAME)
28
+ ubuntu_terminal.enable_service(config_basic.UBUNTU_KIBANA_SERVICE_NAME, sudo=True)
29
29
 
30
30
 
31
31
  def start_kibana_service():
32
- ubuntu_terminal.start_service(config_basic.UBUNTU_KIBANA_SERVICE_NAME)
32
+ ubuntu_terminal.start_service(config_basic.UBUNTU_KIBANA_SERVICE_NAME, sudo=True)
33
33
 
34
34
 
35
35
  def start_elastic_and_check_service_availability(wait_time_seconds: float = 30, exit_on_error: bool = True):
@@ -103,7 +103,7 @@ def is_service_running(service_name: str, user_mode: bool = False, return_false_
103
103
  return False
104
104
 
105
105
 
106
- def enable_service(service_name: str, sudo: bool = True, user_mode: bool = False):
106
+ def enable_service(service_name: str, sudo: bool = False, user_mode: bool = False):
107
107
  """
108
108
  Function enables a service.
109
109
  :param service_name: str, the service name.
@@ -127,7 +127,7 @@ def enable_service(service_name: str, sudo: bool = True, user_mode: bool = False
127
127
  subprocess.check_call(command)
128
128
 
129
129
 
130
- def start_service(service_name: str, sudo: bool = True, user_mode: bool = False):
130
+ def start_service(service_name: str, sudo: bool = False, user_mode: bool = False):
131
131
  """
132
132
  Function starts a service.
133
133
  :param service_name: str, the service name.
@@ -226,3 +226,25 @@ def add_path_to_bashrc(as_regular_user: bool = False):
226
226
  print("Added $HOME/bin to .bashrc")
227
227
  else:
228
228
  print("$HOME/bin already in .bashrc")
229
+
230
+
231
+ def get_command_execution_as_sudo_executer(command: str) -> str:
232
+ """
233
+ Function gets the command execution as the sudo executer.
234
+ The input command should be without 'sudo', if it will be, it will be omitted.
235
+ :param command: str, the command to execute.
236
+ :return: str, the command execution as the sudo executer.
237
+ """
238
+
239
+ if command.startswith('sudo'):
240
+ if command.startswith('sudo -'):
241
+ raise ValueError("The command should not start with 'sudo -'.")
242
+
243
+ command = command.replace('sudo ', '').strip()
244
+
245
+ sudo_executer_username: str = permissions.get_ubuntu_sudo_executer_username()
246
+
247
+ if sudo_executer_username:
248
+ return f'su {sudo_executer_username} -c "/bin/bash {command}"'
249
+ else:
250
+ return command
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.11.20
3
+ Version: 2.11.22
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=V79fHx0ezrqmMcreL64BopGTi3hRURr5mDw33_dU_Yw,124
1
+ atomicshop/__init__.py,sha256=J9VEZPOpY7bpVVAApDulvQp5NP0oPKwgRo2d7A0Py4w,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=tKIluW-p3ThLh1H3QEFgPFRVzw5hafAHk9QJ5OOT_0M,3047
26
26
  atomicshop/print_api.py,sha256=DhbCQd0MWZZ5GYEk4oTu1opRFC-b31g1VWZgTGewG2Y,11568
27
- atomicshop/process.py,sha256=vBsu1Bc_RQ0zCkz2mQ2GsCCvdEpP4nPdf9OPhrD2-hU,15614
27
+ atomicshop/process.py,sha256=kOLrpUb5T5QN9ZvpGOjXyo7Kivrc14A9gcw9lvNMidI,15670
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
@@ -151,7 +151,7 @@ atomicshop/wrappers/olefilew.py,sha256=biD5m58rogifCYmYhJBrAFb9O_Bn_spLek_9HofLe
151
151
  atomicshop/wrappers/pipw.py,sha256=iq4pDhmrHqKbcRi3Y6_v2PQSdb4fqfAx79rsX7JEmXo,801
152
152
  atomicshop/wrappers/process_wrapper_pbtk.py,sha256=ycPmBRnv627RWks6N8OhxJQe8Gu3h3Vwj-4HswPOw0k,599
153
153
  atomicshop/wrappers/pyopensslw.py,sha256=OBWxA6EJ2vU_Qlf4M8m6ilcG3hyYB4yB0EsXUf7NhEU,6804
154
- atomicshop/wrappers/ubuntu_terminal.py,sha256=zKSp5d8aBLHQwFg2P9zYVEM1g5_zp3ctFUs3O9Vh5Bc,7533
154
+ atomicshop/wrappers/ubuntu_terminal.py,sha256=7CKKO700dM6GR2S_6j9lnYWlk94JudzjloAJkFTsw9U,8324
155
155
  atomicshop/wrappers/wslw.py,sha256=AKphiHLSddL7ErevUowr3f9Y1AgGz_R3KZ3NssW07h8,6959
156
156
  atomicshop/wrappers/certauthw/certauth.py,sha256=hKedW0DOWlEigSNm8wu4SqHkCQsGJ1tJfH7s4nr3Bk0,12223
157
157
  atomicshop/wrappers/certauthw/certauthw.py,sha256=4WvhjANI7Kzqrr_nKmtA8Kf7B6rute_5wfP65gwQrjw,8082
@@ -164,11 +164,11 @@ 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=0K4IokanBOXz5QpZgiysSrwD7ppegqP6S0gL4LoSUrc,7987
167
+ atomicshop/wrappers/dockerw/install_docker.py,sha256=zq94ojAFrrmPX_B1eczxGTMST2x9y6J6Ry9yxHaTmcE,8565
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
171
- atomicshop/wrappers/elasticsearchw/infrastructure.py,sha256=aQZpPNN6mcBR5K5iOX-pLV3GJJhmkj5IqbTwkzKKSYE,10261
171
+ atomicshop/wrappers/elasticsearchw/infrastructure.py,sha256=lhG83BF5uXnbPxOUeNb8vJX1rOffuCnF6uAwJ8mh8Ro,10305
172
172
  atomicshop/wrappers/elasticsearchw/install_elastic.py,sha256=IhbapWeq5am-MtmnvKBNBPzvaL338rvfG0rbSpl8azE,8620
173
173
  atomicshop/wrappers/elasticsearchw/queries/__init__.py,sha256=KBjT-bAt75CJsx1Apko9mpuFU4pfZV8DcGWQvpX65RU,78
174
174
  atomicshop/wrappers/elasticsearchw/queries/aggregation.py,sha256=N9a5yMMnb10sMa_x1qJBFQpgyJ49UWo8_vxuqmUtZ1A,1742
@@ -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.20.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
246
- atomicshop-2.11.20.dist-info/METADATA,sha256=njGzCvxerN2aR2967GNSs37Qn0VW9S1pe8JPUl8hmgQ,10448
247
- atomicshop-2.11.20.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
248
- atomicshop-2.11.20.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
249
- atomicshop-2.11.20.dist-info/RECORD,,
245
+ atomicshop-2.11.22.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
246
+ atomicshop-2.11.22.dist-info/METADATA,sha256=3-5riYcQBh8JJ66yZWuB3Zb0PepN5aGqmJjLjRkV8q4,10448
247
+ atomicshop-2.11.22.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
248
+ atomicshop-2.11.22.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
249
+ atomicshop-2.11.22.dist-info/RECORD,,