atomicshop 2.9.31__py3-none-any.whl → 2.9.33__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.9.31'
4
+ __version__ = '2.9.33'
atomicshop/filesystem.py CHANGED
@@ -61,14 +61,33 @@ FILE_NAME_REPLACEMENT_DICT: dict = {
61
61
  }
62
62
 
63
63
 
64
- def get_linux_home() -> str:
64
+ def get_home_directory(return_sudo_user: bool = False) -> str:
65
65
  """
66
- The function will return the home directory of the user on Linux.
66
+ Returns the home directory of the current user or the user who invoked sudo.
67
67
 
68
- :return: string, home directory of the user on Linux.
68
+ :param return_sudo_user: bool, if 'False', then the function will return the home directory of the user who invoked
69
+ sudo (if the script was invoked with sudo).
70
+ If 'True', then the function will return the home directory of the current user, doesn't matter if the script was
71
+ invoked with sudo or not, if so home directory of the sudo user will be returned.
69
72
  """
70
73
 
71
- return os.path.expanduser('~')
74
+ def return_home_directory_of_current_user():
75
+ """
76
+ Returns the home directory of the current user.
77
+ """
78
+ return os.path.expanduser('~')
79
+
80
+ # Check if the script is run using sudo
81
+ if 'SUDO_USER' in os.environ:
82
+ # If 'return_sudo_user' is set to 'True', return the home directory of the sudo user.
83
+ if return_sudo_user:
84
+ return_home_directory_of_current_user()
85
+ else:
86
+ # Get the home directory of the user who invoked sudo
87
+ return os.path.expanduser(f"~{os.environ['SUDO_USER']}")
88
+
89
+ # Get the current user's home directory
90
+ return return_home_directory_of_current_user()
72
91
 
73
92
 
74
93
  def create_empty_file(file_path: str) -> None:
@@ -54,7 +54,8 @@ def add_current_user_to_docker_group(print_kwargs: dict = None):
54
54
  print_api(f"User {current_user} was added to the docker group.", color='green', **(print_kwargs or {}))
55
55
  return True
56
56
  else:
57
- print_api(f"User {current_user} was not added to the docker group.", color='red', **(print_kwargs or {}))
57
+ print_api(f"User {current_user} was not added to the docker group. Try executing with sudo", color='red',
58
+ **(print_kwargs or {}))
58
59
  return False
59
60
 
60
61
 
