dkinst 0.3.0__py3-none-any.whl → 0.4.1__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.
- dkinst/__init__.py +1 -1
- dkinst/installers/helpers/modules/nodejs_installer.py +1 -1
- dkinst/installers/helpers/modules/pycharm_installer.py +140 -0
- dkinst/installers/pycharm.py +36 -0
- {dkinst-0.3.0.dist-info → dkinst-0.4.1.dist-info}/METADATA +1 -1
- {dkinst-0.3.0.dist-info → dkinst-0.4.1.dist-info}/RECORD +10 -8
- {dkinst-0.3.0.dist-info → dkinst-0.4.1.dist-info}/WHEEL +0 -0
- {dkinst-0.3.0.dist-info → dkinst-0.4.1.dist-info}/entry_points.txt +0 -0
- {dkinst-0.3.0.dist-info → dkinst-0.4.1.dist-info}/licenses/LICENSE +0 -0
- {dkinst-0.3.0.dist-info → dkinst-0.4.1.dist-info}/top_level.txt +0 -0
dkinst/__init__.py
CHANGED
@@ -347,6 +347,7 @@ def install_nodejs_ubuntu(
|
|
347
347
|
|
348
348
|
# Check if Node.js is installed.
|
349
349
|
is_nodejs_installed_ubuntu()
|
350
|
+
# === EOF UBUNTU FUNCTIONS =============================================================================================
|
350
351
|
|
351
352
|
|
352
353
|
def _make_parser():
|
@@ -373,7 +374,6 @@ def _make_parser():
|
|
373
374
|
)
|
374
375
|
|
375
376
|
return parser
|
376
|
-
# === EOF UBUNTU FUNCTIONS =============================================================================================
|
377
377
|
|
378
378
|
|
379
379
|
def main(
|
@@ -0,0 +1,140 @@
|
|
1
|
+
import sys
|
2
|
+
import os
|
3
|
+
import argparse
|
4
|
+
import requests
|
5
|
+
from bs4 import BeautifulSoup
|
6
|
+
import subprocess
|
7
|
+
|
8
|
+
from rich.console import Console
|
9
|
+
|
10
|
+
from atomicshop import process, web
|
11
|
+
|
12
|
+
from ..infra import system, permissions
|
13
|
+
|
14
|
+
|
15
|
+
console = Console()
|
16
|
+
|
17
|
+
|
18
|
+
VERSION: str = "1.0.1"
|
19
|
+
|
20
|
+
|
21
|
+
# === WINDOWS FUNCTIONS ================================================================================================
|
22
|
+
def install_win():
|
23
|
+
"""
|
24
|
+
Main function to download and install the latest PyCharm Community Edition.
|
25
|
+
"""
|
26
|
+
|
27
|
+
if not permissions.is_admin():
|
28
|
+
console.print("This script requires administrative privileges to run.", style="red")
|
29
|
+
return 1
|
30
|
+
|
31
|
+
def get_latest_pycharm_download_link():
|
32
|
+
url = "https://www.jetbrains.com/pycharm/download/"
|
33
|
+
headers = {
|
34
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
35
|
+
}
|
36
|
+
|
37
|
+
response = requests.get(url, headers=headers)
|
38
|
+
if response.status_code != 200:
|
39
|
+
raise Exception("Failed to load the download page")
|
40
|
+
|
41
|
+
soup = BeautifulSoup(response.text, 'html.parser')
|
42
|
+
download_link = None
|
43
|
+
|
44
|
+
# Find the Professional version download link
|
45
|
+
for a in soup.find_all('a', href=True):
|
46
|
+
if '/download?code=PCC&platform=windows' in a['href']:
|
47
|
+
download_link = a['href']
|
48
|
+
break
|
49
|
+
|
50
|
+
if not download_link:
|
51
|
+
raise Exception("Could not find the download link for the latest version of PyCharm Professional")
|
52
|
+
|
53
|
+
return f"https:{download_link}"
|
54
|
+
|
55
|
+
installer_path: str | None = None
|
56
|
+
try:
|
57
|
+
print("Fetching the latest PyCharm download link...")
|
58
|
+
download_url = get_latest_pycharm_download_link()
|
59
|
+
print(f"Download URL: {download_url}")
|
60
|
+
|
61
|
+
print("Starting the download...")
|
62
|
+
file_name = "pycharm-latest.exe"
|
63
|
+
# download_file(download_url, file_name)
|
64
|
+
installer_path = web.download(file_url=download_url, file_name=file_name, use_certifi_ca_repository=True)
|
65
|
+
console.print(f"Downloaded the latest version of PyCharm to: {file_name}", style='green')
|
66
|
+
except Exception as e:
|
67
|
+
print(f"An error occurred: {e}")
|
68
|
+
|
69
|
+
if not installer_path:
|
70
|
+
console.print("Failed to download the latest version of PyCharm", style='red')
|
71
|
+
return 1
|
72
|
+
|
73
|
+
# Install PyCharm
|
74
|
+
# Run the installer
|
75
|
+
print("Running the installer...")
|
76
|
+
subprocess.run([installer_path, '/S'], check=True) # /S for silent installation
|
77
|
+
console.print("Installation complete.", style='green')
|
78
|
+
|
79
|
+
# Remove the installer
|
80
|
+
os.remove(installer_path)
|
81
|
+
|
82
|
+
return 0
|
83
|
+
# === EOF WINDOWS FUNCTIONS ============================================================================================
|
84
|
+
|
85
|
+
|
86
|
+
# === UBUNTU FUNCTIONS =================================================================================================
|
87
|
+
def install_ubuntu(enable_sudo_execution: bool = False) -> int:
|
88
|
+
"""
|
89
|
+
Main function to install the latest PyCharm unified Edition.
|
90
|
+
"""
|
91
|
+
|
92
|
+
process.execute_script('sudo snap install pycharm-professional --classic', shell=True)
|
93
|
+
|
94
|
+
if enable_sudo_execution:
|
95
|
+
process.execute_script('xhost +SI:localuser:root', shell=True)
|
96
|
+
console.print('Run the following command to start PyCharm as root: [sudo snap run pycharm-professional]', style='blue', markup=False)
|
97
|
+
return 0
|
98
|
+
# === EOF UBUNTU FUNCTIONS =============================================================================================
|
99
|
+
|
100
|
+
|
101
|
+
def _make_parser():
|
102
|
+
"""
|
103
|
+
Parse command line arguments.
|
104
|
+
|
105
|
+
:return: Parsed arguments.
|
106
|
+
"""
|
107
|
+
parser = argparse.ArgumentParser(description='Install PyCharm Community Edition.')
|
108
|
+
parser.add_argument(
|
109
|
+
'--enable_sudo_execution', action='store_true',
|
110
|
+
help='There is a problem when trying to run snapd installed Pycharm as sudo, need to enable this.'
|
111
|
+
'This is not a good security practice to run GUI apps as root. Only if you know what you doing.')
|
112
|
+
|
113
|
+
return parser
|
114
|
+
|
115
|
+
|
116
|
+
def main(
|
117
|
+
enable_sudo_execution: bool = False
|
118
|
+
) -> int:
|
119
|
+
"""
|
120
|
+
The function will install Node.js on Ubuntu or Windows.
|
121
|
+
|
122
|
+
:param enable_sudo_execution: bool: Enable sudo execution for snapd installed PyCharm.
|
123
|
+
|
124
|
+
:return: int: 0 if success, 1 if error.
|
125
|
+
"""
|
126
|
+
|
127
|
+
current_platform: str = system.get_platform()
|
128
|
+
if current_platform == "debian":
|
129
|
+
return install_ubuntu(enable_sudo_execution)
|
130
|
+
elif current_platform == "windows":
|
131
|
+
return install_win()
|
132
|
+
else:
|
133
|
+
console.print(f"PyCharm installation on {current_platform} is not implemented yet.", style="red")
|
134
|
+
return 1
|
135
|
+
|
136
|
+
|
137
|
+
if __name__ == '__main__':
|
138
|
+
pycharm_parser = _make_parser()
|
139
|
+
args = pycharm_parser.parse_args()
|
140
|
+
sys.exit(main(**vars(args)))
|
@@ -0,0 +1,36 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from types import ModuleType
|
3
|
+
from typing import Literal
|
4
|
+
|
5
|
+
from . import _base
|
6
|
+
from .helpers.modules import pycharm_installer
|
7
|
+
|
8
|
+
|
9
|
+
class PyCharm(_base.BaseInstaller):
|
10
|
+
def __init__(self):
|
11
|
+
super().__init__()
|
12
|
+
self.name: str = Path(__file__).stem
|
13
|
+
self.description: str = "PyCharm Installer"
|
14
|
+
self.version: str = pycharm_installer.VERSION
|
15
|
+
self.platforms: list = ["windows", "debian"]
|
16
|
+
self.helper: ModuleType | None = None
|
17
|
+
|
18
|
+
def install(
|
19
|
+
self,
|
20
|
+
force: bool = False
|
21
|
+
):
|
22
|
+
pycharm_installer.main()
|
23
|
+
|
24
|
+
def _show_help(
|
25
|
+
self,
|
26
|
+
method: Literal["install", "uninstall", "update"]
|
27
|
+
) -> None:
|
28
|
+
if method == "install":
|
29
|
+
method_help: str = (
|
30
|
+
"This method installs the latest version of PyCharm unified:\n"
|
31
|
+
"Windows: Downloads and installs PyCharm using the official installer from the Downloads section.\n"
|
32
|
+
"Debian: Installs using the snap package manager.\n"
|
33
|
+
)
|
34
|
+
print(method_help)
|
35
|
+
else:
|
36
|
+
raise ValueError(f"Unknown method '{method}'.")
|
@@ -1,9 +1,10 @@
|
|
1
|
-
dkinst/__init__.py,sha256=
|
1
|
+
dkinst/__init__.py,sha256=DJlBbVtolLsH24o0HeILaF4gxpl7DL0axOCiIu97aD8,78
|
2
2
|
dkinst/cli.py,sha256=4jLmbW73FInE21i1FXhuhM6eymWhA4Pvicl34H62K_4,9278
|
3
3
|
dkinst/config.toml,sha256=OaTuImf9xBIbTNCrC2MfAzpPLeuDdV2R5feIfT7xImA,48
|
4
4
|
dkinst/installers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
dkinst/installers/_base.py,sha256=2Ke4pQevOq3SRpCI1YKB9JrIwKIacPvAAMfjKn7IG20,10280
|
6
6
|
dkinst/installers/nodejs.py,sha256=34UObZLKjRIKcQt3Omslcqyuibm1m6u9nR6-W472gqY,1781
|
7
|
+
dkinst/installers/pycharm.py,sha256=GvH8uVCItaIjPSGPg2pyYl-7-LOkvh7gtubWmD2qvTM,1196
|
7
8
|
dkinst/installers/robocorp.py,sha256=yDBnA6sFjMSiOhwtyMRd59K-k6VC-42e5zVjeYZbmR4,4141
|
8
9
|
dkinst/installers/tesseract_ocr.py,sha256=iEW6S9CxzGRrhzYW0A0FMwgb6SxKXOOfCdiI1EAG5W0,2532
|
9
10
|
dkinst/installers/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -12,11 +13,12 @@ dkinst/installers/helpers/infra/msis.py,sha256=WQCTo3CsublO_xfyAgim5_HqlzMbjfhuY
|
|
12
13
|
dkinst/installers/helpers/infra/permissions.py,sha256=CYTDVOI0jh9ks0ZLnnOuPzppgCszFEc9-92DTkVTYi4,522
|
13
14
|
dkinst/installers/helpers/infra/system.py,sha256=CovoRRRz3TFEHKzHjuoSEJ2vrJGSbUETm3j5m-fjC2I,676
|
14
15
|
dkinst/installers/helpers/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
dkinst/installers/helpers/modules/nodejs_installer.py,sha256=
|
16
|
+
dkinst/installers/helpers/modules/nodejs_installer.py,sha256=crilyPMcFrydvpmgZjj5Q0evT5oQswY-pLmrt2BDr54,14966
|
17
|
+
dkinst/installers/helpers/modules/pycharm_installer.py,sha256=sRuRCvqFBoCxc9XDqb3E05x-M2LmFGV8c47FsXai8Xg,4914
|
16
18
|
dkinst/installers/helpers/modules/tesseract_ocr_manager.py,sha256=lJYVJDp5OTto4GHY1xkvJUkXCR1sgcOwj3UEUvfbPps,17369
|
17
|
-
dkinst-0.
|
18
|
-
dkinst-0.
|
19
|
-
dkinst-0.
|
20
|
-
dkinst-0.
|
21
|
-
dkinst-0.
|
22
|
-
dkinst-0.
|
19
|
+
dkinst-0.4.1.dist-info/licenses/LICENSE,sha256=ohlj1rmsTHdctr-wyqmP6kbFC6Sff8pJd29v3pruZ18,1088
|
20
|
+
dkinst-0.4.1.dist-info/METADATA,sha256=aevn_0EpnKKRwGhohQreBnCJXvp2mcZJRDupv72ZEVk,2045
|
21
|
+
dkinst-0.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
22
|
+
dkinst-0.4.1.dist-info/entry_points.txt,sha256=YNgO3GufKMdA_oRqWEGAVh6k00oIuPItqqChoUtU278,43
|
23
|
+
dkinst-0.4.1.dist-info/top_level.txt,sha256=_dGNrME6z6Ihv2sxGC4hfAlnVuhoDlKwx-97LZ2xtQ0,7
|
24
|
+
dkinst-0.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|