atomicshop 2.14.14__py3-none-any.whl → 2.15.0__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.14.14'
4
+ __version__ = '2.15.0'
@@ -0,0 +1,9 @@
1
+ from atomicshop.wrappers.mongodbw import install_mongodb
2
+
3
+
4
+ def main():
5
+ install_mongodb.download_install_latest_main()
6
+
7
+
8
+ if __name__ == "__main__":
9
+ main()
atomicshop/urls.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from urllib.parse import urlparse
2
+ import re
2
3
 
3
4
 
4
5
  def url_parser(url):
@@ -19,3 +20,37 @@ def url_parser(url):
19
20
  }
20
21
 
21
22
  return elements
23
+
24
+
25
+ def is_valid_url(url):
26
+ """
27
+ Check if a URL is valid.
28
+ :param url:
29
+ :return:
30
+ """
31
+
32
+ parsed = urlparse(url)
33
+ return all([parsed.scheme, parsed.netloc])
34
+
35
+
36
+ def find_urls_in_text(text: str) -> list[str]:
37
+ """
38
+ Find URLs in text
39
+
40
+ :param text: string, text to search for URLs.
41
+ :return: list of strings, URLs found in text.
42
+ """
43
+
44
+ url_pattern = re.compile(
45
+ r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
46
+ )
47
+ urls = url_pattern.findall(text)
48
+
49
+ # Filter URLs to remove common false positives
50
+ cleaned_urls = []
51
+ for u in urls:
52
+ cleaned_url = u.strip('",.:;!?)(')
53
+ if is_valid_url(cleaned_url):
54
+ cleaned_urls.append(cleaned_url)
55
+
56
+ return cleaned_urls
atomicshop/web.py CHANGED
@@ -146,7 +146,12 @@ def get_page_content(
146
146
  return result
147
147
 
148
148
 
149
- def download(file_url: str, target_directory: str = None, file_name: str = None, **kwargs) -> str:
149
+ def download(
150
+ file_url: str,
151
+ target_directory: str = None,
152
+ file_name: str = None,
153
+ **kwargs
154
+ ) -> str:
150
155
  """
151
156
  The function receives url and target filesystem directory to download the file.
152
157
 
File without changes
@@ -0,0 +1,122 @@
1
+ import os
2
+ import subprocess
3
+ import requests
4
+
5
+ from ... import urls, web
6
+ from ...print_api import print_api
7
+
8
+
9
+ MONGODB_DOWNLOAD_PAGE_URL: str = 'https://www.mongodb.com/try/download/community'
10
+
11
+
12
+ class MongoDBWebPageNoSuccessCodeError(Exception):
13
+ pass
14
+
15
+
16
+ class MongoDBNoDownloadLinksError(Exception):
17
+ pass
18
+
19
+
20
+ class MongoDBNoDownloadLinkForWindowsError(Exception):
21
+ pass
22
+
23
+
24
+ class MongoDBInstallationError(Exception):
25
+ pass
26
+
27
+
28
+ def get_latest_mongodb_download_url(
29
+ no_rc_version: bool = True,
30
+ major_specific: int = None
31
+ ):
32
+ response = requests.get(MONGODB_DOWNLOAD_PAGE_URL)
33
+
34
+ if response.status_code != 200:
35
+ raise MongoDBWebPageNoSuccessCodeError("Failed to load the download page.")
36
+
37
+ urls_in_page: list = urls.find_urls_in_text(response.text)
38
+ if not urls_in_page:
39
+ raise MongoDBNoDownloadLinksError("Could not find the download link for MongoDB Community Server.")
40
+
41
+ windows_urls: list = []
42
+ for url in urls_in_page:
43
+ if 'windows' in url and 'x86_64' in url and url.endswith('.msi'):
44
+ if no_rc_version and '-rc' in url:
45
+ continue
46
+ windows_urls.append(url)
47
+
48
+ if major_specific:
49
+ for url in windows_urls:
50
+ if f'-{major_specific}.' in url:
51
+ windows_urls = [url]
52
+
53
+ if not windows_urls:
54
+ raise MongoDBNoDownloadLinkForWindowsError(
55
+ "Could not find the download link for MongoDB Community Server for Windows x86_64.")
56
+
57
+ # Return the latest URL only.
58
+ return windows_urls[0]
59
+
60
+
61
+ def install_mongodb(installer_path):
62
+ try:
63
+ subprocess.run([installer_path, '/install', '/quiet', '/norestart'], check=True)
64
+ print_api("MongoDB installation completed successfully.", color='green')
65
+ except subprocess.CalledProcessError as e:
66
+ raise MongoDBInstallationError(
67
+ f"An error occurred during the installation: {e}\n"
68
+ f"Try running manually: {installer_path}")
69
+
70
+
71
+ def is_installed() -> bool:
72
+ """
73
+ Check if MongoDB is installed.
74
+ :return: bool, True if MongoDB is installed, False otherwise.
75
+ """
76
+ try:
77
+ # Run the 'mongo' command to see if MongoDB is installed
78
+ result = subprocess.run(['mongo', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
79
+
80
+ # Check the return code
81
+ if result.returncode == 0:
82
+ return True
83
+ else:
84
+ return False
85
+ except FileNotFoundError:
86
+ return False
87
+
88
+
89
+ def download_install_latest_main(
90
+ no_rc_version: bool = True,
91
+ major_specific: int = None,
92
+ force: bool = False
93
+ ):
94
+ """
95
+ Download and install the latest version of MongoDB Community Server.
96
+ :param no_rc_version: bool, if True, the latest non-RC version will be downloaded.
97
+ :param major_specific: int, if set, the latest version of the specified major version will be downloaded.
98
+ :param force: bool, if True, MongoDB will be installed even if it is already installed.
99
+ :return:
100
+ """
101
+
102
+ if is_installed():
103
+ print_api("MongoDB is already installed.", color='blue')
104
+
105
+ if not force:
106
+ return 0
107
+
108
+ print_api("Fetching the latest MongoDB download URL...")
109
+ mongo_installer_url = get_latest_mongodb_download_url(no_rc_version=no_rc_version, major_specific=major_specific)
110
+
111
+ print_api(f"Downloading MongoDB installer from: {mongo_installer_url}")
112
+ installer_file_path: str = web.download(mongo_installer_url)
113
+
114
+ print_api("Installing MongoDB...")
115
+ install_mongodb(installer_file_path)
116
+
117
+ # Clean up the installer file
118
+ if os.path.exists(installer_file_path):
119
+ os.remove(installer_file_path)
120
+ print_api("Cleaned up the installer file.")
121
+
122
+ return 0
@@ -15,10 +15,15 @@ def get_process_using_port(port: int) -> Union[dict, None]:
15
15
  connections = proc.connections(kind='inet')
16
16
  for conn in connections:
17
17
  if conn.laddr.port == port:
18
+ cmdline = proc.info['cmdline']
19
+ if not cmdline:
20
+ cmdline = '<EMPTY: TRY RUNNING AS ADMIN>'
21
+ else:
22
+ cmdline = shlex.join(cmdline)
18
23
  return {
19
24
  'pid': proc.info['pid'],
20
25
  'name': proc.info['name'],
21
- 'cmdline': shlex.join(proc.info['cmdline'])
26
+ 'cmdline': cmdline
22
27
  }
23
28
  except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
24
29
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.14.14
3
+ Version: 2.15.0
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=U_puqMerMK4pch7eXDpGxyvJxHra5X7FFCvSLPeMSUQ,124
1
+ atomicshop/__init__.py,sha256=af2i4LBZ0v9l4xOxfMEIXMsbc6UVm2YVVHFR9u8F6uY,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
@@ -42,10 +42,10 @@ atomicshop/system_resource_monitor.py,sha256=ilA3wEUJfBjQhRsHDXGH7Q05mYr5KarPjRW
42
42
  atomicshop/system_resources.py,sha256=0mhDZBEcMzToCOw5ArJhtqYjktOW6iJGdyRkJ01Cpwk,9272
43
43
  atomicshop/tempfiles.py,sha256=uq1ve2WlWehZ3NOTXJnpBBMt6HyCdBufqedF0HyzA6k,2517
44
44
  atomicshop/timer.py,sha256=7Zw1KRV0acHCRATMnanyX2MLBb63Hc-6us3rCZ9dNlY,2345
45
- atomicshop/urls.py,sha256=CQl1j1kjEVDlAuYJqYD9XxPF1SUSgrmG8PjlcXNEKsQ,597
45
+ atomicshop/urls.py,sha256=yqEn8YJS2Ma-cZidn0NZgIfuzFX0rReJ_L5IDt6iWJA,1414
46
46
  atomicshop/uuids.py,sha256=JSQdm3ZTJiwPQ1gYe6kU0TKS_7suwVrHc8JZDGYlydM,2214
47
47
  atomicshop/virtualization.py,sha256=LPP4vjE0Vr10R6DA4lqhfX_WaNdDGRAZUW0Am6VeGco,494
48
- atomicshop/web.py,sha256=yXZCPqkEgTcG0dk9kgxLQI0rALM608_d_fvxOU41gKw,11508
48
+ atomicshop/web.py,sha256=J9izvF5LNEVOVkkWon0XUgJmR7nrFln03nIxW7wUZWg,11547
49
49
  atomicshop/addons/PlayWrightCodegen.cmd,sha256=Z5cnllsyXD4F1W2h-WLEnyFkg5nZy0-hTGHRWXVOuW4,173
50
50
  atomicshop/addons/ScriptExecution.cmd,sha256=8iC-uHs9MX9qUD_C2M7n9Xw4MZvwOfxT8H5v3hluVps,93
51
51
  atomicshop/addons/a_setup_scripts/install_psycopg2_ubuntu.sh,sha256=lM7LkXQ2AxfFzDGyzSOfIS_zpg9bAD1k3JJ-qu5CdH8,81
@@ -118,7 +118,8 @@ atomicshop/file_io/jsons.py,sha256=q9ZU8slBKnHLrtn3TnbK1qxrRpj5ZvCm6AlsFzoANjo,5
118
118
  atomicshop/file_io/tomls.py,sha256=oa0Wm8yMkPRXKN9jgBuTnKbioSOee4mABW5IMUFCYyU,3041
119
119
  atomicshop/file_io/xlsxs.py,sha256=v_dyg9GD4LqgWi6wA1QuWRZ8zG4ZwB6Dz52ytdcmmmI,2184
120
120
  atomicshop/file_io/xmls.py,sha256=zh3SuK-dNaFq2NDNhx6ivcf4GYCfGM8M10PcEwDSpxk,2104
121
- atomicshop/mains/installs/pycharm.py,sha256=uYTfME7hOeNkAsOZxDDPj2hDqmkxrFqVV6Nv6xnYNVk,141
121
+ atomicshop/mains/installs/win/mongodb.py,sha256=5k9sFWM_9Zh5ShutH2IhGvAo7nrLkOIeUPzhoKvEsx8,171
122
+ atomicshop/mains/installs/win/pycharm.py,sha256=uYTfME7hOeNkAsOZxDDPj2hDqmkxrFqVV6Nv6xnYNVk,141
122
123
  atomicshop/mitm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
124
  atomicshop/mitm/config_editor.py,sha256=9ZwD6NGqgsr1f85NyFwWwM7FDut2vGQ4xari3vS9UT0,1130
124
125
  atomicshop/mitm/connection_thread_worker.py,sha256=PQ8bwOgrPudYP5oPnSi_DWaKXOi038M8TMImlLkxuPI,20486
@@ -244,6 +245,8 @@ atomicshop/wrappers/loggingw/handlers.py,sha256=yFYBeTkxnpmtlauoH3ZEFEHUYQYu9YL-
244
245
  atomicshop/wrappers/loggingw/loggers.py,sha256=DHOOTAtqkwn1xgvLHSkOiBm6yFGNuQy1kvbhG-TDog8,2374
245
246
  atomicshop/wrappers/loggingw/loggingw.py,sha256=lo4OZPXCbYZi3GqpaaJSs9SOGFfqD2EgHzzTK7f5IR4,11275
246
247
  atomicshop/wrappers/loggingw/reading.py,sha256=b4-ibM5WwjEOanvHY3hIsu9-4b2RAdPYiCxvl7745fk,17521
248
+ atomicshop/wrappers/mongodbw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
249
+ atomicshop/wrappers/mongodbw/install_mongodb.py,sha256=5fyIatRm9e_6hmNRnIzhKKLJh6GgObr_0kAR4UAIdis,3846
247
250
  atomicshop/wrappers/nodejsw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
248
251
  atomicshop/wrappers/nodejsw/install_nodejs.py,sha256=QZg-R2iTQt7kFb8wNtnTmwraSGwvUs34JIasdbNa7ZU,5154
249
252
  atomicshop/wrappers/playwrightw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -259,7 +262,7 @@ atomicshop/wrappers/playwrightw/waits.py,sha256=308fdOu6YDqQ7K7xywj7R27sSmFanPBQ
259
262
  atomicshop/wrappers/psutilw/cpus.py,sha256=w6LPBMINqS-T_X8vzdYkLS2Wzuve28Ydp_GafTCngrc,236
260
263
  atomicshop/wrappers/psutilw/disks.py,sha256=3ZSVoommKH1TWo37j_83frB-NqXF4Nf5q5mBCX8G4jE,9221
261
264
  atomicshop/wrappers/psutilw/memories.py,sha256=_S0aL8iaoIHebd1vOFrY_T9aROM5Jx2D5CvDh_4j0Vc,528
262
- atomicshop/wrappers/psutilw/networks.py,sha256=Q2EtyemncDhDsNYZREME0nOIxM-jQqIktFN3i5HtSog,1294
265
+ atomicshop/wrappers/psutilw/networks.py,sha256=jC53QXKdZQPCLdy_iNWXeq-CwpW7H6va6bFPRmI_e7A,1507
263
266
  atomicshop/wrappers/psutilw/psutilw.py,sha256=q3EwgprqyrR4zLCjl4l5DHFOQoukEvQMIPjNB504oQ0,21262
264
267
  atomicshop/wrappers/psycopgw/psycopgw.py,sha256=XJvVf0oAUjCHkrYfKeFuGCpfn0Oxj3u4SbKMKA1508E,7118
265
268
  atomicshop/wrappers/pywin32w/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -288,8 +291,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
288
291
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
289
292
  atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
290
293
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
291
- atomicshop-2.14.14.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
292
- atomicshop-2.14.14.dist-info/METADATA,sha256=9F0J0JZEwuLAVo78ASBM9KOu4CHZdXEXJ9l8b57buzw,10479
293
- atomicshop-2.14.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
294
- atomicshop-2.14.14.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
295
- atomicshop-2.14.14.dist-info/RECORD,,
294
+ atomicshop-2.15.0.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
295
+ atomicshop-2.15.0.dist-info/METADATA,sha256=nd7pqmFFd9WGeuK9aUT0ADduvInXnHIm6pf0feFpMwM,10478
296
+ atomicshop-2.15.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
297
+ atomicshop-2.15.0.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
298
+ atomicshop-2.15.0.dist-info/RECORD,,