예제 #1
0
    def query_calendar(self,uri,calendar_data,filter):
        self._log('querying for calendar data')
        
        # Convert filter to cnodes
        if filter:
            self._log('we got filter!')
            if filter.has_key('uid'):
                getuids = filter['uid']
                getall = False
            else:
                getuids = []
                getall = True
        else:
            getall = True

        if getall:
            return self.get_data(uri)
        else:
            visitor = Erebus2ICSVisitor()
            for uid in getuids:
                if self.itemids.has_key(uid):
                    ex_id = self.itemids[uid]
                else:
                    uid = uid.split('@')[0]
                    ex_id = create_exchange_id(uid)

                self._log('asked for element with uid: %s' % ex_id)

                try:
                    auth = ('Authorization', self.handler.headers['Authorization'])
                    b = ExchangeBackend(host=host,https=False,auth=auth)
                    it = b.get_item(ex_id)

                    visitor.run(it)
                except:
                    raise DAV_Error, 404

            cal = visitor.cal
            cal = cnode2ical(cal)
            return cal.as_string()
예제 #2
0
# -*- coding: utf-8 -*-

# Import events from an ics file into Exchange

import sys
sys.path.extend(['.', '../'])

from Backend.ExchangeBackend import *
from icalendar import Calendar as ICal
from Visitor.ToStringVisitor import *
from Visitor.ICS2ErebusVisitor import *
from Visitor.Erebus2ICSVisitor import *
from erebusconv import *
from CNode import *
from localpw import *

    
if len(sys.argv) != 2:
    print 'Usage: python %s <ical file>' % sys.argv[0]
    sys.exit()

f = sys.argv[1]
cont = open(f).read()
c = ICal.from_string(cont)
ctree = ical2cnode(c)

erebus = ICS2ErebusVisitor(ctree).run()

b = ExchangeBackend(host=host,https=False,user=username,password=password)
b.create_item(erebus)