Пример #1
0
def WeatherModule():
    pidetts.speak(" Where do you want to know the weather conditions for? ")
    location = ''
    while location == '':
        location = pidestt.active_listen()
        location = location.lower()
        if "exit" in location or "nowhere" in location:
            pidetts.speak(" Exiting weather module. ")
            return
        elif "home" in location or "local" in location or "current" in location:
            for user in usermanager.users:
                if currentUser.name == user.name:
                    location = user.home
                    GetWeatherAtTime(location)
        else:
            Repeater(location)
            pidetts.speak(" Is that correct? ")
            answ = ''
            while answ == '':
                answ = pidestt.active_listen()
            if "yes" in answ:
                GetWeatherAtTime(location)
                return
            else:
                pidetts.speak(" Okay! I will try again. ")
                location = ''
Пример #2
0
def setHomeLocation():
    pidetts.speak(" Where do you live? ")
    userhome = ''
    while userhome == '':
        userhome = pidestt.active_listen()
    userhome = userhome.lower()
    pidetts.speak("You live in " + userhome + ". Is this correct?")
    answ = ''
    while answ == '':
        answ = pidestt.active_listen()
        if "yes" in answ:
            return userhome
        elif "no" in answ:
            answ = ''
        elif "exit" in answ:
            return
        else:
            answ = ''
Пример #3
0
def ConfirmPassword(username):
    pidetts.speak(" What is your password? ")
    psw = ''
    while psw == '':
        psw = pidestt.active_listen()
    psw = psw.lower()
    pidetts.speak(" Checking users password ")
    for user in usermanager.users:
        if username == user.name and psw == user.password:
            LoginUser(username)
            return
    pidetts.speak(" Password did not match users password! ")
    return
Пример #4
0
def setPsw():
    pidetts.speak(" You must now create a password")
    pidetts.speak(
        " You use your password when logging into your useraccount by voice. ")
    pidetts.speak(" Create your password now. ")
    userpsw = ''
    while userpsw == '':
        userpsw = pidestt.active_listen()
    userpsw = userpsw.lower()
    pidetts.speak("Your password is " + userpsw + ". Is this correct?")
    answ = ''
    while answ == '':
        answ = pidestt.active_listen()
        if "yes" in answ:
            return userpsw
        elif "no" in answ:
            answ = ''
        elif "exit" in answ:
            return
        else:
            answ = ''
Пример #5
0
def deleteUser(users):
    userReport(users)
    #delete = raw_input('')
    pidetts.speak("Which user do you want to delete?")
    userQuery = ''
    while userQuery == '':
        userQuery = pidestt.active_listen()
    delete = userQuery.lower()
    if "noone" in delete or "none" in delete or "exit" in delete:
        return
    for user in users:
        if user.name == delete:
            users.remove(user)
            shutil.rmtree('./data/users/' + delete)
            shutil.rmtree('./data/faces/' + delete)
            pidetts.speak("User " + delete + " has been removed.")
            saveUsers(users)
            return
    pidetts.speak("Could not locate user named " + delete +
                  ". No account has been deleted")
    return

    saveUsers(users)
Пример #6
0
def addUser(users):
    print "Name user account: \n"
    pidetts.speak("What do you want your user to be named?")
    while True:
        username = ''
        while username == '':
            username = pidestt.active_listen()

        username = username.lower()
        pidetts.speak("Your name is " + username + "? " + " Is this correct?")

        userQuery = ''
        while userQuery == '':
            userQuery = pidestt.active_listen()

        userQuery = userQuery.lower()
        if "yes" in userQuery or "yeah" in userQuery or "ja" in userQuery:
            for user in users:
                if user.name == username:
                    return False
            if path.exists('./data/users/' + username):
                print "USER: "******" exists!"
                return False
            if not path.exists('./data/users/' + username):
                mkdir('./data/users/' + username)
            psw = setPsw()
            homeLocation = setHomeLocation()
            userpath = './data/users/' + username + ''
            users.append(
                User(name=username,
                     password=psw,
                     directory=userpath,
                     home=homeLocation))
            pidetts.speak("Your user account is named " + username +
                          ". I have created a user folder for you at " +
                          userpath + ". Have fun.")
            pidetts.speak(
                "I will now take some pictures of you so I can recognize you next time I see you."
            )
            pidetts.speak(
                "Please look at the camera. I will tell you when I am done.")
            create_data.takePictures(username)
            pidetts.speak(
                "I have finished taking pictures and will recognize you next time I see you"
            )
            user = users[len(users) - 1]
            saveUsers(users)
            return
        elif "no" in userQuery or "nope" in userQuery:
            pidetts.speak("Okay, try to create a new user again.")
            return
        elif "exit" in userQuery:
            return
        elif "" in userQuery:
            userQuery = pidestt.active_listen()
    return
Пример #7
0
def userReport(users):
    pidetts.speak("These are the current accounts. ")
    for user in users:
        pidetts.speak(user.name)
        print(user.name, user.directory)
