-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
264 lines (217 loc) · 8.56 KB
/
setup.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import os
os.system('pip install -r requirements.txt')
os.system('cls')
import sys, shutil, win32com.client, pyowm, pyttsx3, time, datetime, webbrowser, smtplib, wikipedia, wolframalpha, \
random
from playsound import playsound
sys.path.insert(0, 'modules/')
from func import *
# import speech_recognition as sr #pip install speechRecognition
# ==================================================================================
# =========================== Profile Check ========================================
# ==================================================================================
pro_file = open('includes\\profile.jv')
pro_file_r = pro_file.read()
if pro_file_r == '':
print('Sir ! you are running this program for first time \nSo first we need to create your profile')
speak('Sir ! you are running this program for first time, So first we need to create your profile')
speak('press any key to continue')
os.system('pause')
pro_file = open('includes\\profile.jv', 'w')
pro_file.close()
else:
print('You have already installed J.A.R.V.I.S.')
speak('You have already installed JARVIS')
sys.exit()
pro_file.close()
# ==================================================================================
# ==================================================================================
# ==================================================================================
os.system('cls')
print('Welcome here !')
speak('Welcome here !')
print('\n')
print('I\'m J.A.R.V.I.S. !')
speak('I\'m JARVIS !')
print('Just A Rather Very Intelligent System')
speak('Just A Rather Very Intelligent System')
print('\n')
print('I\'m here, present in your service...')
speak('I\'m here, present in your service...')
print('\n')
print('Please enter your credentials (the fields with * are optional)')
speak('Please enter your credentials')
pro_file = open('includes\\profile.jv', 'a')
print('\n')
print('Enter your name :')
speak('Enter your name please')
name = str(input())
pro_file.write(name)
pro_file.write('\n')
print('\n')
print('Enter your Date of Birth :')
speak('Enter your date of birth')
dob = str(input())
pro_file.write(dob)
pro_file.write('\n')
print('\n')
print('Enter your phone number : *')
speak('Enter your phone number, it is optional you may skip this')
phoneno = str(input())
pro_file.write(phoneno)
pro_file.write('\n')
print('\n')
print('Enter your Email ID :')
speak('Enter your email ID')
email = str(input())
pro_file.write(email)
pro_file.write('\n')
print('\n')
print('Enter your Picture Directory : *')
speak('Enter your picture directory (optional)')
music_dir = str(input())
pro_file.write(music_dir)
pro_file.write('\n')
print('\n')
print('Enter your Music Directory : *')
speak('Enter your music directory (optional)')
music_dir = str(input())
pro_file.write(music_dir)
pro_file.write('\n')
print('\n')
print('Enter your Video Directory : *')
speak('Enter your video directory (optional)')
movie_dir = str(input())
pro_file.write(movie_dir)
pro_file.write('\n')
print('\n')
print('Enter Serial key : (type \'trial\' to install trial version)')
speak('Enter serial key of the product')
serial_key = str(input())
if serial_key == 'trial':
ex_date = datetime.datetime.now().strftime('%Y-%m-%d') + '0000-00-30'
pro_file.write(ex_date)
pro_file.write('\n')
elif serial_key == 'S1-MRVAIBH-20040131':
pro_file.write('forever')
pro_file.write('\n')
else:
while serial_key != 'S1-MRVAIBH-20040131' or serial_key != 'trial':
print('Incorrect Serial Key !')
speak('Incorrect Serial Key !')
serial_key = str(input())
if serial_key == 'trial':
ex_date = datetime.datetime.now().strftime('%Y-%m-%d') + '0000-00-30'
pro_file.write(ex_date)
pro_file.write('\n')
break
elif serial_key == 'S1-MRVAIBH-20040131':
pro_file.write('forever')
pro_file.write('\n')
break
pro_file.close()
os.system('cls')
print('Profile Created !!')
speak('profile created')
os.system('cls')
# ==================================================================================
# ========================== Create EXE ============================================
# ==================================================================================
print('Writing jarvis.py')
speak('writing jarvis.py')
time.sleep(2)
os.system('cls')
jv_file = open('modules\\jarvis.py', 'w')
jv_file_r = jv_file.write('''from main import *''')
jv_file.close()
print('jarvis.py Created')
speak('jarvis.py created')
time.sleep(1)
os.system('cls')
print('Creating EXE')
speak('creating exe')
time.sleep(1)
os.system('cls')
os.system(
'pyinstaller --hidden-import=win32com.client --hidden-import=pyttsx3 --hidden-import=pyttsx3.drivers --hidden-import=pyttsx3.drivers.dummy --hidden-import=pyttsx3.drivers.espeak --hidden-import=pyttsx3.drivers.nsss --hidden-import=pyttsx3.drivers.sapi5 --hidden-import=pyowm --hidden-import=wikipedia --hidden-import=wolframalpha --hidden-import=playsound --hidden-import=speechrecognition --hidden-import=geocoder -F -i images\\jv_icon.ico modules\\jarvis.py')
os.system('cls')
# ==================================================================================
# ==================================================================================
# ==================================================================================
# ==================================================================================
# ========================== Create Uninstaller ====================================
# ==================================================================================
print('Creating Uninstaller')
speak('creating uninstaller')
time.sleep(2)
os.system('cls')
un_file = open('modules\\uninstall.py', 'w')
un_file_r = un_file.write('''import os, shutil
desktop = r'C:\\Users\\Public\\Desktop'
shortcut_dsk = os.path.join(desktop, 'J.A.R.V.I.S..lnk')
print('Program Uninstalled Successfully')
try:
os.remove('setup.exe')
os.remove('requirements.txt')
os.remove('J.A.R.V.I.S..lnk')
os.remove('jarvis.exe')
os.remove(shortcut_dsk)
shutil.rmtree('includes')
shutil.rmtree('mp3')
shutil.rmtree('__pycache__')
except:
pass
os.remove('uninstall.exe')''')
un_file.close()
os.system('pyinstaller -F -i images\\uninstall_icon.ico modules\\uninstall.py')
os.system('cls')
# ==================================================================================
# ==================================================================================
# ==================================================================================
print('Re-Arranging Files...')
speak('rearranging files')
os.rename('dist\\jarvis.exe', 'jarvis.exe')
os.rename('dist\\uninstall.exe', 'uninstall.exe')
time.sleep(2)
os.system('cls')
# ==================================================================================
# ========================== Create Shorcut ========================================
# ==================================================================================
print('Creating Shortcut')
speak('creating shortcut')
time.sleep(1)
os.system('cls')
dir_path = os.path.dirname(os.path.realpath(__file__))
desktop = r'C:\Users\Public\Desktop' # path to where you want to put the .lnk
path_dsk = os.path.join(desktop, 'J.A.R.V.I.S..lnk')
target_dsk = os.path.join(dir_path, 'jarvis.exe')
# icon_dsk = r'images\jv_icon.ico' # not needed, but nice
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(path_dsk)
shortcut.Targetpath = target_dsk
# shortcut.IconLocation = icon_dsk
shortcut.WindowStyle = 1 # 7 - Minimized, 3 - Maximized, 1 - Normal
shortcut.save()
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut('J.A.R.V.I.S..lnk')
shortcut.Targetpath = target_dsk
# shortcut.IconLocation = icon_dsk
shortcut.WindowStyle = 1 # 7 - Minimized, 3 - Maximized, 1 - Normal
shortcut.save()
# ==================================================================================
# ==================================================================================
# ==================================================================================
print('Removing Unwanted Trash')
speak('removing unwanted trash')
time.sleep(1)
os.system('cls')
os.remove('jarvis.spec')
os.remove('uninstall.spec')
shutil.rmtree('build')
shutil.rmtree('dist')
shutil.rmtree('modules')
shutil.rmtree('images')
print('Great ! J.A.R.V.I.S. is installed on your system. Now you are ready to give me commands')
speak('Great ! JARVIS is installed on your system. Now you are ready to give me commands')
os.startfile(desktop + r'\J.A.R.V.I.S..lnk')
os.system('exit')