atomicshop 2.19.4__py3-none-any.whl → 2.19.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.19.4'
4
+ __version__ = '2.19.6'
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env python3
2
+ import sys
3
+
4
+ from atomicshop.wrappers.nodejsw import install_nodejs_ubuntu
5
+
6
+
7
+ def main():
8
+ install_nodejs_ubuntu.install_nodejs_main()
9
+
10
+
11
+ if __name__ == "__main__":
12
+ sys.exit(main())
@@ -0,0 +1,11 @@
1
+ import sys
2
+
3
+ from atomicshop.wrappers.nodejsw import install_nodejs_windows
4
+
5
+
6
+ def main():
7
+ install_nodejs_windows.install_nodejs_windows()
8
+
9
+
10
+ if __name__ == "__main__":
11
+ sys.exit(main())
@@ -5,6 +5,7 @@ import tempfile
5
5
  from atomicshop.print_api import print_api
6
6
  from atomicshop.wrappers import githubw
7
7
  from atomicshop.permissions import permissions
8
+ from atomicshop.wrappers.nodejsw import install_nodejs_windows
8
9
 
9
10
 
10
11
  WINDOWS_TESSERACT_DEFAULT_INSTALLATION_DIRECTORY: str = r"C:\Program Files\Tesseract-OCR"
@@ -14,7 +15,14 @@ def main():
14
15
  if not permissions.is_admin():
15
16
  print_api("Please run this script as an Administrator.", color="red")
16
17
  return 1
17
- """
18
+
19
+ if not install_nodejs_windows.is_nodejs_installed():
20
+ install_nodejs_windows.install_nodejs_windows()
21
+ install_nodejs_windows.add_nodejs_to_path()
22
+ if not install_nodejs_windows.is_nodejs_installed():
23
+ print_api("Node.js installation failed.")
24
+ return 1
25
+
18
26
  print_api("PIP Installing Robocorp.")
19
27
  subprocess.check_call(["pip", "install", "--upgrade", "rpaframework"])
20
28
 
@@ -43,7 +51,7 @@ def main():
43
51
 
44
52
  # The Admin needed to install Tesseract.
45
53
  subprocess.check_call([tesseract_installer, "/S"])
46
- """
54
+
47
55
  # Add Tesseract to the PATH.
48
56
  subprocess.check_call(["setx", "PATH", f"%PATH%;{WINDOWS_TESSERACT_DEFAULT_INSTALLATION_DIRECTORY}"])
49
57
 
@@ -1,5 +1,6 @@
1
1
  import subprocess
2
2
  import requests
3
+ import argparse
3
4
 
4
5
  from ...basics import booleans
5
6
  from .. import githubw, ubuntu_terminal
@@ -121,6 +122,46 @@ def install_nodejs_ubuntu(
121
122
  is_nodejs_installed()
122
123
 
123
124
 
125
+ def install_nodejs_main():
126
+ """
127
+ The function will install Node.js on Ubuntu.
128
+ :return:
129
+ """
130
+
131
+ # Create the parser.
132
+ parser = argparse.ArgumentParser(description="Install Node.js on Ubuntu.")
133
+ parser.add_argument(
134
+ '--latest',
135
+ action='store_true',
136
+ help="Install the latest version of Node.js."
137
+ )
138
+ parser.add_argument(
139
+ '--lts',
140
+ action='store_true',
141
+ help="Install the LTS version of Node.js."
142
+ )
143
+ parser.add_argument(
144
+ '--version',
145
+ type=str,
146
+ help="Install a specific version of Node.js."
147
+ )
148
+ parser.add_argument(
149
+ '--force',
150
+ action='store_true',
151
+ help="Force the installation of Node.js."
152
+ )
153
+
154
+ # Parse the arguments.
155
+ args = parser.parse_args()
156
+
157
+ install_nodejs_ubuntu(
158
+ install_latest_version=args.latest,
159
+ install_lts=args.lts,
160
+ install_by_version_number=args.version,
161
+ force_install=args.force
162
+ )
163
+
164
+
124
165
  def install_npm_package_ubuntu(package_name: str, sudo: bool = True):
125
166
  """
126
167
  The function will install a npm package on Ubuntu.
@@ -0,0 +1,180 @@
1
+ import subprocess
2
+ import os
3
+ import requests
4
+ import time
5
+ import tempfile
6
+
7
+ from ... import web
8
+ from ...permissions import permissions
9
+ from .. import msiw
10
+ from ...print_api import print_api
11
+
12
+
13
+ WINDOWS_X64_SUFFIX: str = "x64.msi"
14
+
15
+
16
+ class NodeJSWindowsInstallerNoVersionsFound(Exception):
17
+ pass
18
+
19
+
20
+ class NodeJSWindowsInstallerMoreThanOneVersionFound(Exception):
21
+ pass
22
+
23
+
24
+ class NodeJSWindowsInstallerFailedToExtractFileNameFromString(Exception):
25
+ pass
26
+
27
+
28
+ class NodeJSWindowsInstallerFailedToExtractVersionInString(Exception):
29
+ pass
30
+
31
+
32
+ def is_nodejs_installed():
33
+ """
34
+ Check if Node.js is installed by trying to run 'node -v'.
35
+ """
36
+ print_api("Checking if Node.js is installed...")
37
+ try:
38
+ try:
39
+ node_version = subprocess.check_output(["node", "-v"], text=True)
40
+ except FileNotFoundError:
41
+ print_api(f"node.exe is not found.", color="red")
42
+ raise
43
+
44
+ node_version = node_version.replace("\n", "")
45
+ print_api(f"node.exe is found. Version: {node_version}", color="green")
46
+
47
+ try:
48
+ npm_version = subprocess.check_output(["npm.cmd", "-v"], text=True).strip()
49
+ except FileNotFoundError:
50
+ print_api(f"npm.cmd is not found.", color="red")
51
+ raise
52
+
53
+ npm_version = npm_version.replace("\n", "")
54
+ print_api(f"npm.cmd is found. Version: {npm_version}", color="green")
55
+ print_api("Node.js is installed.")
56
+ return True
57
+ except FileNotFoundError:
58
+ print_api("Node.js is not installed.")
59
+ return False
60
+
61
+
62
+ def add_nodejs_to_path():
63
+ """
64
+ Add Node.js to the PATH for the current CMD session.
65
+ """
66
+ print_api("Adding Node.js to the PATH for the current session...")
67
+ # Get the installation directory from the default Node.js install path
68
+ program_files = os.environ.get("ProgramFiles", "C:\\Program Files")
69
+ nodejs_path = os.path.join(program_files, "nodejs")
70
+
71
+ if os.path.exists(nodejs_path):
72
+ print_api(f"Node.js installation found at: {nodejs_path}")
73
+ current_path = os.environ.get("PATH", "")
74
+ if nodejs_path not in current_path:
75
+ # Add Node.js to the PATH for the current process
76
+ os.environ["PATH"] = f"{nodejs_path};{current_path}"
77
+ print_api("Node.js has been added to the PATH for this session.")
78
+ else:
79
+ print_api("Node.js is already in the PATH.")
80
+ else:
81
+ print_api("Node.js installation directory not found.")
82
+
83
+
84
+ def get_latest_nodejs_version():
85
+ """
86
+ Fetch the latest Node.js version from the official Node.js website.
87
+ """
88
+ print_api("Fetching the latest Node.js version...")
89
+ url = "https://nodejs.org/dist/latest/SHASUMS256.txt"
90
+
91
+ response = requests.get(url, timeout=10)
92
+ response.raise_for_status()
93
+ # Parse the file for the Node.js version
94
+ found_versions: list = []
95
+ for line in response.text.splitlines():
96
+ if line.endswith(WINDOWS_X64_SUFFIX):
97
+ found_versions.append(line)
98
+
99
+ if not found_versions:
100
+ raise NodeJSWindowsInstallerNoVersionsFound("No Node.js versions found in [https://nodejs.org/dist/latest/SHASUMS256.txt]")
101
+ elif len(found_versions) > 1:
102
+ raise NodeJSWindowsInstallerMoreThanOneVersionFound(f"More than one Node.js version found:\n"
103
+ f"{'\n'.join(found_versions)}")
104
+
105
+ try:
106
+ file_name = found_versions[0].split(" ")[-1]
107
+ except IndexError:
108
+ raise NodeJSWindowsInstallerFailedToExtractFileNameFromString("Failed to extract the file name from the string.")
109
+
110
+ try:
111
+ version = file_name.replace("node-v", "").replace(f"-{WINDOWS_X64_SUFFIX}", "")
112
+ except Exception:
113
+ raise NodeJSWindowsInstallerFailedToExtractVersionInString("Failed to extract the version from the string.")
114
+
115
+ print_api(f"Latest Node.js version: {version}")
116
+ return version
117
+
118
+
119
+ def download_nodejs_installer(version):
120
+ """
121
+ Download the Node.js MSI installer for Windows.
122
+ """
123
+
124
+ version = f"v{version}"
125
+ nodejs_base_url = f"https://nodejs.org/dist/{version}/"
126
+ file_name = f"node-{version}-x64.msi"
127
+ download_url = nodejs_base_url + file_name
128
+ print_api(f"Downloading Node.js installer from: {download_url}")
129
+
130
+ # Make temporary directory to store the installer
131
+ temp_dir = tempfile.gettempdir()
132
+ temp_file_path = web.download(download_url, temp_dir)
133
+ return temp_file_path
134
+
135
+
136
+ def clean_up(installer_path):
137
+ """
138
+ Remove the installer file after installation.
139
+ """
140
+ try:
141
+ if os.path.exists(installer_path):
142
+ os.remove(installer_path)
143
+ print_api(f"Removed installer: {installer_path}")
144
+ except Exception as e:
145
+ print_api(f"Failed to clean up the installer: {e}")
146
+
147
+
148
+ def install_nodejs_windows() -> int:
149
+ """
150
+ Install Node.js on Windows.
151
+ If you're installing as part of a cmd script that continues and installs npm packages, you can do something like this:
152
+ if not install_nodejs_windows.is_nodejs_installed():
153
+ install_nodejs_windows.is_nodejs_installed()
154
+ install_nodejs_windows.install_nodejs_windows()
155
+ install_nodejs_windows.add_nodejs_to_path()
156
+ if not install_nodejs_windows.is_nodejs_installed():
157
+ print_api("Node.js installation failed.")
158
+ return 1
159
+ :return:
160
+ """
161
+ if not permissions.is_admin():
162
+ print_api("This script requires administrative privileges to install Node.js.")
163
+ return 1
164
+
165
+ print_api("Starting Node.js installation process...")
166
+ version = get_latest_nodejs_version()
167
+ if not version:
168
+ print_api("Exiting: Could not fetch the latest Node.js version.")
169
+ return 1
170
+
171
+ installer_path = download_nodejs_installer(version)
172
+ if not installer_path:
173
+ print_api("Exiting: Failed to download the Node.js installer.")
174
+ return 1
175
+
176
+ msiw.install_msi(installer_path, silent_progress_bar=True)
177
+ time.sleep(5) # Wait a few seconds for the installation to complete
178
+ clean_up(installer_path)
179
+ print_api("Installation process finished.")
180
+ return 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.19.4
3
+ Version: 2.19.6
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=2gEn2WdCk0RCwEWqqFtueCBw9uFygvrBG4hm-HaHdQU,123
1
+ atomicshop/__init__.py,sha256=knCj__YmUuoKs1yCpFlwbRugLxYK9EFx2UTKQEkbSTc,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
@@ -51,11 +51,13 @@ atomicshop/a_installs/ubuntu/docker_rootless.py,sha256=9IPNtGZYjfy1_n6ZRt7gWz9KZ
51
51
  atomicshop/a_installs/ubuntu/docker_sudo.py,sha256=JzayxeyKDtiuT4Icp2L2LyFRbx4wvpyN_bHLfZ-yX5E,281
52
52
  atomicshop/a_installs/ubuntu/elastic_search_and_kibana.py,sha256=yRB-l1zBxdiN6av-FwNkhcBlaeu4zrDPjQ0uPGgpK2I,244
53
53
  atomicshop/a_installs/ubuntu/mongodb.py,sha256=xuRJS1qqOZ0EZp7of5R3tTjSu6CwBIxYg8-NaM7othE,230
54
+ atomicshop/a_installs/ubuntu/nodejs.py,sha256=Iax55VJpT2HZsdRv-JvxkLg6JPYpJ-M8_r-wI5ES_yQ,222
54
55
  atomicshop/a_installs/ubuntu/pycharm.py,sha256=Ld7YQBwPxrjuZcTG1K4kZqjbBdt8aooCVRa15u5FOmE,157
55
56
  atomicshop/a_installs/win/fibratus.py,sha256=TU4e9gdZ_zI73C40uueJ59pD3qmN-UFGdX5GFoVf6cM,179
56
57
  atomicshop/a_installs/win/mongodb.py,sha256=AqyItXu19aaoe49pppDxtEkXey6PMy0PoT2Y_RmPpPE,179
58
+ atomicshop/a_installs/win/nodejs.py,sha256=U519Dyt4bsQPbEg_PwnZL5tsbfqDr1BbhxwoQFZsSKo,200
57
59
  atomicshop/a_installs/win/pycharm.py,sha256=j_RSd7aDOyC3yDd-_GUTMLlQTmDrqtVFG--oUfGLiZk,140
58
- atomicshop/a_installs/win/robocorp.py,sha256=sxSqncQIXr4rA8lCr_SwDU18IxWZlNznDE2WY3vPEMM,1789
60
+ atomicshop/a_installs/win/robocorp.py,sha256=tCUrBHFynAZK81To8vRBvchOwY6BWc4LhBgTxXb0az4,2132
59
61
  atomicshop/a_installs/win/wsl_ubuntu_lts.py,sha256=dZbPRLNKFeMd6MotjkE6UDY9cOiIaaclIdR1kGYWI50,139
60
62
  atomicshop/a_mains/dns_gateway_setting.py,sha256=ncc2rFQCChxlNP59UshwmTonLqC6MWblrVAzbbz-13M,149
61
63
  atomicshop/a_mains/msi_unpacker.py,sha256=5hrkqETYt9HIqR_3PMf32_q06kCrIcsdm_RJV9oY438,188
@@ -266,7 +268,8 @@ atomicshop/wrappers/mongodbw/install_mongodb_win.py,sha256=64EUQYx7VuMC3ndO2x3nS
266
268
  atomicshop/wrappers/mongodbw/mongo_infra.py,sha256=IjEF0jPzQz866MpTm7rnksnyyWQeUT_B2h2DA9ryAio,2034
267
269
  atomicshop/wrappers/mongodbw/mongodbw.py,sha256=ih3Gd45rg_70y4sGeu0eEJ3sJd9tEN4I5IqHZelRZJw,52854
268
270
  atomicshop/wrappers/nodejsw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
269
- atomicshop/wrappers/nodejsw/install_nodejs.py,sha256=TKGa3jSlSqZTL2NA0nMkWDFtlkz7rxGGn44ywCg7MN8,5228
271
+ atomicshop/wrappers/nodejsw/install_nodejs_ubuntu.py,sha256=wjpJdfAaY92RYl_L9esDIWuBMGeYH35RHJ5BVgMof8Y,6260
272
+ atomicshop/wrappers/nodejsw/install_nodejs_windows.py,sha256=WvXIcEVnKcQYD-KNwhVP094s__1tt0Ir2Y87MABl8Nc,6283
270
273
  atomicshop/wrappers/playwrightw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
271
274
  atomicshop/wrappers/playwrightw/_tryouts.py,sha256=l1BLkFsiIMNlgv7nfZd1XGEvXQkIQkIcg48__9OaC00,4920
272
275
  atomicshop/wrappers/playwrightw/base.py,sha256=WeRpx8otdXuKSr-BjY-uCJTze21kbPpfitoOjKQz5-g,9818
@@ -322,8 +325,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
322
325
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
323
326
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
324
327
  atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
325
- atomicshop-2.19.4.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
326
- atomicshop-2.19.4.dist-info/METADATA,sha256=eSfshvAU4DddcC-LbGoIJSBJ2GMPusBLhqc0pWWZEN0,10630
327
- atomicshop-2.19.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
328
- atomicshop-2.19.4.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
329
- atomicshop-2.19.4.dist-info/RECORD,,
328
+ atomicshop-2.19.6.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
329
+ atomicshop-2.19.6.dist-info/METADATA,sha256=Y0sI9FlA-ojjoCn5MnTdwd1xe6nC1Rs8tVkH9dxtyHo,10630
330
+ atomicshop-2.19.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
331
+ atomicshop-2.19.6.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
332
+ atomicshop-2.19.6.dist-info/RECORD,,