Skip to content

Commit e7c782d

Browse files
Update pipwizard.py
1 parent 0c5b63f commit e7c782d

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

pipwizard.py

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
import os
2+
import sys
23
import subprocess
34
import importlib
45
import pkgutil
56

67
if pkgutil.find_loader("colorama") is None:
78
subprocess.check_call(["pip", "install", "colorama"])
9+
#installs colorama automatically
810
else:
911
pass
1012
import colorama
1113
from colorama import Fore, Back, Style
1214
colorama.init(autoreset=True)
1315

16+
#clears terminal
1417
os.system("cls")
1518
print('''
1619
█▀▀█ ▀█▀ █▀▀█ █ █ ▀█▀ █▀▀▀█ █▀▀█ █▀▀█ █▀▀▄
1720
█▄▄█ █ █▄▄█ █ █ █ █ ▄▄▄▀▀ █▄▄█ █▄▄▀ █ █
18-
█ ▄█▄ █ █▄▀▄█ ▄█▄ █▄▄▄█ █ █ █ █ █▄▄▀ v1.5.0''')
21+
█ ▄█▄ █ █▄▀▄█ ▄█▄ █▄▄▄█ █ █ █ █ █▄▄▀ v1.5.1''')
1922
print(Fore.YELLOW + " PYTHON PACKAGE MANAGER")
2023
print('''
2124
(1) Install package
@@ -25,10 +28,12 @@
2528
(5) Batch uninstall from requirements file
2629
(6) Check package status
2730
(7) Display installed packages
28-
(8) Save requirements file''')
31+
(8) Save requirements file
32+
(9) Exit''')
2933

3034

3135
while True:
36+
print()
3237
option = input(Fore.CYAN + " Enter option: " + Style.RESET_ALL)
3338
if option == "1":
3439
print()
@@ -37,13 +42,11 @@
3742
try:
3843
subprocess.check_call(["pip", "install", install_pkg])
3944
print(" " + Fore.BLACK + Back.GREEN + f" Installed {install_pkg} ")
40-
print()
41-
input(" Press Enter to exit...")
45+
#input(" Press Enter to exit...")
4246
except subprocess.CalledProcessError:
4347
print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ")
44-
print()
45-
input(" Press Enter to exit...")
46-
break
48+
#input(" Press Enter to exit...")
49+
#break
4750

4851
elif option == "2":
4952
print()
@@ -59,9 +62,8 @@
5962
print()
6063
except subprocess.CalledProcessError:
6164
print(" " + Fore.BLACK + Back.RED + " AN ERROR OCCURED ")
62-
print()
63-
input(" Press Enter to exit...")
64-
break
65+
#input(" Press Enter to exit...")
66+
#break
6567

6668
elif option == "3":
6769
print()
@@ -70,13 +72,11 @@
7072
try:
7173
subprocess.check_call(["pip", "install", "--upgrade", update_pkg])
7274
print(" " + Fore.BLACK + Back.GREEN + f" Updated {update_pkg} ")
73-
print()
74-
input(" Press Enter to exit...")
75+
#input(" Press Enter to exit...")
7576
except subprocess.CalledProcessError:
7677
print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ")
77-
print()
78-
input(" Press Enter to exit...")
79-
break
78+
#input(" Press Enter to exit...")
79+
#break
8080

8181
elif option == "4":
8282
print()
@@ -86,12 +86,11 @@
8686
subprocess.check_call(["pip", "uninstall", uninstall_pkg])
8787
print(" " + Fore.BLACK + Back.RED + f" Uninstalled {uninstall_pkg} ")
8888
print()
89-
input(" Press Enter to exit...")
89+
#input(" Press Enter to exit...")
9090
except subprocess.CalledProcessError:
9191
print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ")
92-
print()
93-
input(" Press Enter to exit...")
94-
break
92+
#input(" Press Enter to exit...")
93+
#break
9594

9695
elif option == "5":
9796
print()
@@ -105,13 +104,8 @@
105104
try:
106105
subprocess.check_call(["pip", "uninstall", "-y", pkg])
107106
print(" " + Fore.BLACK + Back.RED + f" Uinstalled {pkg} ")
108-
print()
109107
except subprocess.CalledProcessError:
110108
print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ")
111-
print()
112-
input(" Press Enter to exit...")
113-
#os._exit(0)
114-
break
115109

116110
elif option == "6":
117111
print()
@@ -120,22 +114,21 @@
120114
try:
121115
subprocess.check_call(["pip", "show", verify_pkg])
122116
print(" " + Fore.BLACK + Back.GREEN + f" {verify_pkg} package exists ")
123-
print()
124-
input(" Press Enter to exit...")
117+
#input(" Press Enter to exit...")
125118
except subprocess.CalledProcessError:
126119
print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ")
127-
print()
128-
input(" Press Enter to exit...")
129-
break
120+
#input(" Press Enter to exit...")
121+
#break
130122

131123
elif option == "7":
132124
print()
133125
print(Fore.GREEN + " Displaying all installed packages...")
134-
135126
subprocess.check_call(["pip", "list"])
136-
print()
137-
input(" Press Enter to exit...")
138-
break
127+
128+
# run pip list command and capture output
129+
output = subprocess.check_output(["pip", "list"])
130+
with open("packages.txt", "w") as f:
131+
f.write(output.decode("utf-8"))
139132

140133
elif option == "8":
141134
print()
@@ -146,18 +139,27 @@
146139
save = subprocess.run(["pip", "freeze"], stdout=subprocess.PIPE)
147140
with open('requirements.txt', 'wb') as f:
148141
f.write(save.stdout)
149-
150142
print(" " + Fore.BLACK + Back.GREEN + " PROJECT REQUIREMENTS SAVED ")
151-
print()
152-
input(" Press Enter to exit...")
153143
except subprocess.CalledProcessError:
154144
print(" " + Fore.BLACK + Back.RED + " AN ERROR OCCURED ")
155-
print()
156-
input(" Press Enter to exit...")
157-
break
145+
146+
elif option == "help":
147+
print('''
148+
(1) Install package
149+
(2) Batch install from requirements file
150+
(3) Update package
151+
(4) Uninstall package
152+
(5) Batch uninstall from requirements file
153+
(6) Check package status
154+
(7) Display installed packages
155+
(8) Save requirements file
156+
(9) Exit''')
157+
158+
elif option == "9":
159+
os._exit(0) #exits program
158160
else:
159161
print(" " + Fore.BLACK + Back.RED + " INVALID OPTION ")
160-
print()
161162

162163

163-
# Copyright © 2023 Ashfaaq Rifath - PipWizard v1.5.0
164+
165+
# Copyright © 2023 Ashfaaq Rifath - PipWizard v1.5.1

0 commit comments

Comments
 (0)