コード例 #1
0
ファイル: erminig_core.py プロジェクト: cas--/erminig-ng
def getDeletedEventsFromLocal(pid, localSource, remoteSource, lastSync, progress):
	# get all events in the Trash:
	rows = cwrapper.getAllDeletedEvents(localSource, lastSync)
	if not rows:
		update_progress(progress, 1.0)
		return

	progress_inc = 1.0/3.0/len(rows)
	progress_val = 1.0/3.0*2
	for e in rows:
		progress_val = progress_val + progress_inc
		update_progress(progress, progress_val)

		gid = getGoogleIdFromLocalId(e)
		if not gid:
			continue

		try:
			event = google_api.run_google_action(google_api.gd_client.GetCalendarEventEntry, urllib.quote("/calendar/feeds/" + remoteSource + "/private/full/" + gid))

			if event == None:
				logger.append("Unable to get event to delete!")
				return 

			google_api.run_google_action(google_api.gd_client.DeleteEvent, event.GetEditLink().href)
		except ErminigGoogleError, e:
			error_win.display(e.title(), e.description())
			return
コード例 #2
0
def getDeletedEventsFromLocal(pid, localSource, remoteSource, lastSync,
                              progress):
    # get all events in the Trash:
    rows = cwrapper.getAllDeletedEvents(localSource, lastSync)
    if not rows:
        update_progress(progress, 1.0)
        return

    progress_inc = 1.0 / 3.0 / len(rows)
    progress_val = 1.0 / 3.0 * 2
    for e in rows:
        progress_val = progress_val + progress_inc
        update_progress(progress, progress_val)

        gid = getGoogleIdFromLocalId(e)
        if not gid:
            continue

        try:
            event = google_api.run_google_action(
                google_api.gd_client.GetCalendarEventEntry,
                urllib.quote("/calendar/feeds/" + remoteSource +
                             "/private/full/" + gid))

            if event == None:
                logger.append("Unable to get event to delete!")
                return

            google_api.run_google_action(google_api.gd_client.DeleteEvent,
                                         event.GetEditLink().href)
        except ErminigGoogleError, e:
            error_win.display(e.title(), e.description())
            return
コード例 #3
0
ファイル: erminig_core.py プロジェクト: cas--/erminig-ng
def getNewEventsFromGoogle(pid, localSource, remoteSource, lastSync, \
		                        progress):
	query = gdata.calendar.service.CalendarEventQuery(remoteSource, \
			'private', 'composite', None, {"ctz":"utc"})
	query.updated_min = timestampToIso8601(lastSync)
	query.updated_max = timestampToIso8601(int(time.time()))
	query.max_results = "100000"

	feed = None
	try:
		feed = google_api.run_google_action(google_api.gd_client.CalendarQuery, query)
	except ErminigGoogleError, e:
		error_win.display(e.title(), e.description())
		return
コード例 #4
0
def getNewEventsFromGoogle(pid, localSource, remoteSource, lastSync, \
                          progress):
    query = gdata.calendar.service.CalendarEventQuery(remoteSource, \
      'private', 'composite', None, {"ctz":"utc"})
    query.updated_min = timestampToIso8601(lastSync)
    query.updated_max = timestampToIso8601(int(time.time()))
    query.max_results = "100000"

    feed = None
    try:
        feed = google_api.run_google_action(google_api.gd_client.CalendarQuery,
                                            query)
    except ErminigGoogleError, e:
        error_win.display(e.title(), e.description())
        return
コード例 #5
0
ファイル: erminig_core.py プロジェクト: cas--/erminig-ng
def updateGoogleEvent(evt, googleid, pid):
	"""
	@type  evt:      L{Event.Event}
	@param googleid: name of calendar ?
	@type  googleid: unicode
	@type  pid:      int
	"""
	# get Googleid of event:
	gid = getGoogleIdFromLocalId(evt.get_id())
	if not gid:
		return

	event = None
	try:
		event = google_api.run_google_action(google_api.gd_client.GetCalendarEventEntry, urllib.quote("/calendar/feeds/" + googleid + "/private/full/" + gid))
	except ErminigGoogleError, e:
		error_win.display(e.title(), e.description())
		return
コード例 #6
0
def createNewGoogleEvent(evt, googleid, pid):

    start_time = timestampToIso8601(evt.get_start())
    end_time = timestampToIso8601(evt.get_end())

    # if it's a full-day event, then we can strip the start/end times:
    if evt.get_fullday() == 1:
        start_time = timestampToIso8601(
            int(evt.get_start()) + evt.get_tzOffset())
        end_time = timestampToIso8601(int(evt.get_end()) + evt.get_tzOffset())
        start_time = start_time[0:10]
        end_time = end_time[0:10]

        # Add artificially one day:
        td = datetime.timedelta(1)
        time_dt = datetime.datetime.strptime(end_time, "%Y-%m-%d")
        time_dt = time_dt + td
        end_time = time_dt.strftime("%Y-%m-%d")

    event = gdata.calendar.CalendarEventEntry()
    event.title = atom.Title(text=evt.get_title())
    event.content = atom.Content(text=evt.get_description())
    event.where.append(gdata.calendar.Where(value_string=evt.get_where()))
    # Differentiate for recurrence:
    if evt.get_rrule() <> "":
        rec_data = create_rrule(start_time, end_time, evt.get_rrule())
        event.recurrence = gdata.calendar.Recurrence(text=rec_data)
        event.reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()))
    else:
        event.when.append(
            gdata.calendar.When(start_time=start_time, end_time=end_time))
        event.when[0].reminder.append(
            gdata.calendar.Reminder(minutes=evt.get_alarm()))

    new_event = None
    try:
        new_event = google_api.run_google_action(
            google_api.gd_client.InsertEvent, event,
            urllib.quote('/calendar/feeds/' + googleid + '/private/full'))
    except ErminigGoogleError, e:
        error_win.display(e.title(), e.description())
        return
