예제 #1
0
def events():
    service = auth.get_calendar_service()
    now = (datetime.datetime.utcnow()).isoformat() + \
        'Z'  # 'Z' indicates UTC time
    print('Getting the upcoming 100 events')
    events, time_zone = calendar_api.get_events(service,
                                                end_cap=now,
                                                max_results=100)
    json_dict = {
        'timeZone':
        time_zone,
        'events':
        sorted([calendar_api.parse_event_info(e) for e in events],
               key=lambda e: e['start'])
    }
    for e in json_dict.get('events'):
        if e.get('zoom') == "":
            # No zoom link found, send email
            message = flask_mail.Message(
                subject='No Link included in your ZoomTV Event',
                body=
                "Your zoomTV event titled {} doesn't seem to have a Zoom link in the location or description. \
                Please add one so people can find your event!".format(
                    e.get('summary')),
                recipients=[str(e['creator'])])
            mail.send(message)
    return json.dumps(json_dict)
예제 #2
0
def good_morning(): 
	greeting = u'Bom dia, agora são %s!' % time.strftime("%H:%M", time.localtime())
 
	weather_com = pywapi.get_weather_from_weather_com('BRXX0222','metric')
	
	conditions = weather_com['current_conditions']
	weather = u' O tempo hoje está %s e faz %s graus lá fora!' % (conditions['text'],
																  conditions['temperature'])
	forecasts = weather_com['forecasts']
	weather += u' A máxima para hoje é de %s graus e a mínima é de %s!' % (forecasts[0]['high'],
																		   forecasts[0]['low'])
	weather += u' A chance de chuva é de %s %!' % forecasts[0]['day']['chance_precip']

	calendar = u'Seus eventos para hoje são: %s' % str(calendar_api.get_events())

	# saving and reproducing
	report = greeting + weather + calendar
	generate_mp3(report, "report.mp3")
	subprocess.Popen(['gst-launch-1.0', 'filesrc', 'location=/home/root/clock/report.mp3',
					  '!', 'mad', '!', 'pulsesink']) 
예제 #3
0
	
	# checks if you want to end the snooze and play the report
	while stop_button_pressed == False:
		if (datetime.utcnow().hour == snooze_time.hour and 
		    datetime.utcnow().minute == snooze_time.minute and
			datetime.utcnow().second == snooze_time.second):
			return False
		stop_button_pressed = stop_button.read()

	return True


if __name__ == "__main__":
	while True:	
		# get today events and set the alarm time 
		calendar_api.get_events()
		alarm_time = calendar_api.alarm_time
		
		# print alarm_time and now time to debug
		print("alarm time: " + str(alarm_time))
		print("now: " + str(datetime.utcnow()))

		# checks if it's time to wake up
		if (datetime.utcnow().hour == alarm_time.hour and
			datetime.utcnow().minute == alarm_time.minute):
			# checks if it's 10 secs before or after, since it takes some time to execute the code
			# so it can miss the exactly second
			if (datetime.utcnow().second >= alarm_time.second - 10 and
				datetime.utcnow().second <= alarm_time.second + 10):
				wake_up()