コード例 #1
0
ファイル: views.py プロジェクト: jeid64/pdpreg
def addevent(request):
#	cshUserName = request.headers["X-Webauth-User"]
	title = request.params['title']
	start = request.params['start']
	end = request.params['end']
	allDay = request.params['allDay']
	#closeddate = request.params['closeddate']
	print (title + start + end + allDay)
	start = convertFullTime(start)
	end = convertFullTime(end)
	gcal = GoogleCalendar()
	gcal.addEvent(start, end, title)
	return {'username' : 123, 'userNumber' : 0}
コード例 #2
0
ファイル: sync.py プロジェクト: kumarrus/google-calendar-sync
### Parse configuration file  ###
    config = ConfigParser.ConfigParser()
    # Get mandatory parameters
    try:
        config.read(config_file)
        g_username = config.get('google',  'username')
        g_password = config.get('google',  'password')
        ical_path = config.get('ical',  'path')
    except Exception,  e:
        print 'ERROR: not a valid configuration file, check',  config_file
        print type(e),  e.args,  e
        sys.exit(1)

### Initialization ###
    gcalendar = GoogleCalendar()
    icalendar = iCalCalendar(ical_path)

    # Login into Google Calendar
    gcalendar._ClientLogin(g_username,  g_password)

    all_calendars = gcalendar.cal_client.GetOwnCalendarsFeed()

    # Gcal name which has to be synchronized with the ical
    gcal_name = icalendar.calName() + '-sync'

    for a_calendar in all_calendars.entry:
        print 'Found the calendar %s' % a_calendar.title.text
        if a_calendar.title.text == gcal_name:
            print '*Found the calendar %s' % a_calendar.title.text
            a_c = a_calendar
コード例 #3
0
def main():
	if len(sys.argv) != 2:
		sys.stderr.write("Usage: wf_calendar_sync.py [YAML file]\n")
		exit(1)

	sys.stdout.write("(c) 2011 Jonas Gulle <*****@*****.**>\n\n")
	sys.stdout.write("Enter your Google Account credentials.\n")

	from getpass import getpass
	while True:
		try:
			username = raw_input(" Username: "******" Password: "******"%s\n" % e)

	calendars = calendar.get_calendars()
	sys.stdout.write("\nYour calendars:\n");
	for i, c in enumerate(calendars):
		sys.stdout.write(" %d: %s\n" % (i + 1, c["name"]))

	while True:
		try:
			i = int(raw_input("Select calendar: ")) - 1
			if i < 0:
				raise IndexError
			calendar.insert_uri = calendars[i]["insert_uri"]
			break
		except (IndexError, ValueError):
			sys.stderr.write("No such calendar exist\n")

	with open(sys.argv[1]) as f:
		doc = yaml.load(f.read())

	sys.stdout.write("\nCreating events, please wait.")
	for event in doc["Calendar"]:
		from datetime import timedelta
		start = event["Date"]
		# Default to 3 hours if length is omitted
		end = start + timedelta(hours=3)
		if event.has_key("Length"):
			end = start + timedelta(hours=int(event["Length"]))

		# Grab the first line as the title
		title = event["Event"].partition("\n")[0]

		def dress_str(s):
			try:
				return {u"MK": u"Mörk kostym", u"HD": u"Högtidsdräkt"}[s]
			except KeyError:
				return s

		content = u""
		if event.has_key("Dress code"):
			content = u"%s\n\nKlädkod: %s" % (event["Event"], dress_str(event["Dress code"]))
		else:
			content = event["Event"]

		calendar.insert_event(
			title,
			content,
			start_time=start.isoformat(),
			end_time=end.isoformat()
		)

		sys.stdout.write(".")

	sys.stdout.write("\nDone!\n")