-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuick-Modules-Installer.py
115 lines (115 loc) · 5.59 KB
/
Quick-Modules-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
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
112
113
114
115
import os
import getpass
import sys
user = getpass.getuser()
def platform1():
platforms = {
'linux1' : 'Linux',
'linux2' : 'Linux',
'darwin' : 'OS X',
'win32' : 'Windows'
}
if sys.platform not in platforms:
return sys.platform
return platforms[sys.platform]
try:
if platform1()== "Windows":
pass
else:
print("This software is only for Windows sorry")
sys.exit()
def lable():
print("""
##############################
# Python #
# Quick Modules Installer #
##############################
""")
lable()
while True :
mod = input("Enter the Name of Python Module to install : ")
if mod:
if mod.lower() == "exit":
print("\nReload this program to install new Modules of Python.")
sys.exit()
else:
veri = os.listdir("C:\\Users\\{}\\AppData\\Local\\Programs\\Python".format(user))
if len(veri) ==2:
pyveri1,pyveri2 = veri[0],veri[1]
print("You have two folder in your python file or you install two versions of python.")
print("(1)",pyveri1)
print("(2)",pyveri2)
print("Please select your python folder")
while True:
try:
ans1 = input("Type 1 to select {} or Type 2 to select {} : ".format(pyveri1,pyveri2))
if ans1:
if ans1 == "1":
veri =pyveri1
break
elif ans1 == "2":
veri =pyveri2
break
elif ans1.lower()[0:6] == pyveri1.lower()[0:6] or ans1.lower()[0:6] == pyveri2.lower()[0:6]:
print("Please Type the number of python folder. But you name of python folder. ")
continue
else:
print("Error : {} not found".format(ans1))
continue
else:
print("Error : Please select the number of your python folder")
continue
except ValueError:
print("ValueError: {} not found The Number of folder must be a number".format(ans1))
continue
os.system("cd C:\\Users\\{}\\AppData\\Local\\Programs\\Python\\{}\\Scripts && pip.exe install {}".format(user,veri,mod))
more = input("Do You want to install more ? [Yes/No] : ")
if more.lower()=="yes" or more.lower()=="y":
lable()
continue
else:
break
sys.exit()
elif len(veri)>2:
def versioninfo():
print("You have many versions of python. Please Select your python folder.")
for i in range(0,len(veri)):
pyveri = veri[i]
print("({})".format(i), pyveri)
print("You have many versions of python. Please Select your python folder.")
while True:
try:
foldernum=int(input("Type the Number of your python folder which show in display : "))
if foldernum:
if foldernum > i:
print("Error: {} not found. \nThe number you type is too high and not found in the list of folders.".format(foldernum))
continue
else:
break
except ValueError:
print("ValueError: The Folder Number must be a number. Please type a number.")
continue
gen = veri[foldernum]
return gen
veri = versioninfo()
os.system("cd C:\\Users\\{}\\AppData\\Local\\Programs\\Python\\{}\\Scripts && pip.exe install {}".format(user,veri,mod))
more = input("Do You want to install more ? [Yes/No] : ")
if more.lower()=="yes" or more.lower()=="y":
lable()
else:
print("{} ThanksYou for using.......".format(user))
sys.exit()
else:
x = str(*veri)
os.system("cd C:\\Users\\{}\\AppData\\Local\\Programs\\Python\\{}\\Scripts && pip.exe install {}".format(user,x,mod))
more = input("Do You want to install more ? [Yes/No] : ")
if more.lower()=="yes" or more.lower()=="y":
lable()
else:
print("{} ThanksYou for using .......".format(user))
sys.exit()
else:
print("Please Type Module Name or type Exit to exit.")
continue
except Exception as e:
print("Error : ",e,"\nPlease Try again")