def execute(self, operand):
        self.debug("Reminding " + operand)

        cmd = "play " + self.get_resource_path('ding.mp3')
        system.call_silently(cmd, sync=True)

        speech.say("Sir, " + operand, sync=False)
        response = inputs.get_string_timeout(self.get_config('TIME_OUT'))
        if not response:
            self.reschedule(operand)

        if meaning.means(response, "okay"):
            return
        elif meaning.means(response, "not_okay"):
            self.debug("Reminding again in one day.")
            reschedule_str = inputs.get_string("Schedule again in: ")
            try:
                delta = parse.time_delta(reschedule_str)
            except exceptions.PAULAParseException as e:
                outputs.print_error(str(e.__class__))

            # fix bash issues again
            operand = operand.replace("\"", "\\\"")
            operand = operand.replace("\'", "\\\'")
            schedule.schedule_event_with_delta(delta, "paula_remind", operand)
        else:
            self.reschedule(operand)
def numeral_and_quantifier(string):
    if len(string.split()) != 2: #TODO is this too hard coded?
        raise exceptions.PAULAParseException("Too many spaces to parse:  \"" + string + "\"")
    numeral, quantifier = string.split()
    num = get_numeral_int(numeral)
    delta_seconds = 0
    delta_minutes = 0
    delta_hours = 0
    delta_days = 0
    delta_weeks = 0

    if meaning.means(quantifier, "seconds"):
        delta_seconds = num
    elif meaning.means(quantifier, "minutes"):
        delta_minutes = num
    elif meaning.means(quantifier, "hours"):
        delta_hours = num
    elif meaning.means(quantifier, "days"):
        delta_days = num
    elif meaning.means(quantifier, "weeks"):
        delta_weeks = num
    else:
        raise exceptions.PAULAUnknownQuantifierException

    delta = timedelta(days=delta_days, seconds=delta_seconds, minutes=delta_minutes, hours=delta_hours,
                      weeks=delta_weeks)
    return delta
Ejemplo n.º 3
0
def prompt_for_input_boolean(prompt=""):
    """
    Prompt the user for a boolean, optionally given a specific prompt.
    @param prompt: A given prompt string
    @return: A boolean of the user's choice.
    """
    while True:
        answer = string.prompt_for_input_string(prompt=prompt)
        if meaning.means(answer, "yes"):
            return True
        elif meaning.means(answer, "no"):
            return False
        else:
            outputs.print_error("Not a Boolean value.")
    def execute(self, operand):
        search_string = operand
        self.debug("The search string: " + search_string)
        local_song = song.find_song(search_string)

        if local_song:
            self.debug("Found local song!")
            local_song.play()
            return

        #We didn't find it locally; check youtube!
        vid_id, name = youtube.search_first_hit(search_string)
        youtube.play_song(vid_id, name)

        if self.get_config('ASK_DOWNLOAD'):
            print("Do you want to download this song?")
            answer = inputs.get_string()
            if meaning.means(answer, "yes"):
                youtube.download_song(vid_id)