Skip to content

Commit

Permalink
Guinea pig 1.2.2
Browse files Browse the repository at this point in the history
Guinea pig 1.2.2

What's new in this version?
- Removed updater on boot (now you can directly run python3 my.py in .bashrc)
- Added releases API with description and new functions, that release provides

Thanks to @alexmercerind for submitting GitHub API in #61
  • Loading branch information
mytja authored Sep 12, 2020
1 parent e519d26 commit 4169ae5
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 8 deletions.
30 changes: 22 additions & 8 deletions my.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
import StringToInteger as strtoint
import _thread as thread
from youtubesearchpython import searchYoutube
import updateChecker as uc

alarm1 = []
alarm2 = []
alarm3 = []

version = "guinea_1.2.2"

daysOfTheWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
monthsOfTheYear = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

Expand Down Expand Up @@ -176,20 +179,20 @@ def recognitionMode(recognitionint):
global InternetMode
InternetMode = recognitionint

def yesOrNo(): # Not in use
def yesOrNo(toAsk):
with sr.Microphone() as source:
playsound('media/beep_my.wav')
print("I'm listening!")
audio = r.listen(source)
recognition = r.recognize_google(audio)
tts.say(toAsk)
if recognition=="yes":
InternetMode = 1
My = False
tts.say("Ok. Switching to online mode")
return "yes"
else:
InternetMode = 0
My = False
tts.say("Ok. Switching to offline mode")
return "no"


def MyMain():
print("I'm listening!")
Expand Down Expand Up @@ -251,7 +254,7 @@ def MyMain():
tts.say("Electricity.")
My = False
elif mymainr=="version":
tts.say("Guinea pig 1.2")
tts.say(version)
My = False
elif mymainr=="what's your favorite food" or mymainr=="what is your favorite food":
tts.say("I like pizza.")
Expand All @@ -269,8 +272,19 @@ def MyMain():
elif mymainr=="reboot":
os.system("sudo reboot")
elif mymainr=="check for updates" or mymainr=="check for system updates" or mymainr=="update" or mymainr=="update your software":
os.system("./update-from-my")
kill-this-process() #this kills the process of My, because this function doesn't exist
uccheck = uc.checkForVersion("stable", version)
for item in uccheck:
updateAvaiable = item["update"]
desc = item["description"]
if (updateAvaiable=="y"):
assembly = "There is a new release avaiable" + str(description) + "Would you like to install it"
yn = yesOrNo(assembly)
if (yn == "yes"):
tts.say("Okay! Let's do it!")
os.system("cd /home/pi/Desktop/ && ./updater")
kill-this-process() #this kills the process of My, because this function doesn't exist
else:
tts.say("Okay, aborting mission")
My = False
elif mymainr=="higher volume" or mymainr=="louder" or mymainr=="volume up":
os.system("cd /home/pi/Desktop/ && vol +")
Expand Down
57 changes: 57 additions & 0 deletions updateChecker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import requests
import json

def getRidOf(text):
q = text.lower()
q = q.replace("g", "")
q = q.replace("u", "")
q = q.replace("i", "")
q = q.replace("n", "")
q = q.replace("e", "")
q = q.replace("a", "")
q = q.replace("_", "")
q = q.replace("b", "")
q = q.replace("t", "")
q = q.replace("l", "")
q = q.replace("s", "")
q = q.replace("v", "")
q = q.replace(".", "")
return q

def checkForVersions(stability, currentTag):
i = True
r = requests.get("https://api.github.com/repos/mytja/MyAssistantOS-Raspbian/releases")
y = r.json()
for item in y:
if (i != False):
i = False
version = item["tag_name"]
author = item["author"]["login"]
target = item["target_commitish"]
description = item["body"]

ver = int(getRidOf(version))
curver = int(getRidOf(currentTag))

#print(ver)
#print(curver)

if (ver < curver):
update = "y"
else:
update = "n"

end = {
"update": update,
"branch": target,
"version": version,
"description": description,
"publisher": author,
"ver": ver
}

finalJSON = json.dumps(end)

return finalJSON

checkForVersions("beta", "1.0.1")

0 comments on commit 4169ae5

Please sign in to comment.