コード例 #7
0
def updateGoogleEvent(evt, googleid, pid):
    """
	@type  evt:      L{Event.Event}
	@param googleid: name of calendar ?
	@type  googleid: unicode
	@type  pid:      int
	"""
    # get Googleid of event:
    gid = getGoogleIdFromLocalId(evt.get_id())
    if not gid:
        return

    event = None
    try:
        event = google_api.run_google_action(
            google_api.gd_client.GetCalendarEventEntry,
            urllib.quote("/calendar/feeds/" + googleid + "/private/full/" +
                         gid))
    except ErminigGoogleError, e:
        error_win.display(e.title(), e.description())
        return
コード例 #8
0
ファイル: erminig_core.py プロジェクト: cas--/erminig-ng
def createNewGoogleEvent(evt, googleid, pid):

	start_time = timestampToIso8601(evt.get_start())
	end_time = timestampToIso8601(evt.get_end())

	# if it's a full-day event, then we can strip the start/end times:
	if evt.get_fullday() == 1:
		start_time = timestampToIso8601(int(evt.get_start())+evt.get_tzOffset())
		end_time = timestampToIso8601(int(evt.get_end())+evt.get_tzOffset())
		start_time = start_time[0:10]
		end_time = end_time[0:10]

		# Add artificially one day:
		td = datetime.timedelta(1)
		time_dt = datetime.datetime.strptime(end_time, "%Y-%m-%d")
		time_dt = time_dt + td
		end_time = time_dt.strftime("%Y-%m-%d")

	event = gdata.calendar.CalendarEventEntry()
	event.title = atom.Title(text=evt.get_title())
	event.content = atom.Content(text=evt.get_description())
	event.where.append(gdata.calendar.Where(value_string=evt.get_where()))
	# Differentiate for recurrence:
	if evt.get_rrule() <> "":
		rec_data = create_rrule(start_time, end_time, evt.get_rrule())
		event.recurrence = gdata.calendar.Recurrence(text=rec_data)
		event.reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));
	else:
		event.when.append(gdata.calendar.When(start_time=start_time, end_time=end_time))
		event.when[0].reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));

	new_event = None
	try:
		new_event = google_api.run_google_action(google_api.gd_client.InsertEvent, event, urllib.quote('/calendar/feeds/' + googleid + '/private/full'))
	except ErminigGoogleError, e:
		error_win.display(e.title(), e.description())
		return
コード例 #9
0
ファイル: erminig_core.py プロジェクト: cas--/erminig-ng
	if evt.get_rrule() <> "":
		rec_data = create_rrule(start_time, end_time, evt.get_rrule())
		event.recurrence = gdata.calendar.Recurrence(text=rec_data)
		if len(event.reminder) > 0:
			event.reminder[0].minutes = evt.get_alarm()
		else:
			event.reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));
	else:
		event.when[0] = gdata.calendar.When(start_time=start_time, end_time=end_time)
		if len(event.when[0].reminder) > 0:
			event.when[0].reminder[0].minutes = evt.get_alarm()
		else:
			event.when[0].reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));

	try:
		google_api.run_google_action(google_api.gd_client.UpdateEvent, event.GetEditLink().href, event)
	except ErminigGoogleError, e:
		error_win.display(e.title(), e.description())
		return

def getUpdatedEventsFromLocal(pid, localSource, remoteSource, lastSync, progress):
	# Those are events to update in Google:
	evts = queryUpdatedLocalEvents(lastSync, localSource)
	if not evts:
		update_progress(progress, 1.0/3*2)
		return

	progress_inc = 1.0/3.0/len(evts)
	progress_val = 1.0/3.0
	for e in evts:
		progress_val = progress_val + progress_inc
コード例 #10
0
        if len(event.reminder) > 0:
            event.reminder[0].minutes = evt.get_alarm()
        else:
            event.reminder.append(
                gdata.calendar.Reminder(minutes=evt.get_alarm()))
    else:
        event.when[0] = gdata.calendar.When(start_time=start_time,
                                            end_time=end_time)
        if len(event.when[0].reminder) > 0:
            event.when[0].reminder[0].minutes = evt.get_alarm()
        else:
            event.when[0].reminder.append(
                gdata.calendar.Reminder(minutes=evt.get_alarm()))

    try:
        google_api.run_google_action(google_api.gd_client.UpdateEvent,
                                     event.GetEditLink().href, event)
    except ErminigGoogleError, e:
        error_win.display(e.title(), e.description())
        return


def getUpdatedEventsFromLocal(pid, localSource, remoteSource, lastSync,
                              progress):
    # Those are events to update in Google:
    evts = queryUpdatedLocalEvents(lastSync, localSource)
    if not evts:
        update_progress(progress, 1.0 / 3 * 2)
        return

    progress_inc = 1.0 / 3.0 / len(evts)
    progress_val = 1.0 / 3.0