Пример #8
0
def GetUserRequest():
    pidetts.speak(" What can I do for you today? ")
    global currentUser
    while currentUser.name is not None:
        userQuery = pidestt.active_listen()
        userQuery = userQuery.lower()
        if "user" in userQuery or "who am i" in userQuery or "username" in userQuery:
            Repeater(userQuery)
            pidetts.speak(" You are currently logged in as " +
                          currentUser.name + "! ")
        elif "weather" in userQuery or "show me the weather" in userQuery or "how is the weather" in userQuery:
            WeatherModule()
        elif "shutdown" in userQuery:
            print "Shutting down client..."
            pidetts.speak(" Shutting down client... ")
            os.system("sudo shutdown now &")
        elif "logout" in userQuery or "log out" in userQuery or "logoff" in userQuery or "log off" in userQuery or "change user" in userQuery or "exit" in userQuery or "quit" in userQuery:
            print "Logging out user: "******" Logging out " + currentUser.name + "! ")
            del currentUser
            username = ''
            return
        elif "pictures" in userQuery:
            create_data.takePictures(currentUser.name)
        elif "report" in userQuery:
            usermanager.userReport(usermanager.users)
        elif "delete" in userQuery:
            usermanager.deleteUser(usermanager.users)
        elif "play" in userQuery or "song" in userQuery:
            PlaySong()
        elif "time" in userQuery or "clock" in userQuery:
            pidetts.speak(" The clock is " + strftime("%H:%M:%S", gmtime()))
        elif "date" in userQuery or "day" in userQuery:
            pidetts.speak(" Today is " + strftime("%d-%m-%Y"))
        elif "help" in userQuery:
            pidetts.speak(
                " Hello, " + currentUser.name +
                ". I am Piedee. Simply ask me about the weather and I will tell and show you the weather from around the world. "
            )
            pidetts.speak(
                " If you wonder if you are logged inn with the right profile, ask who am i? and I will tell you which user you are logged inn as. "
            )
            pidetts.speak(
                " If you want to end the current session simply say: exit. If you want to shut me down. Say shutdown. "
            )
        else:
            print "WAITING"
    #currentUser.logOut()

    while currentUser.name is None:
        pidetts.speak(" Please log into an account! ")
        return
Пример #9
0
def LoginVoice():
    pidetts.speak(" Who are you? ")
    while True:
        username = ''
        while username == '':
            username = pidestt.active_listen()

        username = username.lower()
        if "exit" in username:
            return False

        pidetts.speak(" Your name is " + username + "? " +
                      " Is this correct? ")

        userQuery = ''
        while userQuery == '':
            userQuery = pidestt.active_listen()

        userQuery = userQuery.lower()
        if "exit" in userQuery:
            pidetts.speak(" Exit login module ")
            return
        if "no" in userQuery or "lowe's" in userQuery or "low" in userQuery:
            pidetts.speak("Okay, one more time, who are you?")
        if "yes" in userQuery or "yeah" in userQuery or "ja" in userQuery:
            for user in usermanager.users:
                if user.name == username:
                    ConfirmPassword(username)
                    global currentUser
                    currentUser = user
                    return False
            pidetts.speak("I don't know you")
            pidetts.speak("Do you want to create a new user?")
            answ = ''
            while answ == '':
                answ = pidestt.active_listen()
                if "yes" in answ or "yeah" in answ or "ja" in answ:
                    CreateUser()
                    GetUserRequest()
                elif "no" in answ or "Lowe's" in answ or "low" in answ or "nei" in answ or "nope" in answ or "njet" in answ:
                    pidetts.speak("Ok... Bye!")
                    return False
                elif "exit" in answ:
                    return
Пример #10
0
def GetWeatherAtTime(location):
    pidetts.speak(" Today or at a number of days from now? ")
    atDay = ''
    while atDay == '':
        atDay = pidestt.active_listen()
        atDay = atDay.lower()
        if "exit" in atDay:
            return
        elif "now" in atDay or "today" in atDay or "present" in atDay:
            pidetts.speak("Getting weather for " + location + " now.")
            result = pideweather.weatherAtNow(location)
            pidetts.speak(result)
            return
        elif "tomorrow" in atDay or "1" in atDay or "one" in atDay:
            pidetts.speak(" Getting weather for tommorow at " + location +
                          " now.")
            pideweather.weatherAtDay(location, 2)
            return

        elif "2" in atDay or "two" in atDay:
            pideweather.weatherAtDay(location, 3)
            return
        elif "3" in atDay or "three" in atDay:
            pideweather.weatherAtDay(location, 4)
            return

        elif "4" in atDay or "four" in atDay:
            pideweather.weatherAtDay(location, 5)
            return

        elif "5" in atDay or "five" in atDay:
            pideweather.weatherAtDay(location, 6)
            return

        elif "help" in atDay:
            pidetts.speak(" Try today, tomorrow or a number up to five. ")
        else:
            pidetts.speak(" I am waiting ")
            atDay = ''
Пример #11
0
def GreetUser():
    pidetts.speak(" Hello " + currentUser.name + "! ")
Пример #12
0
def Repeater(userQuery):
    pidetts.speak(" You said " + userQuery + "! ")
Пример #13
0
def PlaySong():
    pidetts.speak(" You asked for it! ")
    os.system("omxplayer -o local ./data/media/ymca.mp3")
    return