forked from GManOfficial/Termux_HackingLab_Setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython_modules.py
111 lines (101 loc) · 3.78 KB
/
python_modules.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
100
101
102
103
104
105
106
107
108
109
110
111
import subprocess
import sys
import pkg_resources
import os, sys
from tqdm import tqdm
from colorama import Fore, Back, Style
red = Fore.RED + Style.BRIGHT
green = Fore.GREEN + Style.BRIGHT
yellow = Fore.YELLOW + Style.BRIGHT
blue = Fore.BLUE + Style.BRIGHT
purple = Fore.MAGENTA + Style.BRIGHT
cyan = Fore.CYAN + Style.BRIGHT
white = Fore.WHITE + Style.BRIGHT
no_colour = Fore.RESET + Back.RESET + Style.RESET_ALL
def line_print(n):
for word in n + "\n":
sys.stdout.write(word)
sys.stdout.flush()
time.sleep(0.05)
# List of Python modules to install
modules_to_install = ['requests', 'colorama', 'scrapy', 'lolcat']
banner = f'''{cyan}
___ __ __ __
| .-----.-----| |_.---.-| | .-----.----.
|. | |__ --| _| _ | | | -__| _|
|. |__|__|_____|____|___._|__|__|_____|__|
|: | Developer ~ @G_Man_Official
|::.| Tool ~ Termux Hacking Lab Setup
`---' For More ~ Join | @hacking_network8
'''
colour = f"{no_colour} "
def install_modules(modules):
"""
Install missing Python modules.
"""
print(f"{red} Installing missing Python modules...")
print(f"{yellow} ")
try:
command = [sys.executable, "-m", "pip", "install"] + modules
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
progress_bar = tqdm(total=len(modules), unit="module")
for line in process.stdout:
progress_bar.update()
progress_bar.close()
output, error = process.communicate()
if process.returncode == 0:
print(f"{green}All missing Python modules have been installed successfully.")
else:
print(f"{red}Failed to install Python modules. Error:", error.decode().strip())
except subprocess.CalledProcessError as e:
print(f"{red}Failed to install Python modules. Error:", e)
def check_installed_versions(modules):
"""
Check installed versions of modules.
"""
print("\nChecking installed module versions:")
for module in modules:
try:
version = pkg_resources.get_distribution(module).version
print(f"{cyan}{module}: {version}")
except pkg_resources.DistributionNotFound:
print(f"{red}{module} is not installed.")
def uninstall_module(module):
"""
Uninstall a specific module.
"""
print(f"{red}\nUninstalling {module}...")
try:
command = [sys.executable, "-m", "pip", "uninstall", "-y", module]
uninstall_result = subprocess.run(command, capture_output=True, text=True)
if uninstall_result.returncode == 0:
print(f"{green}{module} has been successfully uninstalled.")
else:
print(f"Failed to uninstall {module}. Error:", uninstall_result.stderr.strip())
except subprocess.CalledProcessError as e:
print(f"Failed to uninstall {module}. Error:", e)
if __name__ == '__main__':
try:
os.system("clear")
print(banner)
print(colour)
# Check if modules are already installed
missing_modules = []
for module in modules_to_install:
try:
__import__(module)
except ImportError:
missing_modules.append(module)
# Install missing modules
if missing_modules:
install_modules(missing_modules)
else:
print("All required Python modules are already installed.")
# Check installed versions of modules
check_installed_versions(modules_to_install)
# Uninstall specific module
module_to_uninstall = 'scrapy'
uninstall_module(module_to_uninstall)
os.system("python3 tools_setup.py")
except KeyboardInterrupt:
line_print("\n" + green + "Thanks for using This Tool!\n" + no_colour)