1313import StringToInteger as strtoint
1414import _thread as thread
1515from youtubesearchpython import searchYoutube
16+ import updateChecker as uc
1617
1718alarm1 = []
1819alarm2 = []
1920alarm3 = []
2021
22+ version = "guinea_1.2.2"
23+
2124daysOfTheWeek = ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" , "Saturday" , "Sunday" ]
2225monthsOfTheYear = ["January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" ]
2326
@@ -176,20 +179,20 @@ def recognitionMode(recognitionint):
176179 global InternetMode
177180 InternetMode = recognitionint
178181
179- def yesOrNo (): # Not in use
182+ def yesOrNo (toAsk ):
180183 with sr .Microphone () as source :
181184 playsound ('media/beep_my.wav' )
182185 print ("I'm listening!" )
183186 audio = r .listen (source )
184187 recognition = r .recognize_google (audio )
188+ tts .say (toAsk )
185189 if recognition == "yes" :
186- InternetMode = 1
187190 My = False
188- tts . say ( "Ok. Switching to online mode" )
191+ return "yes"
189192 else :
190- InternetMode = 0
191193 My = False
192- tts .say ("Ok. Switching to offline mode" )
194+ return "no"
195+
193196
194197def MyMain ():
195198 print ("I'm listening!" )
@@ -251,7 +254,7 @@ def MyMain():
251254 tts .say ("Electricity." )
252255 My = False
253256 elif mymainr == "version" :
254- tts .say ("Guinea pig 1.2" )
257+ tts .say (version )
255258 My = False
256259 elif mymainr == "what's your favorite food" or mymainr == "what is your favorite food" :
257260 tts .say ("I like pizza." )
@@ -269,8 +272,19 @@ def MyMain():
269272 elif mymainr == "reboot" :
270273 os .system ("sudo reboot" )
271274 elif mymainr == "check for updates" or mymainr == "check for system updates" or mymainr == "update" or mymainr == "update your software" :
272- os .system ("./update-from-my" )
273- kill - this - process () #this kills the process of My, because this function doesn't exist
275+ uccheck = uc .checkForVersion ("stable" , version )
276+ for item in uccheck :
277+ updateAvaiable = item ["update" ]
278+ desc = item ["description" ]
279+ if (updateAvaiable == "y" ):
280+ assembly = "There is a new release avaiable" + str (description ) + "Would you like to install it"
281+ yn = yesOrNo (assembly )
282+ if (yn == "yes" ):
283+ tts .say ("Okay! Let's do it!" )
284+ os .system ("cd /home/pi/Desktop/ && ./updater" )
285+ kill - this - process () #this kills the process of My, because this function doesn't exist
286+ else :
287+ tts .say ("Okay, aborting mission" )
274288 My = False
275289 elif mymainr == "higher volume" or mymainr == "louder" or mymainr == "volume up" :
276290 os .system ("cd /home/pi/Desktop/ && vol +" )
0 commit comments