|
9 | 9 | os.system("cls")
|
10 | 10 | print()
|
11 | 11 | print(" " + Fore.BLACK + Back.YELLOW + " PIPWIZARD - Package Installer ")
|
12 |
| -print(Fore.LIGHTBLACK_EX + " Copyright © 2023 Ashfaaq Rifath - PipWizard v1.2.0") |
| 12 | +print(Fore.LIGHTBLACK_EX + " Copyright © 2023 Ashfaaq Rifath - PipWizard v1.3.0") |
13 | 13 | print('''
|
14 |
| - (1) Install library |
15 |
| - (2) Upgrade library |
16 |
| - (3) Uninstall library''') |
17 |
| -option = input(Fore.CYAN + " Enter option: " + Style.RESET_ALL) |
| 14 | + (1) Install package |
| 15 | + (2) Upgrade package |
| 16 | + (3) Uninstall package''') |
18 | 17 |
|
19 |
| -if option == "1": |
20 |
| - print() |
21 |
| - install_lib = input(Fore.CYAN + " Enter library name: " + Style.RESET_ALL) |
22 |
| - try: |
23 |
| - importlib.import_module(install_lib) |
24 |
| - print(" " + Fore.BLACK + Back.GREEN + f" {install_lib} already installed ") |
| 18 | +while True: |
| 19 | + option = input(Fore.CYAN + " Enter option: " + Style.RESET_ALL) |
| 20 | + if option == "1": |
25 | 21 | print()
|
26 |
| - input("Press Enter to exit...") |
27 |
| - except ImportError: |
28 |
| - subprocess.check_call(["pip", "install", install_lib]) |
29 |
| - print(" " + Fore.BLACK + Back.GREEN + f" {install_lib} has been installed ") |
30 |
| - print() |
31 |
| - input("Press Enter to exit...") |
| 22 | + install_pkg = input(Fore.CYAN + " Enter package name: " + Style.RESET_ALL) |
32 | 23 |
|
33 |
| -elif option == "2": |
34 |
| - print() |
35 |
| - upgrade_lib = input(Fore.YELLOW + " Enter library name: " + Style.RESET_ALL) |
| 24 | + try: |
| 25 | + importlib.import_module(install_pkg) |
| 26 | + print(" " + Fore.BLACK + Back.GREEN + f" {install_pkg} already installed ") |
| 27 | + print() |
| 28 | + input("Press Enter to exit...") |
| 29 | + except ImportError: |
| 30 | + subprocess.check_call(["pip", "install", install_pkg]) |
| 31 | + print(" " + Fore.BLACK + Back.GREEN + f" Installed {install_pkg} ") |
| 32 | + print() |
| 33 | + input("Press Enter to exit...") |
| 34 | + break |
36 | 35 |
|
37 |
| - subprocess.check_call(["pip", "install", "--upgrade", upgrade_lib]) |
38 |
| - print(" " + Fore.BLACK + Back.GREEN + f" {upgrade_lib} has been upgraded ") |
39 |
| - print() |
40 |
| - input("Press Enter to exit...") |
| 36 | + elif option == "2": |
| 37 | + print() |
| 38 | + upgrade_pkg = input(Fore.YELLOW + " Enter package name: " + Style.RESET_ALL) |
41 | 39 |
|
42 |
| -elif option == "3": |
43 |
| - print() |
44 |
| - uninstall_lib = input(Fore.LIGHTRED_EX + " Enter library name: " + Style.RESET_ALL) |
| 40 | + try: |
| 41 | + subprocess.check_call(["pip", "install", "--upgrade", upgrade_pkg]) |
| 42 | + print(" " + Fore.BLACK + Back.GREEN + f" Upgraded {upgrade_pkg} ") |
| 43 | + print() |
| 44 | + input("Press Enter to exit...") |
| 45 | + except subprocess.CalledProcessError: |
| 46 | + print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ") |
| 47 | + print() |
| 48 | + input("Press Enter to exit...") |
| 49 | + break |
45 | 50 |
|
46 |
| - subprocess.check_call(["pip", "uninstall", uninstall_lib]) |
47 |
| - print(" " + Fore.BLACK + Back.RED + f"{uninstall_lib} has been uninstalled ") |
48 |
| - print() |
49 |
| - input("Press Enter to exit...") |
50 |
| -else: |
51 |
| - print(" " + Fore.BLACK + Back.RED + " INVALID OPTION ") |
52 |
| - print() |
53 |
| - input("Press Enter to exit...") |
| 51 | + elif option == "3": |
| 52 | + print() |
| 53 | + uninstall_pkg = input(Fore.LIGHTRED_EX + " Enter package name: " + Style.RESET_ALL) |
| 54 | + |
| 55 | + try: |
| 56 | + subprocess.check_call(["pip", "uninstall", uninstall_pkg]) |
| 57 | + print(" " + Fore.BLACK + Back.RED + f" Unistalled {uninstall_pkg} ") |
| 58 | + print() |
| 59 | + input("Press Enter to exit...") |
| 60 | + except subprocess.CalledProcessError: |
| 61 | + print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ") |
| 62 | + print() |
| 63 | + input("Press Enter to exit...") |
| 64 | + break |
| 65 | + else: |
| 66 | + print(" " + Fore.BLACK + Back.RED + " INVALID OPTION ") |
| 67 | + print() |
0 commit comments