示例#1
0
    def _multigetEvent(self):
        event = None

        multiget = webdavlib.CalDAVCalendarMultiget(
            self.resource, ["{urn:ietf:params:xml:ns:caldav}calendar-data"],
            [self.url])
        self.client.execute(multiget)
        if multiget.response["status"] != 404:
            event = self._calendarDataInMultistatus(multiget)

        return event
示例#2
0
    def _multigetEvent(self, event_class):
        event = None

        icsClass = self.classToICSClass[event_class]
        url = "%s%s-event.ics" % (self.resource, icsClass.lower())
        multiget = webdavlib.CalDAVCalendarMultiget(
            self.resource, ["{urn:ietf:params:xml:ns:caldav}calendar-data"],
            [url])
        self.subscriber_client.execute(multiget)
        if multiget.response["status"] != 404:
            event = self._calendarDataInMultistatus(multiget, url)

        return event
示例#3
0
def main():
  depth = 1
  synctoken = "1"
  url = None

  try:
   opts, args = getopt.getopt (sys.argv[1:], "hs:u:", \
                               ("sync-token=", "url="));
  except getopt.GetoptError:
    usage()
    exit(1)

  for o, v in opts :
    if o == "-h" :
      usage()
      exit(1)
    elif o == "-s" or o == "--sync-token" :
      synctoken = v
    elif o == "-u" or o == "--url" :
      url = v

  if url is None:
    usage()
    exit(1)

  o = urlparse.urlparse(url)
  hostname = o.hostname
  port = o.port
  username = o.username
  password = o.password
  uri = o.path

  client = webdavlib.WebDAVClient(hostname, port, username, password)

  collections = getAllCollections(client, uri)
  if len(collections) == 0:
    print "No collections found!"
    sys.exit(1)

  for collection in collections:
    changedItems = changedItemsFromCollection(client, collection) 
    # fetch the href data
    if len(changedItems) > 0:
      multiget = webdavlib.CalDAVCalendarMultiget(collection,
                                                  ["getetag", "{%s}calendar-data" % webdavlib.xmlns_caldav],
                                                  changedItems, depth)
      client.execute(multiget)
      client.conn.close()
      if (multiget.response["status"] != 207):
        raise Exception("Bad http response code: %d" % multiget.response["status"])