atomicshop 2.5.4__py3-none-any.whl → 2.5.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 +1 -1
- atomicshop/addons/mains/install_wsl_ubuntu_lts_admin.py +14 -0
- atomicshop/filesystem.py +92 -0
- atomicshop/process.py +72 -3
- atomicshop/wrappers/dockerw/install_docker.py +41 -27
- atomicshop/wrappers/factw/fact_extractor/docker_image.py +14 -14
- atomicshop/wrappers/wslw.py +112 -0
- {atomicshop-2.5.4.dist-info → atomicshop-2.5.6.dist-info}/METADATA +2 -1
- {atomicshop-2.5.4.dist-info → atomicshop-2.5.6.dist-info}/RECORD +14 -12
- /atomicshop/addons/mains/{factw_fact_extractor_docker_image_main_with_sudo.py → factw_fact_extractor_docker_image_main_sudo.py} +0 -0
- /atomicshop/{wrappers/dockerw/install_docker_ubuntu_sudo.py → addons/mains/install_docker_ubuntu_main_sudo.py} +0 -0
- {atomicshop-2.5.4.dist-info → atomicshop-2.5.6.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.5.4.dist-info → atomicshop-2.5.6.dist-info}/WHEEL +0 -0
- {atomicshop-2.5.4.dist-info → atomicshop-2.5.6.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from atomicshop.wrappers import wslw
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
if len(sys.argv) < 2:
|
|
7
|
+
print("Usage: python main.py <directory_path_to_save_Ubuntu_package>")
|
|
8
|
+
sys.exit(1)
|
|
9
|
+
|
|
10
|
+
wslw.install_wsl(directory_path=sys.argv[1])
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
if __name__ == '__main__':
|
|
14
|
+
main()
|
atomicshop/filesystem.py
CHANGED
|
@@ -3,6 +3,7 @@ import pathlib
|
|
|
3
3
|
from pathlib import Path, PurePath, PureWindowsPath, PurePosixPath
|
|
4
4
|
import glob
|
|
5
5
|
import shutil
|
|
6
|
+
from contextlib import contextmanager
|
|
6
7
|
|
|
7
8
|
from .print_api import print_api, print_status_of_list
|
|
8
9
|
from .basics import strings, list_of_dicts
|
|
@@ -11,6 +12,51 @@ from . import hashing
|
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
WINDOWS_DIRECTORY_SPECIAL_CHARACTERS = ['<', '>', ':', '"', '/', '\\', '|', '?', '*']
|
|
15
|
+
FILE_NAME_REPLACEMENT_DICT: dict = {
|
|
16
|
+
'$': '_',
|
|
17
|
+
' ': '_',
|
|
18
|
+
'(': '_',
|
|
19
|
+
')': '_',
|
|
20
|
+
'[': '_',
|
|
21
|
+
']': '_',
|
|
22
|
+
'{': '_',
|
|
23
|
+
'}': '_',
|
|
24
|
+
"'": "_",
|
|
25
|
+
'"': '_',
|
|
26
|
+
'`': '_',
|
|
27
|
+
';': '_',
|
|
28
|
+
'&': '_',
|
|
29
|
+
'|': '_',
|
|
30
|
+
'*': '_',
|
|
31
|
+
'?': '_',
|
|
32
|
+
'~': '_',
|
|
33
|
+
'#': '_',
|
|
34
|
+
'=': '_',
|
|
35
|
+
'+': '_',
|
|
36
|
+
'%': '_',
|
|
37
|
+
',': '_',
|
|
38
|
+
'^': '_',
|
|
39
|
+
':': '_',
|
|
40
|
+
'@': '_',
|
|
41
|
+
'!': '_',
|
|
42
|
+
'°': '_',
|
|
43
|
+
'§': '_',
|
|
44
|
+
'²': '_',
|
|
45
|
+
'³': '_',
|
|
46
|
+
'µ': '_',
|
|
47
|
+
'€': '_',
|
|
48
|
+
'£': '_',
|
|
49
|
+
'¥': '_',
|
|
50
|
+
'¢': '_',
|
|
51
|
+
'©': '_',
|
|
52
|
+
'®': '_',
|
|
53
|
+
'™': '_',
|
|
54
|
+
'×': '_',
|
|
55
|
+
'÷': '_',
|
|
56
|
+
'¶': '_',
|
|
57
|
+
'·': '_',
|
|
58
|
+
'¹': '_'
|
|
59
|
+
}
|
|
14
60
|
|
|
15
61
|
|
|
16
62
|
def get_working_directory() -> str:
|
|
@@ -217,6 +263,52 @@ def create_directory(directory_fullpath: str):
|
|
|
217
263
|
pathlib.Path(directory_fullpath).mkdir(parents=True, exist_ok=True)
|
|
218
264
|
|
|
219
265
|
|
|
266
|
+
def rename_file(source_file_path: str, target_file_path: str) -> None:
|
|
267
|
+
"""
|
|
268
|
+
The function renames file from source to target.
|
|
269
|
+
|
|
270
|
+
:param source_file_path: string, full path to source file.
|
|
271
|
+
:param target_file_path: string, full path to target file.
|
|
272
|
+
|
|
273
|
+
:return: None
|
|
274
|
+
"""
|
|
275
|
+
|
|
276
|
+
# Rename file.
|
|
277
|
+
os.rename(source_file_path, target_file_path)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
@contextmanager
|
|
281
|
+
def temporary_rename(file_path: str, temp_file_path) -> None:
|
|
282
|
+
"""
|
|
283
|
+
The function will rename the file to temporary name and then rename it back to original name.
|
|
284
|
+
|
|
285
|
+
:param file_path: string, full path to file.
|
|
286
|
+
:param temp_file_path: string, temporary name to rename the file to.
|
|
287
|
+
:return: None.
|
|
288
|
+
|
|
289
|
+
Usage:
|
|
290
|
+
original_file = 'example.txt'
|
|
291
|
+
temporary_file = 'temp_example.txt'
|
|
292
|
+
|
|
293
|
+
with temporary_rename(original_file, temporary_file):
|
|
294
|
+
# Inside this block, the file exists as 'temp_example.txt'
|
|
295
|
+
print(f"File is temporarily renamed to {temporary_file}")
|
|
296
|
+
# Perform operations with the temporarily named file here
|
|
297
|
+
|
|
298
|
+
# Outside the block, it's back to 'example.txt'
|
|
299
|
+
print(f"File is renamed back to {original_file}")
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
original_name = file_path
|
|
303
|
+
try:
|
|
304
|
+
# Rename the file to the temporary name
|
|
305
|
+
os.rename(original_name, temp_file_path)
|
|
306
|
+
yield
|
|
307
|
+
finally:
|
|
308
|
+
# Rename the file back to its original name
|
|
309
|
+
os.rename(temp_file_path, original_name)
|
|
310
|
+
|
|
311
|
+
|
|
220
312
|
def move_file(source_file_path: str, target_file_path: str, no_overwrite: bool = False) -> None:
|
|
221
313
|
"""
|
|
222
314
|
The function moves file from source to target.
|
atomicshop/process.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import sys
|
|
2
3
|
import functools
|
|
3
4
|
from typing import Union
|
|
4
5
|
import shlex
|
|
@@ -70,6 +71,15 @@ def execute_with_live_output(
|
|
|
70
71
|
# output all the error output to 'stdout' variable as well. This way when you output new lines
|
|
71
72
|
# in a loop, you don't need to worry about checking 'stderr' buffer.
|
|
72
73
|
# text=True: by default the output is binary, this option sets the output to text / string.
|
|
74
|
+
# bufsize=1: When you set bufsize=1, it means line buffering is enabled. In this mode, the output is buffered
|
|
75
|
+
# line by line. Each time a line is completed (typically ending with a newline character), it is flushed
|
|
76
|
+
# from the buffer. This is particularly useful when you want to read output from the subprocess in real-time
|
|
77
|
+
# or line by line, such as in a logging or monitoring scenario.
|
|
78
|
+
# bufsize=-1 or bufsize=subprocess.PIPE: This is the default setting.
|
|
79
|
+
# It enables full buffering, which means data is buffered until the buffer is full.
|
|
80
|
+
# The buffer size is system-dependent and usually chosen by the underlying implementation to optimize performance.
|
|
81
|
+
# # bufsize=0: This means no buffering.
|
|
82
|
+
# The I/O is unbuffered, and data is written or read from the stream immediately.
|
|
73
83
|
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, text=True) as process:
|
|
74
84
|
# We'll count the number of lines from 'process.stdout'.
|
|
75
85
|
counter: int = 0
|
|
@@ -136,9 +146,9 @@ def execute_in_new_window(
|
|
|
136
146
|
return executed_process
|
|
137
147
|
|
|
138
148
|
|
|
139
|
-
def
|
|
149
|
+
def execute_script(script: str, check: bool = True, shell: bool = False):
|
|
140
150
|
"""
|
|
141
|
-
The function executes
|
|
151
|
+
The function executes a batch script bash on Linux or CMD.exe on Windows.
|
|
142
152
|
:param script: string, script to execute.
|
|
143
153
|
:param check: check=True: When this is set, if the command executed with subprocess.run() returns a non-zero
|
|
144
154
|
exit status (which usually indicates an error), a subprocess.CalledProcessError exception will be raised.
|
|
@@ -159,8 +169,16 @@ def execute_script_ubuntu(script: str, check: bool = True, shell: bool = False):
|
|
|
159
169
|
not an executable but a shell built-in command.
|
|
160
170
|
:return: None if execution was successful, subprocess.CalledProcessError string if not.
|
|
161
171
|
"""
|
|
172
|
+
|
|
173
|
+
if os.name == 'nt':
|
|
174
|
+
executable = 'cmd.exe'
|
|
175
|
+
elif os.name == 'posix':
|
|
176
|
+
executable = '/bin/bash'
|
|
177
|
+
else:
|
|
178
|
+
raise OSError(f'OS not supported: {os.name}')
|
|
179
|
+
|
|
162
180
|
try:
|
|
163
|
-
subprocess.run(script, check=check, shell=shell, executable=
|
|
181
|
+
subprocess.run(script, check=check, shell=shell, executable=executable)
|
|
164
182
|
return None
|
|
165
183
|
except subprocess.CalledProcessError as e:
|
|
166
184
|
return e
|
|
@@ -219,3 +237,54 @@ def match_pattern_against_running_processes_cmdlines(pattern: str, first: bool =
|
|
|
219
237
|
break
|
|
220
238
|
|
|
221
239
|
return matched_cmdlines
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def run_powershell_command(command):
|
|
243
|
+
try:
|
|
244
|
+
result = subprocess.run(["powershell", "-Command", command], capture_output=True, text=True, check=True)
|
|
245
|
+
print_api(result.stdout)
|
|
246
|
+
return result.stdout
|
|
247
|
+
except subprocess.CalledProcessError as e:
|
|
248
|
+
print_api(f"An error occurred: {e}", color='red', error_type=True)
|
|
249
|
+
return e
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
"""
|
|
253
|
+
subprocess.Popen and subprocess.run are both functions in Python's subprocess module used for executing shell commands,
|
|
254
|
+
but they serve different purposes and offer different levels of control over command execution.
|
|
255
|
+
|
|
256
|
+
subprocess.Popen:
|
|
257
|
+
Flexibility and Control: Popen is more flexible and provides more control over how a command is executed.
|
|
258
|
+
It is used for more complex subprocess management.
|
|
259
|
+
Asynchronous Execution: When you use Popen, it does not wait for the command to complete; instead, it starts
|
|
260
|
+
the process and moves on to the next line of code.
|
|
261
|
+
This is useful for running a process in the background while your Python script does other things.
|
|
262
|
+
I/O Streams: It gives you the ability to interact with the standard input (stdin), standard output (stdout),
|
|
263
|
+
and standard error (stderr) streams of the command.
|
|
264
|
+
Manual Management: With Popen, you need to manage the process' termination (using process.wait() or
|
|
265
|
+
process.communicate()), which gives you the ability to handle the process's output and errors in a more
|
|
266
|
+
controlled manner.
|
|
267
|
+
|
|
268
|
+
Example Usage:
|
|
269
|
+
import subprocess
|
|
270
|
+
process = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
271
|
+
stdout, stderr = process.communicate()
|
|
272
|
+
|
|
273
|
+
subprocess.run:
|
|
274
|
+
Simplicity and Convenience: run is a simpler and more convenient interface for basic subprocess management.
|
|
275
|
+
It is suitable for more straightforward use cases where you just want to execute a command and wait for it to finish.
|
|
276
|
+
Synchronous Execution: It waits for the command to complete and then returns a CompletedProcess instance.
|
|
277
|
+
This instance contains information like the command's output, error message, and return code.
|
|
278
|
+
Less Control: run does not give direct access to the command's I/O streams while it is running.
|
|
279
|
+
Automatic Management: It automatically waits for the command to complete and provides the output/error after
|
|
280
|
+
completion, simplifying error handling and output retrieval.
|
|
281
|
+
|
|
282
|
+
Example Usage:
|
|
283
|
+
import subprocess
|
|
284
|
+
result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
285
|
+
print(result.stdout)
|
|
286
|
+
|
|
287
|
+
In summary, subprocess.Popen is more suitable for complex scenarios where you need more control over subprocess
|
|
288
|
+
execution and interaction. In contrast, subprocess.run is designed for simpler use cases where you just want to
|
|
289
|
+
run a command, wait for it to complete, and maybe get its output.
|
|
290
|
+
"""
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
|
|
1
3
|
from ... import process
|
|
4
|
+
from ...print_api import print_api
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def is_docker_installed():
|
|
8
|
+
"""
|
|
9
|
+
The function will check if docker is installed.
|
|
10
|
+
:return: bool.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
# Run the command 'docker --version'
|
|
15
|
+
result = subprocess.run(['docker', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
16
|
+
|
|
17
|
+
# Check if the command was successful
|
|
18
|
+
if result.returncode == 0:
|
|
19
|
+
message = f"Docker is installed. Version: {result.stdout.strip()}"
|
|
20
|
+
print_api(message, color='green')
|
|
21
|
+
return True
|
|
22
|
+
else:
|
|
23
|
+
print_api("Docker is not installed.")
|
|
24
|
+
return False
|
|
25
|
+
except FileNotFoundError:
|
|
26
|
+
print_api("Docker command not found. Docker is not installed.")
|
|
27
|
+
return False
|
|
2
28
|
|
|
3
29
|
|
|
4
30
|
def install_docker_ubuntu():
|
|
@@ -17,31 +43,6 @@ def install_docker_ubuntu():
|
|
|
17
43
|
main()
|
|
18
44
|
"""
|
|
19
45
|
|
|
20
|
-
"""
|
|
21
|
-
#!/bin/bash
|
|
22
|
-
|
|
23
|
-
# Step 1: Set up Docker's apt repository
|
|
24
|
-
sudo apt-get update
|
|
25
|
-
sudo apt-get install -y ca-certificates curl gnupg
|
|
26
|
-
sudo install -m 0755 -d /etc/apt/keyrings
|
|
27
|
-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
28
|
-
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|
29
|
-
|
|
30
|
-
# Add the repository to Apt sources
|
|
31
|
-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
32
|
-
sudo apt-get update
|
|
33
|
-
|
|
34
|
-
# Step 2: Install the Docker packages
|
|
35
|
-
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
36
|
-
|
|
37
|
-
# Step 3: Verify the installation
|
|
38
|
-
sudo docker run hello-world
|
|
39
|
-
|
|
40
|
-
# Add Privileges to run docker without sudo. Add current user to Docker superuser group.
|
|
41
|
-
# So you can use docker without sudo.
|
|
42
|
-
sudo usermod -aG docker $USER
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
46
|
script = f"""
|
|
46
47
|
# Step 1: Set up Docker's apt repository
|
|
47
48
|
sudo apt-get update
|
|
@@ -58,10 +59,23 @@ def install_docker_ubuntu():
|
|
|
58
59
|
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
59
60
|
|
|
60
61
|
# Step 3: Verify the installation
|
|
61
|
-
sudo docker run hello-world
|
|
62
|
+
# sudo docker run hello-world
|
|
62
63
|
|
|
63
64
|
# Add Privileges to run docker without sudo. Add current user to Docker superuser group.
|
|
64
65
|
sudo usermod -aG docker $USER
|
|
65
66
|
"""
|
|
66
67
|
|
|
67
|
-
process.
|
|
68
|
+
process.execute_script(script, shell=True)
|
|
69
|
+
|
|
70
|
+
# Verify the installation.
|
|
71
|
+
result: list = process.execute_with_live_output('sudo docker run hello-world')
|
|
72
|
+
|
|
73
|
+
print_api('\n'.join(result))
|
|
74
|
+
|
|
75
|
+
if 'Hello from Docker!' in '\n'.join(result):
|
|
76
|
+
print_api('Docker installed successfully.', color='green')
|
|
77
|
+
return True
|
|
78
|
+
else:
|
|
79
|
+
print_api('Docker installation failed.', color='red')
|
|
80
|
+
print_api('Please check the logs above for more information.', color='red')
|
|
81
|
+
return False
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from ....import process
|
|
2
|
+
from ...dockerw import install_docker
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
def create_docker_image_ubuntu(directory_path: str):
|
|
@@ -26,20 +27,27 @@ def create_docker_image_ubuntu(directory_path: str):
|
|
|
26
27
|
main()
|
|
27
28
|
"""
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
# Check if docker is installed.
|
|
31
|
+
if not install_docker.is_docker_installed():
|
|
32
|
+
install_docker.install_docker_ubuntu()
|
|
33
|
+
|
|
34
|
+
# Create the script to execute.
|
|
35
|
+
script = f"""
|
|
31
36
|
#!/bin/bash
|
|
32
37
|
|
|
33
38
|
# Run this script with sudo
|
|
34
39
|
|
|
35
|
-
# If you get an error on
|
|
40
|
+
# If you get an error on execution use dos2unix to convert windows style file to linux.
|
|
36
41
|
# -bash: ./install_fact_extractor_docker.sh: /bin/bash^M: bad interpreter: No such file or directory
|
|
37
42
|
# sudo apt-get install dos2unix
|
|
38
43
|
# dos2unix ./install_fact_extractor_docker.sh
|
|
39
44
|
|
|
40
45
|
# Pull docker image from the repo.
|
|
41
46
|
docker pull fkiecad/fact_extractor
|
|
42
|
-
|
|
47
|
+
|
|
48
|
+
# Navigate to specified directory to download the repo and create the docker image.
|
|
49
|
+
cd "{directory_path}"
|
|
50
|
+
|
|
43
51
|
# Start from the directory you want the git repo to be downloaded.
|
|
44
52
|
# Clone the repository
|
|
45
53
|
git clone https://github.com/fkie-cad/fact_extractor.git
|
|
@@ -54,13 +62,5 @@ def create_docker_image_ubuntu(directory_path: str):
|
|
|
54
62
|
sudo docker build -t fact_extractor .
|
|
55
63
|
"""
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
cd "{directory_path}"
|
|
60
|
-
git clone https://github.com/fkie-cad/fact_extractor.git
|
|
61
|
-
cd fact_extractor
|
|
62
|
-
sudo service docker start
|
|
63
|
-
sudo docker build -t fact_extractor .
|
|
64
|
-
"""
|
|
65
|
-
|
|
66
|
-
process.execute_script_ubuntu(script, shell=True)
|
|
65
|
+
# Execute the script.
|
|
66
|
+
process.execute_script(script, shell=True)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from ..import process, permissions
|
|
6
|
+
from ..print_api import print_api
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def is_installed():
|
|
10
|
+
# Command to check the status of the WSL feature
|
|
11
|
+
command = "Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux"
|
|
12
|
+
|
|
13
|
+
# Check if WSL is enabled
|
|
14
|
+
if "Enabled" in process.run_powershell_command(command):
|
|
15
|
+
return True
|
|
16
|
+
else:
|
|
17
|
+
return False
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def is_ubuntu_installed() -> bool:
|
|
21
|
+
"""
|
|
22
|
+
Check if Ubuntu is installed on WSL.
|
|
23
|
+
:return: bool, True if Ubuntu is installed, False otherwise.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
# Command to list installed WSL distributions
|
|
27
|
+
command = "wsl --list --quiet"
|
|
28
|
+
|
|
29
|
+
is_ubuntu_exists: bool = False
|
|
30
|
+
# Check each distribution for being Ubuntu 22.04
|
|
31
|
+
for distro in process.run_powershell_command(command).splitlines():
|
|
32
|
+
if "ubuntu" in distro.lower():
|
|
33
|
+
is_ubuntu_exists = True
|
|
34
|
+
break
|
|
35
|
+
|
|
36
|
+
return is_ubuntu_exists
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def is_ubuntu_version_installed(version: str = "22.04") -> bool:
|
|
40
|
+
"""
|
|
41
|
+
Check if specific version of Ubuntu is installed on WSL.
|
|
42
|
+
:param version: string, Ubuntu version to check for. Default is 22.04.
|
|
43
|
+
:return: bool, True if Ubuntu is installed, False otherwise.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
# Command to get Ubuntu version
|
|
47
|
+
command = f"wsl -d Ubuntu lsb_release -a"
|
|
48
|
+
|
|
49
|
+
# Execute the command
|
|
50
|
+
result = process.run_powershell_command(command)
|
|
51
|
+
|
|
52
|
+
is_version_installed: bool = False
|
|
53
|
+
# Parse the output for the version number
|
|
54
|
+
for line in result.splitlines():
|
|
55
|
+
if "Release" in line and version in line:
|
|
56
|
+
is_version_installed = True
|
|
57
|
+
break
|
|
58
|
+
|
|
59
|
+
return is_version_installed
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def install_wsl(directory_path: str, enable_virtual_machine_platform: bool = False):
|
|
63
|
+
"""
|
|
64
|
+
Install WSL on Windows 10.
|
|
65
|
+
:param directory_path: string, directory path to save Ubuntu package.
|
|
66
|
+
:param enable_virtual_machine_platform: bool, True to enable Virtual Machine Platform feature.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
# Check for admin privileges
|
|
70
|
+
if not permissions.is_admin():
|
|
71
|
+
sys.exit("Script must be run as administrator")
|
|
72
|
+
|
|
73
|
+
# Check if WSL is already installed
|
|
74
|
+
if is_installed():
|
|
75
|
+
print_api("WSL is already installed", color='green')
|
|
76
|
+
else:
|
|
77
|
+
# Enable WSL
|
|
78
|
+
print_api("Enabling Windows Subsystem for Linux...")
|
|
79
|
+
process.run_powershell_command(
|
|
80
|
+
"Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux")
|
|
81
|
+
|
|
82
|
+
# Check if the system needs a reboot
|
|
83
|
+
if "You must restart your computer" in process.run_powershell_command(
|
|
84
|
+
"Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux"):
|
|
85
|
+
print_api("Please restart your computer to complete the installation of WSL and rerun the script.")
|
|
86
|
+
sys.exit(0)
|
|
87
|
+
|
|
88
|
+
if enable_virtual_machine_platform:
|
|
89
|
+
# Check if Hyper-V is enabled
|
|
90
|
+
if "Enabled" in process.run_powershell_command(
|
|
91
|
+
"Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V"):
|
|
92
|
+
print_api("Hyper-V is enabled")
|
|
93
|
+
else:
|
|
94
|
+
# Command to enable Virtual Machine Platform
|
|
95
|
+
command = "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All"
|
|
96
|
+
|
|
97
|
+
print_api("Enabling Virtual Machine Platform...")
|
|
98
|
+
process.run_powershell_command(command)
|
|
99
|
+
|
|
100
|
+
# Check if Ubuntu is already installed. If so, exit with a message.
|
|
101
|
+
if is_ubuntu_version_installed():
|
|
102
|
+
print_api("Ubuntu is already installed", color='green')
|
|
103
|
+
sys.exit(0)
|
|
104
|
+
|
|
105
|
+
# Download and Install Ubuntu
|
|
106
|
+
print_api("Installing Ubuntu for WSL...")
|
|
107
|
+
package_file_path: str = str(Path(directory_path, "Ubuntu.appx"))
|
|
108
|
+
process.run_powershell_command(
|
|
109
|
+
f"Invoke-WebRequest -Uri https://aka.ms/wslubuntu2204 -OutFile {package_file_path} -UseBasicParsing")
|
|
110
|
+
process.run_powershell_command(f"Add-AppxPackage {package_file_path}")
|
|
111
|
+
|
|
112
|
+
print_api("Ubuntu installation is complete. You can now launch Ubuntu from the Start Menu.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: atomicshop
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.6
|
|
4
4
|
Summary: Atomic functions and classes to make developer life easier
|
|
5
5
|
Author: Denis Kras
|
|
6
6
|
License: MIT License
|
|
@@ -170,6 +170,7 @@ To get a local copy up and running follow these simple steps.
|
|
|
170
170
|
## Usage
|
|
171
171
|
|
|
172
172
|
To follow. For now, check the files in the library. I tried my best with understandable naming and grouping convention.
|
|
173
|
+
There are some ready to use scripts in the 'addons/mains' folder. You can use them as a reference.
|
|
173
174
|
|
|
174
175
|
|
|
175
176
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=tCeFenBN36rswxpsPeUGcOeOeSmu5wl3QX2WWwVdrHk,122
|
|
2
2
|
atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
|
|
3
3
|
atomicshop/appointment_management.py,sha256=N3wVGJgrqJfsj_lqiRfaL3FxMEe57by5Stzanh189mk,7263
|
|
4
4
|
atomicshop/archiver.py,sha256=E4dgAuh6ARtAWRW6Q0RdnMRMzsE_S1NjMiajHRIVG9s,5537
|
|
@@ -12,7 +12,7 @@ atomicshop/diff_check.py,sha256=RON9cSTgy3jAnwUmAUkOyfF6bgrBKOq9Sbgyl3RYodw,1235
|
|
|
12
12
|
atomicshop/dns.py,sha256=bNZOo5jVPzq7OT2qCPukXoK3zb1oOsyaelUwQEyK1SA,2500
|
|
13
13
|
atomicshop/domains.py,sha256=Rxu6JhhMqFZRcoFs69IoEd1PtYca0lMCG6F1AomP7z4,3197
|
|
14
14
|
atomicshop/emails.py,sha256=I0KyODQpIMEsNRi9YWSOL8EUPBiWyon3HRdIuSj3AEU,1410
|
|
15
|
-
atomicshop/filesystem.py,sha256=
|
|
15
|
+
atomicshop/filesystem.py,sha256=nVun_XRMynayrvudsr2B47keFFCcjXf8VagotH8YwKI,28085
|
|
16
16
|
atomicshop/functions.py,sha256=VqLjxAxhaxUr-Ad8P1cw9bZGdZpbtqfCaXQyHf3CM9g,509
|
|
17
17
|
atomicshop/github_wrapper.py,sha256=7pZkhliP4vdcdeVtbgTDEzBS3lUw3-mp5PMWUDA19V0,4347
|
|
18
18
|
atomicshop/hashing.py,sha256=k_HXR7FnPUzLUKk8EiewJ_gLFBlWncZluiBwzplFMWs,3548
|
|
@@ -23,7 +23,7 @@ atomicshop/keyboard_press.py,sha256=1W5kRtOB75fulVx-uF2yarBhW0_IzdI1k73AnvXstk0,
|
|
|
23
23
|
atomicshop/pbtkmultifile_argparse.py,sha256=aEk8nhvoQVu-xyfZosK3ma17CwIgOjzO1erXXdjwtS4,4574
|
|
24
24
|
atomicshop/permissions.py,sha256=CYTDVOI0jh9ks0ZLnnOuPzppgCszFEc9-92DTkVTYi4,522
|
|
25
25
|
atomicshop/print_api.py,sha256=3n1CoiXvDcDGg00n5gEmQYInHryIhWbcpNjVobO1Gao,11468
|
|
26
|
-
atomicshop/process.py,sha256=
|
|
26
|
+
atomicshop/process.py,sha256=i_25PrSqSBbTcstCi_8rWVXAEYco81l6b9x1l_egTOY,14193
|
|
27
27
|
atomicshop/process_name_cmd.py,sha256=TNAK6kQZm5JKWzEW6QLqVHEG98ZLNDQiSS4YwDk8V8c,3830
|
|
28
28
|
atomicshop/process_poller.py,sha256=t79SwTX_4scH2WIH_ziw27aodG1ibhEFWbsVsmTyOVA,10846
|
|
29
29
|
atomicshop/python_functions.py,sha256=onZ272J1IiSQToqdzEvvWAFHe0EAJnNkAVv0mYkeNNw,4464
|
|
@@ -43,7 +43,9 @@ atomicshop/addons/PlayWrightCodegen.cmd,sha256=Z5cnllsyXD4F1W2h-WLEnyFkg5nZy0-hT
|
|
|
43
43
|
atomicshop/addons/ScriptExecution.cmd,sha256=8iC-uHs9MX9qUD_C2M7n9Xw4MZvwOfxT8H5v3hluVps,93
|
|
44
44
|
atomicshop/addons/a_setup_scripts/install_psycopg2_ubuntu.sh,sha256=lM7LkXQ2AxfFzDGyzSOfIS_zpg9bAD1k3JJ-qu5CdH8,81
|
|
45
45
|
atomicshop/addons/a_setup_scripts/install_pywintrace_0.3.cmd,sha256=lEP_o6rWcBFUyup6_c-LTL3Q2LRMqryLuG3mJw080Zc,115
|
|
46
|
-
atomicshop/addons/mains/
|
|
46
|
+
atomicshop/addons/mains/factw_fact_extractor_docker_image_main_sudo.py,sha256=DDKX3Wp2SmzMCEtCIEOUbEKMob2ZQ7VEQGLEf9uYXrs,320
|
|
47
|
+
atomicshop/addons/mains/install_docker_ubuntu_main_sudo.py,sha256=3VDGDO41Vubzf64DaBapLlFYX52dEdyPBNfolSsbGcM,161
|
|
48
|
+
atomicshop/addons/mains/install_wsl_ubuntu_lts_admin.py,sha256=3RjHoCEg6BCfONEKeH6vGDd9ZLun5dOp-jiDSlFbmKU,291
|
|
47
49
|
atomicshop/addons/package_setup/CreateWheel.cmd,sha256=hq9aWBSH6iffYlZyaCNrFlA0vxMh3j1k8DQE8IARQuA,189
|
|
48
50
|
atomicshop/addons/package_setup/Setup in Edit mode.cmd,sha256=299RsExjR8Mup6YyC6rW0qF8lnwa3uIzwk_gYg_R_Ss,176
|
|
49
51
|
atomicshop/addons/package_setup/Setup.cmd,sha256=IMm0PfdARH7CG7h9mbWwmWD9X47l7tddwQ2U4MUxy3A,213
|
|
@@ -127,17 +129,17 @@ atomicshop/wrappers/numpyw.py,sha256=sBV4gSKyr23kXTalqAb1oqttzE_2XxBooCui66jbAqc
|
|
|
127
129
|
atomicshop/wrappers/process_wrapper_pbtk.py,sha256=ycPmBRnv627RWks6N8OhxJQe8Gu3h3Vwj-4HswPOw0k,599
|
|
128
130
|
atomicshop/wrappers/psutilw.py,sha256=W9PSEZmrm_Ct_-6oKqAcbgbyF21CwcIbbHOkVqgMiow,20866
|
|
129
131
|
atomicshop/wrappers/pyopensslw.py,sha256=OBWxA6EJ2vU_Qlf4M8m6ilcG3hyYB4yB0EsXUf7NhEU,6804
|
|
132
|
+
atomicshop/wrappers/wslw.py,sha256=I6Im5unWniiXXK4TDonK3a9N9DrotdJCtHxmtRv-z6o,4149
|
|
130
133
|
atomicshop/wrappers/certauthw/certauth.py,sha256=hKedW0DOWlEigSNm8wu4SqHkCQsGJ1tJfH7s4nr3Bk0,12223
|
|
131
134
|
atomicshop/wrappers/certauthw/certauthw.py,sha256=4WvhjANI7Kzqrr_nKmtA8Kf7B6rute_5wfP65gwQrjw,8082
|
|
132
135
|
atomicshop/wrappers/ctyping/process_winapi.py,sha256=QcXL-ETtlSSkoT8F7pYle97ubGWsjYp8cx8HxkVMgAc,2762
|
|
133
136
|
atomicshop/wrappers/dockerw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
|
-
atomicshop/wrappers/dockerw/install_docker.py,sha256=
|
|
135
|
-
atomicshop/wrappers/dockerw/install_docker_ubuntu_sudo.py,sha256=3VDGDO41Vubzf64DaBapLlFYX52dEdyPBNfolSsbGcM,161
|
|
137
|
+
atomicshop/wrappers/dockerw/install_docker.py,sha256=dpSOmD690oLukoLCo0u6Pzh5fRyCWBuSQEtG8VwC3jk,2765
|
|
136
138
|
atomicshop/wrappers/factw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
137
139
|
atomicshop/wrappers/factw/fact_config.py,sha256=J-K9Zn50WcDC7ubb-boraSZExfBk7a6M52NhRJVlsjk,895
|
|
138
140
|
atomicshop/wrappers/factw/get_file_data.py,sha256=ChKC0OjgjFlNubZQBwcGhRO3L2pccc27RLRlAMIUix4,1641
|
|
139
141
|
atomicshop/wrappers/factw/fact_extractor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
140
|
-
atomicshop/wrappers/factw/fact_extractor/docker_image.py,sha256=
|
|
142
|
+
atomicshop/wrappers/factw/fact_extractor/docker_image.py,sha256=d2QLX0zTmJubzyvegf_SJK4yT7Ml2Aw_VlCSzZINFVs,2080
|
|
141
143
|
atomicshop/wrappers/factw/postgresql/__init__.py,sha256=xMBn2d3Exo23IPP2F_9-SXmOlhFbwWDgS9KwozSTjA0,162
|
|
142
144
|
atomicshop/wrappers/factw/postgresql/analysis.py,sha256=2Rxzy2jyq3zEKIo53z8VkjuslKE_i5mq2ZpmJAvyd6U,716
|
|
143
145
|
atomicshop/wrappers/factw/postgresql/file_object.py,sha256=VRiCXnsd6yDbnsE-TEKYPC-gkAgFVkE6rygRrJLQShI,713
|
|
@@ -186,8 +188,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=VfNthyBvgI5tL9v3Qprh4
|
|
|
186
188
|
atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
|
|
187
189
|
atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
|
|
188
190
|
atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
|
|
189
|
-
atomicshop-2.5.
|
|
190
|
-
atomicshop-2.5.
|
|
191
|
-
atomicshop-2.5.
|
|
192
|
-
atomicshop-2.5.
|
|
193
|
-
atomicshop-2.5.
|
|
191
|
+
atomicshop-2.5.6.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
192
|
+
atomicshop-2.5.6.dist-info/METADATA,sha256=R3xh983G78wSve1rqT6gdglDmTK5kH3fcMYnG-Q6O_I,10267
|
|
193
|
+
atomicshop-2.5.6.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
|
194
|
+
atomicshop-2.5.6.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
195
|
+
atomicshop-2.5.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|