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()
def execute(self, operand): speech.say("How long do you think you will be gone, Sir?") answer = inputs.get_string() delta = parse.time_delta(answer) speech.say_all_from_file(self.get_resource_path('greetings.paula_says'), sync=True) sleep.go_to_sleep_mode(delta.seconds) answer = inputs.get_string_timeout(self.get_config('WAITING_TIME')) if not answer: sleep.go_to_sleep_mode(0) else: speech.say("Welcome back, Sir")