atomicshop 3.3.14__py3-none-any.whl → 3.3.15__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__ = '3.3.14'
4
+ __version__ = '3.3.15'
atomicshop/process.py CHANGED
@@ -316,14 +316,21 @@ def kill_process_by_filename_pattern(pattern: str):
316
316
  processes.kill_process_by_pid(running_processes[0]['pid'])
317
317
 
318
318
 
319
- def run_powershell_command(command):
319
+ def run_powershell_command(
320
+ command: str
321
+ ):
320
322
  try:
321
323
  result = subprocess.run(["powershell", "-Command", command], capture_output=True, text=True, check=True)
322
- print_api(result.stdout)
324
+ if result.stdout:
325
+ print_api(result.stdout)
326
+ if result.stderr: # PS can write warnings to stderr even on success
327
+ print_api(result.stderr, color='yellow')
323
328
  return result.stdout
324
329
  except subprocess.CalledProcessError as e:
325
- print_api(f"An error occurred: {e}", color='red', error_type=True)
326
- return e
330
+ # e.stderr and e.stdout are populated because capture_output=True
331
+ msg = (e.stderr or e.stdout or f"PowerShell exited with code {e.returncode}")
332
+ print_api(msg, color='red', error_type=True)
333
+ return msg
327
334
 
328
335
 
329
336
  """
atomicshop/web.py CHANGED
@@ -4,6 +4,11 @@ import ssl
4
4
  # noinspection PyPackageRequirements
5
5
  import certifi
6
6
 
7
+ try:
8
+ from importlib.metadata import version, PackageNotFoundError # Python 3.8+
9
+ except ImportError: # Python <3.8
10
+ from importlib_metadata import version, PackageNotFoundError # backport
11
+
7
12
  from .archiver import zips
8
13
  from .urls import url_parser
9
14
  from .file_io import file_io
@@ -14,8 +19,6 @@ from . import filesystem, print_api
14
19
  # https://www.useragents.me/
15
20
  # https://user-agents.net/
16
21
  USER_AGENTS = {
17
- 'Windows_Chrome_Latest':
18
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36',
19
22
  'Chrome_111.0.0_Windows_10-11_x64':
20
23
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
21
24
  'Chrome 132.0.0, Windows 10/11':
@@ -184,6 +187,19 @@ def download(
184
187
  else:
185
188
  print_api.print_api(f'Downloaded bytes: {aggregated_bytes_int}', print_end=print_end, **kwargs)
186
189
 
190
+ def has_pip_system_certs() -> bool:
191
+ try:
192
+ version("pip-system-certs") # distribution/project name on PyPI
193
+ return True
194
+ except PackageNotFoundError:
195
+ return False
196
+
197
+ if not has_pip_system_certs():
198
+ print_api.print_api(
199
+ 'Warning: "pip-system-certs" package is not installed. '
200
+ 'If "certifi" package is installed, the system\'s CA store will not be used for SSL context. '
201
+ 'Install "pip-system-certs" package if you want to use the system\'s CA store.', color='yellow', **kwargs)
202
+
187
203
  # Size of the buffer to read each time from url.
188
204
  buffer_size: int = 4096
189
205
 
@@ -2,12 +2,26 @@ import os
2
2
  from typing import Literal, Union
3
3
  from pathlib import Path
4
4
  import datetime
5
+ import re
5
6
 
6
7
  from ... import filesystem, datetimes
7
8
  from ...basics import booleans, list_of_classes
8
9
  from ...file_io import csvs
9
10
 
10
11
 
12
+ def is_string_ends_with_ymd(s: str) -> bool:
13
+ date_tail_re = re.compile(r'(\d{4}-\d{2}-\d{2})$')
14
+
15
+ m = date_tail_re.search(s)
16
+ if not m:
17
+ return False
18
+ try:
19
+ datetime.datetime.strptime(m.group(1), "%Y-%m-%d")
20
+ return True
21
+ except ValueError:
22
+ return False
23
+
24
+
11
25
  def get_logs_paths(
12
26
  log_file_path: str,
13
27
  date_format: str = None,
@@ -65,6 +79,10 @@ def get_logs_paths(
65
79
  log_file_name: str = Path(log_file_path).stem
66
80
  log_file_extension: str = Path(log_file_path).suffix
67
81
 
82
+ if is_string_ends_with_ymd(log_file_name):
83
+ raise ValueError(
84
+ f'The log file name cannot end with a date in the format YYYY-MM-DD: {log_file_name}')
85
+
68
86
  if not log_file_extension and '.' in log_file_name:
69
87
  log_file_name, log_file_extension = log_file_name.rsplit('.')
70
88
  log_file_extension = f'.{log_file_extension}'
@@ -245,7 +245,7 @@ def wrap_socket_with_ssl_context_client___default_certs___ignore_verification(
245
245
  custom_pem_client_certificate_file_path: str = None,
246
246
  enable_sslkeylogfile_env_to_client_ssl_context: bool = False,
247
247
  sslkeylog_file_path: str = None
248
- ):
248
+ ) -> ssl.SSLSocket:
249
249
  """
