-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.py
73 lines (46 loc) · 2.51 KB
/
installer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import requests
import zipfile
import subprocess
url = "https://github.com/junegunn/fzf/releases/download/0.42.0/fzf-0.42.0-windows_amd64.zip"
download_path = "fzf-0.42.0-windows_amd64.zip"
extract_dir = "C:/Windows/System32/"
def download_and_extract(url, download_path, extract_dir):
print("Downloading file...")
with requests.get(url, stream=True) as response:
with open(download_path, "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print("Extracting files...")
with zipfile.ZipFile(download_path, "r") as zip_ref:
zip_ref.extractall(extract_dir)
os.remove(download_path)
print("Extraction complete!")
if __name__ == "__main__":
script_dir = os.path.dirname(os.path.abspath(__file__))
if not os.path.exists(extract_dir):
print("Destination directory does not exist. Please ensure 'C:/Windows/System32/' exists.")
else:
download_and_extract(url, download_path, extract_dir)
try:
subprocess.run("winget --help", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
except subprocess.CalledProcessError:
print("Installing winget...")
subprocess.run("iex (new-object net.webclient).downloadstring('https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.Winget.Source.appxbundle')", shell=True, check=True)
print("winget installed.")
try:
subprocess.run("scoop --version", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
except subprocess.CalledProcessError:
print("Installing Scoop...")
iwr_cmd = "iex (new-object net.webclient).downloadstring('https://get.scoop.sh')"
subprocess.run(["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", iwr_cmd])
print("Scoop installed.")
scripts_to_run = ["setup.bat", "install_dependencies.ps1", "config.bat"]
for script in scripts_to_run:
script_path = os.path.join(script_dir, script)
if os.path.exists(script_path):
print(f"Running {script}...")
subprocess.Popen(["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "Start-Process", script_path, "-Verb", "RunAs"])
print(f"{script} launched.")
else:
print(f"Script {script} not found in the script directory.")