def execute(self, operand): if operand.strip() == "": outputs.print_error("Nothing to remind you of.") return if not "in" in operand: #TODO too hard coded? self.debug("no \"in\", Exiting.") return operand_parts = operand.split(" in ") content = " in ".join(operand_parts[:-1]) moment = operand_parts[-1] if not " " in moment: self.debug("No space in moment, Exiting.") return try: delta = parse.time_delta(moment) except exceptions.PAULAParseException as e: outputs.print_error("An error occured while parsing the time delta.", error=e) return treated_content = self.treat_content(content) schedule.schedule_event_with_delta(delta, "paula_remind", treated_content) speech.say_random_from_file(self.get_resource_path('confirmation.paula_says'))
def coach(self, exercise, rest_duration, workout_list): """ Coaches the given scheme of the given exercise. @param exercise: The given exercise. @param rest_duration: The amount of rest between each set. @param workout_list: The list of reps in the sets. @return: """ for w in workout_list[:-1]: speech.say(str(w) + " " + exercise + ", Sir.") if not inputs.get_boolean(): speech.say("Done, Sir?") if inputs.get_boolean(): self.debug("Exiting.") return if not self.get_debug(): speech.say_random_from_file(self.get_resource_path('break.paula_says')) self.rest(rest_duration) speech.say("For the last set, do at least " + str(workout_list[-1]) + " " + exercise + ", Sir.") if not inputs.get_boolean(): speech.say("Too bad, Sir.") return speech.say_random_from_file(self.get_resource_path('done.paula_says'))
def execute(self, operand): speech.say("How long would you like to sleep, Sir?") option = inputs.get_item_from_dict(self.get_config('DURATION_OPTIONS')) # select song speech.say("Please select which song you want to wake you up.") s = song.choose() speech.say_random_from_file(self.get_resource_path('night.paula_says'), sync=True) # Set volume to something pleasant system_volume.set(self.get_config('PLEASANT_WAKE_UP_VOLUME')) # Sleep sleep.go_to_sleep_mode(int(option)) # Alarm go off speech.say_random_from_file(self.get_resource_path('morning.paula_says'), sync=True) now = datetime.datetime.now() hour_min = 'It is %H:%M' if now.hour < 9: hour_min += "in the morning." speech.say(now.strftime(hour_min), sync=True) month_day = "We are the %-d" day = now.day if day in self.get_config('DAY_SUFFIXES').keys(): month_day += self.get_config('DAY_SUFFIXES')[day] else: month_day += "th" month_day += ' %B %Y' speech.say(now.strftime(month_day), sync=True) subp = s.play() answer = inputs.get_string_timeout(self.get_config('WAKE_UP_TIME')) if not answer: # Wait until the song has finished subp.wait() try: subp.kill() except ProcessLookupError: pass speech.say_random_from_file(self.get_resource_path('up.paula_says')) # Show quote print((str(quote.get_random()))) # Get agenda for next few days agenda.print_default()