250
250
  This function is a preset for wrapping the socket with SSL context for the client.
251
251
  It sets the CA default certificates, and ignores the server's certificate verification.
@@ -256,6 +256,9 @@ def wrap_socket_with_ssl_context_client___default_certs___ignore_verification(
256
256
  Default is None.
257
257
  :param enable_sslkeylogfile_env_to_client_ssl_context: boolean, enables the SSLKEYLOGFILE environment variable
258
258
  to the SSL context. Default is False.
259
+ :param sslkeylog_file_path: string, full file path for the SSL key log file. Default is None.
260
+
261
+ :return: ssl.SSLSocket object
259
262
  """
260
263
  ssl_context: ssl.SSLContext = create_ssl_context_for_client(
261
264
  enable_sslkeylogfile_env_to_client_ssl_context=enable_sslkeylogfile_env_to_client_ssl_context
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atomicshop
3
- Version: 3.3.14
3
+ Version: 3.3.15
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=debK84uDGgKHJ_4iS_NawX5O0cgsZh-k1lWv7rnptCA,123
1
+ atomicshop/__init__.py,sha256=6WgqHKNGGFHXE26Xw2aXZupzRTfmkTbM2lmvzAjmQcc,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
@@ -28,7 +28,7 @@ atomicshop/networks.py,sha256=IfhEgI0rJHPgkbIDEC6lsPVZm-fyylpacKSo5HrIEic,26403
28
28
  atomicshop/on_exit.py,sha256=9XlOnzoAG8zlI8wBF4AB8hyrC6Q1b84gkhqpAhhdN9g,6977
29
29
  atomicshop/pbtkmultifile_argparse.py,sha256=aEk8nhvoQVu-xyfZosK3ma17CwIgOjzO1erXXdjwtS4,4574
30
30
  atomicshop/print_api.py,sha256=SJNQIMqSLlYaPtjHnALySAI-jQYuYHOCGgfP7oe96fU,10957
31
- atomicshop/process.py,sha256=dmje2YIDPVM8zS38ylAqyOhDBXk6ay_N1xeewKdEIX4,16966
31
+ atomicshop/process.py,sha256=e8u7jvq5HDKqna7xmeqNTKFY4BQNKX6NtAUGPwur6zE,17288
32
32
  atomicshop/python_file_patcher.py,sha256=-uhbUX-um5k-If_XXuOfCr8wMzZ3QE6h9N8xGWw6W_o,5486
33
33
  atomicshop/python_functions.py,sha256=BPZ3sv5DgQs6Xrl3nIMdPABRpgrau3XSrsnDIz-LEwY,6175
34
34
  atomicshop/question_answer_engine.py,sha256=7nM6kGDSFjQNi87b87-kP9lYM0vTjBHn1rEQGNAfdGA,825
@@ -48,12 +48,11 @@ atomicshop/uuids.py,sha256=JSQdm3ZTJiwPQ1gYe6kU0TKS_7suwVrHc8JZDGYlydM,2214
48
48
  atomicshop/venvs.py,sha256=D9lwOoObkYoRx-weuoAmbvN-RdSHhVm4DE9TVl-utAs,903
49
49
  atomicshop/versioning.py,sha256=e5W6m9AF3__M5nntqI9CqNAeHqkwY9JhlnpYeZ1CEus,970
50
50
  atomicshop/virtualization.py,sha256=LPP4vjE0Vr10R6DA4lqhfX_WaNdDGRAZUW0Am6VeGco,494
51
- atomicshop/web.py,sha256=syPmJLkV8j7zdn8cb_VPOB-zD0wJMr3metnrJHm3Hm0,13189
51
+ atomicshop/web.py,sha256=dqnOX2Y4kQktAaU2xzfT-U-emPcqN4z50rQ0UoOgiBc,13828
52
52
  atomicshop/websocket_parse.py,sha256=aLHWyKqaYqEn_MRBWm2L6rIl6QPmqbVrjEXE_rBzwCw,16711
53
53
  atomicshop/a_installs/ubuntu/docker_rootless.py,sha256=9IPNtGZYjfy1_n6ZRt7gWz9KZgR6XCgevjqq02xk-o0,281
54
54
  atomicshop/a_installs/ubuntu/docker_sudo.py,sha256=JzayxeyKDtiuT4Icp2L2LyFRbx4wvpyN_bHLfZ-yX5E,281
55
55
  atomicshop/a_installs/ubuntu/elastic_search_and_kibana.py,sha256=yRB-l1zBxdiN6av-FwNkhcBlaeu4zrDPjQ0uPGgpK2I,244
56
- atomicshop/a_installs/win/wsl_ubuntu_lts.py,sha256=dZbPRLNKFeMd6MotjkE6UDY9cOiIaaclIdR1kGYWI50,139
57
56
  atomicshop/a_mains/dns_gateway_setting.py,sha256=ncc2rFQCChxlNP59UshwmTonLqC6MWblrVAzbbz-13M,149
58
57
  atomicshop/a_mains/github_wrapper.py,sha256=F-PoZknVCxWPN0PTO6l7ZNiaYvo7OVFKFI_zlPt56ps,169
59
58
  atomicshop/a_mains/msi_unpacker.py,sha256=5hrkqETYt9HIqR_3PMf32_q06kCrIcsdm_RJV9oY438,188
@@ -198,7 +197,6 @@ atomicshop/wrappers/process_wrapper_pbtk.py,sha256=ycPmBRnv627RWks6N8OhxJQe8Gu3h
198
197
  atomicshop/wrappers/pyopensslw.py,sha256=pklvXEbi0fHu5n1eRKKHEDLN_nsIqCTXv5Lv0bzReTo,7071
199
198
  atomicshop/wrappers/sysmonw.py,sha256=CdawuWuy_uUi3ALCm6lKP7pSyKeTk1MXyzOaTMbBSO8,5346
200
199
  atomicshop/wrappers/ubuntu_terminal.py,sha256=hHXsr_jEHU4frCwgo1XWS5Gb5nmg-Q06tiem4N8RYeE,12316
201
- atomicshop/wrappers/wslw.py,sha256=2Z7X0j5M2hoRZjbHfm_vqwNXZeptsdkNCdhdcM_S9vo,6998
202
200
  atomicshop/wrappers/certauthw/certauth.py,sha256=qLo593_MLU8VfbhYoNQ3J5BvtZuE71aFQROysEt6_dk,12225
203
201
  atomicshop/wrappers/certauthw/certauthw.py,sha256=4WvhjANI7Kzqrr_nKmtA8Kf7B6rute_5wfP65gwQrjw,8082
204
202
  atomicshop/wrappers/ctyping/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -260,7 +258,7 @@ atomicshop/wrappers/loggingw/formatters.py,sha256=ZY12IokVY1G_Wzn2Zlv9qjK-e8CtIK
260
258
  atomicshop/wrappers/loggingw/handlers.py,sha256=9JoleL96N85e6lEtD92YmKMwupHHON_YbV2ajeOBJ-8,21965
261
259
  atomicshop/wrappers/loggingw/loggers.py,sha256=mmM__XR3W4QC82wbsDRG_M4_0JYGGEP0Qn0WCOSp-go,2910
262
260
  atomicshop/wrappers/loggingw/loggingw.py,sha256=Cp_9IsiloPYpp9uzEQtUX-jCfcgGe4B2nFBle8x4wqQ,43582
263
- atomicshop/wrappers/loggingw/reading.py,sha256=sCNlgqLNH5XdKqOOjjEox7CvViMHzs6h7-hwCnx4NKk,17566
261
+ atomicshop/wrappers/loggingw/reading.py,sha256=3uM7xc4Q_CBDkWgu6YGv_n5-9cCGrYXEd7qhc_Zk2EI,18068
264
262
  atomicshop/wrappers/mongodbw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
265
263
  atomicshop/wrappers/mongodbw/mongo_infra.py,sha256=vEXKy1Mi6LZ7QNEtRb8d-5xT5PYFhXbeEfFsXfsgpYo,918
266
264
  atomicshop/wrappers/mongodbw/mongodbw.py,sha256=CHbDfW9CXzXUs3V97DYQpt-dYlt_gB60JhwqG2tVFQY,56049
@@ -303,7 +301,7 @@ atomicshop/wrappers/socketw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
303
301
  atomicshop/wrappers/socketw/accepter.py,sha256=4I9ORugRDvwaqSzm_gWSjZnRwQGY8hDTlCdsYHwH_ZE,2377
304
302
  atomicshop/wrappers/socketw/base.py,sha256=EcosGkD8VzgBY3GeIHDSG29ThQfXwg3-GQPmBTAqTdw,3048
305
303
  atomicshop/wrappers/socketw/certificator.py,sha256=mtWPJ_ew3OSwt0-1W4jaoco1VIY4NRCrMv3mDUxb_Cc,12418
306
- atomicshop/wrappers/socketw/creator.py,sha256=V_M-xGoOsPWh0ndScdHG3zHrX-5nIjQjYhJHnt_P8vg,13816
304
+ atomicshop/wrappers/socketw/creator.py,sha256=LLqPEI00pDN1HxHo_QVVuNmrmjmjhIBNMsgpZd3wS_4,13969
307
305
  atomicshop/wrappers/socketw/dns_server.py,sha256=GOYMvHvS6Fx7s-DRygGqO7_o8_Qt9on3HmKxgOSznRE,55956
308
306
  atomicshop/wrappers/socketw/exception_wrapper.py,sha256=qW_1CKyPgGlsIt7_jusKkMV4A4hih4bX324u0PLnoO8,7382
309
307
  atomicshop/wrappers/socketw/get_process.py,sha256=aJC-_qFUv3NgWCSUzDI72E4z8_-VTZE9NVZ0CwUoNlM,5698
@@ -318,8 +316,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=_gA8bMX6Sw_UCXKi2y9wNAwlqif
318
316
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
319
317
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
320
318
  atomicshop/wrappers/winregw/winreg_network.py,sha256=ih0BVNwByLvf9F_Lac4EdmDYYJA3PzMvmG0PieDZrsE,9905
321
- atomicshop-3.3.14.dist-info/licenses/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
322
- atomicshop-3.3.14.dist-info/METADATA,sha256=fJyUo62FOFuh2wMAlAnxRwsXJSWpggmeXAuwJpKdljU,9345
323
- atomicshop-3.3.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
324
- atomicshop-3.3.14.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
325
- atomicshop-3.3.14.dist-info/RECORD,,
319
+ atomicshop-3.3.15.dist-info/licenses/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
320
+ atomicshop-3.3.15.dist-info/METADATA,sha256=Mcn63amszsRHA31Jh2PiUb2TH3jwolN_trPIqZUGwr8,9345
321
+ atomicshop-3.3.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
322
+ atomicshop-3.3.15.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
323
+ atomicshop-3.3.15.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- from atomicshop.wrappers import wslw
2
-
3
-
4
- # Run as admin
5
- def main():
6
- wslw.install_wsl()
7
-
8
-
9
- if __name__ == '__main__':
10
- main()
@@ -1,192 +0,0 @@
1
- import sys
2
- from pathlib import Path
3
-
4
- from ..import process, permissions, virtualization
5
- from ..permissions import 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 get_installed_distros() -> list:
21
- """
22
- Get a list of installed WSL distros.
23
- :return: list, list of installed WSL distros.
24
- """
25
- return process.execute_with_live_output("wsl --list --quiet")
26
-
27
-
28
- def get_available_distros_to_install() -> list:
29
- """
30
- Get a list of available WSL distros to install.
31
- :return: list, list of available WSL distros to install.
32
- """
33
- return process.execute_with_live_output("wsl --list --online")
34
-
35
-
36
- def is_ubuntu_installed(version: str = "22.04") -> bool:
37
- """
38
- Check if specific version of Ubuntu is installed on WSL.
39
- :param version: string, Ubuntu version to check for. Default is 22.04.
40
- :return: bool, True if Ubuntu is installed, False otherwise.
41
- """
42
-
43
- if not version:
44
- version = str()
45
-
46
- installed_distros_list = get_installed_distros()
47
-
48
- if f'Ubuntu-{version}' in installed_distros_list:
49
- return True
50
- elif 'Ubuntu' in installed_distros_list:
51
- # Command to get Ubuntu version
52
- command = f"wsl -d Ubuntu lsb_release -a"
53
-
54
- # Execute the command
55
- result = process.execute_with_live_output(command)
56
-
57
- is_version_installed: bool = False
58
- # Parse the output for the version number
59
- for line in result:
60
- if "Release" in line and version in line:
61
- is_version_installed = True
62
- break
63
-
64
- return is_version_installed
65
- else:
66
- return False
67
-
68
-
69
- def install_wsl_manual(
70
- directory_path: str, enable_virtual_machine_platform: bool = True, set_default_version_2: bool = True):
71
- # noinspection GrazieInspection
72
- """
73
- Install WSL on Windows 10.
74
- :param directory_path: string, directory path to save Ubuntu package.
75
- :param enable_virtual_machine_platform: bool, True to enable Virtual Machine Platform feature.
76
- :param set_default_version_2: bool, True to set WSL version 2 as default.
77
-
78
- Main.py example:
79
- import sys
80
- from atomicshop.wrappers import wslw
81
-
82
-
83
- def main():
84
- if len(sys.argv) < 2:
85
- print("Usage: python main.py <directory_path_to_save_Ubuntu_package>")
86
- sys.exit(1)
87
-
88
- wslw.install_wsl(directory_path=sys.argv[1])
89
-
90
-
91
- if __name__ == '__main__':
92
- main()
93
- """
94
-
95
- # Check for admin privileges
96
- if not permissions.is_admin():
97
- sys.exit("Script must be run as administrator")
98
-
99
- # Check if WSL is already installed
100
- if is_installed():
101
- print_api("WSL is already installed", color='green')
102
- else:
103
- # Enable WSL
104
- print_api("Enabling Windows Subsystem for Linux...")
105
- process.run_powershell_command(
106
- "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart")
107
-
108
- # # Check if the system needs a reboot
109
- # if "RestartNeeded : True" in process.run_powershell_command(
110
- # "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux"):
111
- # print_api("Please restart your computer to complete the installation of WSL and rerun the script.")
112
- # sys.exit(0)
113
-
114
- # Enable Virtual Machine Platform is needed for WSL 2.
115
- if enable_virtual_machine_platform:
116
- # Check if Hyper-V is enabled
117
- if "Enabled" in process.run_powershell_command(
118
- "Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V"):
119
- print_api("Hyper-V is enabled")
120
- else:
121
- # Command to enable Virtual Machine Platform
122
- command = "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart"
123
-
124
- print_api("Enabling Virtual Machine Platform...")
125
- process.run_powershell_command(command)
126
-
127
- # Set WSL version 2 as default.
128
- if set_default_version_2:
129
- print_api("Setting WSL version 2 as default...")
130
- process.execute_with_live_output("wsl --set-default-version 2")
131
-
132
- # Check if Ubuntu is already installed. If so, exit with a message.
133
- if is_ubuntu_installed():
134
- print_api("Ubuntu is already installed", color='green')
135
- sys.exit(0)
136
-
137
- # Before you install Ubuntu, you need to set the WSL to version 2.
138
- # You can do it after you install, but if so, you will need to set the Ubuntu to version 2 either.
139
- # Download and Install Ubuntu.
140
- print_api("Installing Ubuntu for WSL...")
141
- package_file_path: str = str(Path(directory_path, "Ubuntu.appx"))
142
- process.run_powershell_command(
143
- f"Invoke-WebRequest -Uri https://aka.ms/wslubuntu2204 -OutFile {package_file_path} -UseBasicParsing")
144
- process.run_powershell_command(f"Add-AppxPackage {package_file_path}")
145
-
146
- print_api("Ubuntu installation is complete. You can now launch Ubuntu from the Start Menu.")
147
- print_api("Please restart your computer to complete the installation.")
148
-
149
-
150
- def install_wsl(distro: str = "Ubuntu-22.04"):
151
- # noinspection GrazieInspection
152
- """
153
- Install WSL and Ubuntu.
154
- :param distro: string, distro to install. Default is Ubuntu-22.04.
155
- :return:
156
-
157
- Main.py example:
158
- from atomicshop.wrappers import wslw
159
-
160
-
161
- def main():
162
- wslw.install_wsl()
163
-
164
-
165
- if __name__ == '__main__':
166
- main()
167
- """
168
-
169
- # Check for admin privileges
170
- if not permissions.is_admin():
171
- print_api("Script must be run as administrator", color='red')
172
- sys.exit(1)
173
-
174
- # Check if virtualization is enabled.
175
- if not virtualization.is_enabled():
176
- print_api("Virtualization is not enabled in the bios. Please enable it and rerun the script.", color='red')
177
- sys.exit(1)
178
-
179
- # Check if WSL and Ubuntu is already installed
180
- wsl_installed: bool = is_installed()
181
- ubuntu_installed: bool = is_ubuntu_installed()
182
-
183
- if wsl_installed and ubuntu_installed:
184
- print_api("WSL and Ubuntu is already installed", color='green')
185
- sys.exit(0)
186
- elif wsl_installed and not ubuntu_installed:
187
- print_api("WSL is already installed, installing Ubuntu")
188
- elif not wsl_installed:
189
- print_api("WSL is not installed, installing WSL and Ubuntu")
190
-
191
- command = f"wsl --install -d {distro}"
192
- process.execute_with_live_output(command, verbose=True)