-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
99 lines (87 loc) · 3.09 KB
/
install.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import sys
import subprocess
import time
from colorama import init, Fore, Style
# Initialize colorama
init()
# Logo with color
logo = f"""
{Fore.YELLOW}
,----------------.
/////// |Please wait files| /`., ,
|| _ _| | installing ✔ | /'/''<
|/(O)(O) `-/--------------'_.' /_'\.
(- `\\| / (_ oOo __) |
| _`-'| / `\:/' `\\
____/ (___)|___ /` |____
/ `\\ .___/ | \ /'\\_______/ _ `\\
/ `\\ /' \\______ ____ | | | |
/ / `\\___/' | | __) | | | |
_________________________________________________________
{Style.RESET_ALL}
"""
# List of packages to be installed
packages = [
'urllib3',
'requests',
'tkinter',
'platform',
]
# Function to check if pip is installed
def check_pip():
try:
subprocess.run(['pip', '--version'], check=True)
except subprocess.CalledProcessError:
print(f"{Fore.RED}pip could not be found. Please install pip first.{Style.RESET_ALL}")
sys.exit(1)
# Function to display a colored progress bar
def progress_bar(duration, label, color):
print(f"{color}{label}{Style.RESET_ALL}")
for i in range(1, duration + 1):
percent = i * 100 // duration
progress = '#' * (i * 50 // duration)
print(f"\r{label}: {percent}%|{progress:<50s}| {i}/{duration}", end='', flush=True)
time.sleep(0.1)
print()
# Function to install packages
def install_packages():
for package in packages:
print(f"Checking if {package} is already installed...")
try:
subprocess.run(['pip', 'show', package], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print(f"{package} is already installed.")
except subprocess.CalledProcessError:
print(f"Installing {package}...")
subprocess.run(['pip', 'install', package], check=True)
# Function to check if imports are successful
def check_imports():
print("Checking if required imports are successful...")
python_code = """
import urllib.request
import webbrowser
import os
import sys
import json
import requests
import tkinter as tk
from tkinter import ttk, messagebox
import platform
print("All imports are successful.")
"""
try:
subprocess.run(['python3', '-c', python_code], check=True)
except subprocess.CalledProcessError:
print(f"{Fore.RED}One or more imports failed.{Style.RESET_ALL}")
sys.exit(1)
# Main script execution
print(logo)
print("Checking if pip is installed...")
check_pip()
progress_bar(20, "Connecting", Fore.YELLOW) # Yellow
progress_bar(40, "Downloading", Fore.GREEN) # Green
install_packages()
progress_bar(10, "Finalizing", Fore.BLUE) # Blue
print("Verifying the installations...")
check_imports()
print(f"{Fore.GREEN}All packages have been installed and verified.{Style.RESET_ALL}")
print(f"{Fore.GREEN}Download complete!{Style.RESET_ALL}")