File without changes
@@ -0,0 +1,49 @@
1
+ import subprocess
2
+ import getpass
3
+
4
+ from ... import process, filesystem, permissions
5
+ from ...print_api import print_api
6
+
7
+
8
+ def is_nodejs_installed():
9
+ """
10
+ The function will check if Node.js is installed.
11
+ :return: bool.
12
+ """
13
+
14
+ try:
15
+ # Run the command 'node -v'
16
+ result = subprocess.run(['node', '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
17
+
18
+ # Check if the command was successful
19
+ if result.returncode == 0:
20
+ message = f"Node.js installed. Version: {result.stdout.strip()}"
21
+ print_api(message, color='green')
22
+ return True
23
+ else:
24
+ print_api("Node.js is not installed.")
25
+ return False
26
+ except FileNotFoundError:
27
+ print_api("Node command not found. Node.js is not installed.")
28
+ return False
29
+
30
+
31
+ def install_nodejs_ubuntu():
32
+ """
33
+ The function will install Node.js on Ubuntu.
34
+ :return:
35
+ """
36
+
37
+ # Check if Node.js is already installed.
38
+ if is_nodejs_installed():
39
+ return
40
+
41
+ # Add the Node.js repository.
42
+ process.run_command(['curl', '-sL', 'https://deb.nodesource.com/setup_14.x', '-o', '/tmp/nodesource_setup.sh'])
43
+ process.run_command(['bash', '/tmp/nodesource_setup.sh'])
44
+
45
+ # Install Node.js
46
+ process.run_command(['apt-get', 'install', '-y', 'nodejs'])
47
+
48
+ # Check if Node.js is installed.
49
+ is_nodejs_installed()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.9.31
3
+ Version: 2.9.33
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=O5Mg1YEnyuMMxuHVeNFjAnoVWh4dxTDc5cBdnuTKNIU,123
1
+ atomicshop/__init__.py,sha256=xZ_X7wkuj9RC8hITqUIPCnbV_tPMEP3Ct3FVSt2GWdM,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
@@ -14,7 +14,7 @@ atomicshop/dns.py,sha256=bNZOo5jVPzq7OT2qCPukXoK3zb1oOsyaelUwQEyK1SA,2500
14
14
  atomicshop/domains.py,sha256=Rxu6JhhMqFZRcoFs69IoEd1PtYca0lMCG6F1AomP7z4,3197
15
15
  atomicshop/emails.py,sha256=I0KyODQpIMEsNRi9YWSOL8EUPBiWyon3HRdIuSj3AEU,1410
16
16
  atomicshop/file_types.py,sha256=-0jzQMRlmU1AP9DARjk-HJm1tVE22E6ngP2mRblyEjY,763
17
- atomicshop/filesystem.py,sha256=kMsAMp6ij1j1Qdd-T1H8A-5PYD6zH4cTLMwBnQoHgJ8,42791
17
+ atomicshop/filesystem.py,sha256=FFOEUZygGvPrIdedq4DVaXhMX2YFaFovB2xhDVMCgM4,43813
18
18
  atomicshop/functions.py,sha256=pK8hoCE9z61PtWCxQJsda7YAphrLH1wxU5x-1QJP-sY,499
19
19
  atomicshop/hashing.py,sha256=Le8qGFyt3_wX-zGTeQShz7L2HL_b6nVv9PnawjglyHo,3474
20
20
  atomicshop/http_parse.py,sha256=nrf2rZcprLqtW8HVrV7TCZ1iTBcWRRy-mXIlAOzcaJs,9703
@@ -154,7 +154,7 @@ atomicshop/wrappers/certauthw/certauthw.py,sha256=4WvhjANI7Kzqrr_nKmtA8Kf7B6rute
154
154
  atomicshop/wrappers/ctyping/process_winapi.py,sha256=QcXL-ETtlSSkoT8F7pYle97ubGWsjYp8cx8HxkVMgAc,2762
155
155
  atomicshop/wrappers/dockerw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
156
156
  atomicshop/wrappers/dockerw/dockerw.py,sha256=w8zSJr5C7cbvbuG09ORCpAe0BOcibqqL_Z2EKEBHYK4,6266
157
- atomicshop/wrappers/dockerw/install_docker.py,sha256=Jz0fVIVy2bAX-JNdiDaM4pDCiP3FQ7Kk-vK_3WyJ3gY,4756
157
+ atomicshop/wrappers/dockerw/install_docker.py,sha256=eF0raR1EO9Xk1MVH7CvtkFI2Fgu9zL12MIYV_1vPTQk,4799
158
158
  atomicshop/wrappers/elasticsearchw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
159
159
  atomicshop/wrappers/elasticsearchw/config_basic.py,sha256=XJMKKfDrUq9ZKxYnQ-xFJxSA51z31Nn4eB8_n_hryVk,800
160
160
  atomicshop/wrappers/elasticsearchw/elasticsearchw.py,sha256=7TqFdEFznO8NlligJhEKk1vm641ALpCYdaRl1uoXdzM,9768
@@ -198,6 +198,8 @@ atomicshop/wrappers/loggingw/handlers.py,sha256=qm5Fbu8eDmlstMduUe5nKUlJU5IazFkS
198
198
  atomicshop/wrappers/loggingw/loggers.py,sha256=DHOOTAtqkwn1xgvLHSkOiBm6yFGNuQy1kvbhG-TDog8,2374
199
199
  atomicshop/wrappers/loggingw/loggingw.py,sha256=v9WAseZXB50LluT9rIUcRvvevg2nLVKPgz3dbGejfV0,12151
200
200
  atomicshop/wrappers/loggingw/reading.py,sha256=xs7L6Jo-vedrhCVP7m-cJo0VhWmoSoK86avR4Tm0kG4,3675
201
+ atomicshop/wrappers/nodejsw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
202
+ atomicshop/wrappers/nodejsw/install_nodejs.py,sha256=an7zX_sEG4CF57tdeR3jldDSNnS8Z4vRfSY9y1OjF4g,1440
201
203
  atomicshop/wrappers/playwrightw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
202
204
  atomicshop/wrappers/playwrightw/_tryouts.py,sha256=l1BLkFsiIMNlgv7nfZd1XGEvXQkIQkIcg48__9OaC00,4920
203
205
  atomicshop/wrappers/playwrightw/base.py,sha256=WeRpx8otdXuKSr-BjY-uCJTze21kbPpfitoOjKQz5-g,9818
@@ -230,8 +232,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
230
232
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
231
233
  atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
232
234
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
233
- atomicshop-2.9.31.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
234
- atomicshop-2.9.31.dist-info/METADATA,sha256=vagp2i4LcpWDtUApxl9LyIO714mmSrkrpxhExdeXTIs,10423
235
- atomicshop-2.9.31.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
236
- atomicshop-2.9.31.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
237
- atomicshop-2.9.31.dist-info/RECORD,,
235
+ atomicshop-2.9.33.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
236
+ atomicshop-2.9.33.dist-info/METADATA,sha256=xhGDHuJiZxOFiXby5r0kKvwrMjy6bJN59Vx0ynMYkFU,10423
237
+ atomicshop-2.9.33.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
238
+ atomicshop-2.9.33.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
239
+ atomicshop-2.9.33.dist-info/RECORD,,