Esempio n. 1
0
def update_site_agenda(giedo):
    agendas = fetch()
    if agendas is None:
        logging.warning('agenda: could not fetch agenda')
        return {'error': 'Failed to fetch agendas'}
    update(agendas)
    return {'success': True}
Esempio n. 2
0
def update_site_agenda():
    agendas = fetch()
    if agendas is None:
        logging.warning('agenda: could not fetch agenda')
        return {'error': 'Failed to fetch agendas'}
    update(agendas)
    return {'success': True}
Esempio n. 3
0
def update_site_agenda(giedo):
    try:
        agendas = fetch()
    except Exception as err:
        return {'error': str(err)}
    if agendas is None:
        logging.warning('agenda: could not fetch agenda')
        return {'error': 'Failed to fetch agendas'}
    update(agendas)
    return {'success': True}
Esempio n. 4
0
def update_site_agenda(giedo):
    try:
        agendas = fetch()
    except Exception as err:
        return {'error': str(err)}
    if agendas is None:
        logging.warning('agenda: could not fetch agenda')
        return {'error': 'Failed to fetch agendas'}
    update(agendas)
    return {'success': True}
Esempio n. 5
0
def update_site_agenda(giedo):
    update(fetch())
    return {'success': True}
Esempio n. 6
0
    timeMin = datetime.datetime.utcnow().date().isoformat() + 'T00:00:00Z'
    cal = build('calendar', 'v3', http=h)
    request = cal.events().list(calendarId=cal_id,
                                timeMin=timeMin,
                                fields='items(summary,description,start,end)')
    response = request.execute()
    agenda = []
    for item in response['items']:
        agenda.append((item['summary'], item.get('description', ''),
                       parse_item_date(item['start']),
                       parse_item_date(item['end'])))
    return agenda


def fetch():
    h = httplib2.Http()
    credentials = get_credentials()
    credentials.authorize(h)

    agendas = {}
    for key, cal_id in settings.GOOGLE_CALENDAR_IDS.items():
        agendas[key] = fetch_agenda(h, cal_id)
    return agendas


if __name__ == '__main__':
    from kn.agenda.entities import update
    update(fetch())

# vim: et:sta:bs=2:sw=4:
Esempio n. 7
0
                                timeMin=timeMin,
                                fields='items(summary,description,start,end)')
    response = request.execute()
    agenda = []
    for item in response['items']:
        agenda.append((item.get('summary', '?'), item.get('description', ''),
                       parse_item_date(item['start']),
                       parse_item_date(item['end'])))
    return agenda


def fetch():
    h = httplib2.Http()
    credentials = get_credentials()
    credentials.authorize(h)

    try:
        agendas = {}
        for key, cal_id in settings.GOOGLE_CALENDAR_IDS.items():
            agendas[key] = fetch_agenda(h, cal_id)
        return agendas
    except httplib2.ServerNotFoundError:
        return None


if __name__ == '__main__':
    from kn.agenda.entities import update
    update(fetch())

# vim: et:sta:bs=2:sw=4: