def updateCalendars(self): ## load calendar info (name, id, ctag) ret = util.requestData(hostname=util.mixHostUrl( self.hostname, self.homesetUrl), depth=1, data=static.XML_REQ_CALENDARINFO, auth=self.client.auth) # xmlTree = ElementTree(fromstring(ret.content)).getroot() xmlTree = util.XmlObject(ret.content) calendarList = [] for response in xmlTree.iter(): if response.find("href").text() == self.homesetUrl: continue calendar = self.client.Calendar( hostname=self.hostname, calendarUrl=response.find("href").text(), calendarName=response.find("propstat").find("prop").find( "displayname").text(), cTag=response.find("propstat").find("prop").find( "getctag").text(), client=self.client) calendarList.append(calendar) self.calendarList = calendarList return calendarList
def getCalendarData(self, eventList): splitRange = 40 resultList = [] for i in range(0, len(eventList), splitRange): eventSubList = eventList[i:i + splitRange] sendDataList = [] for eventItem in eventSubList: sendDataList.append( "<D:href xmlns:D=\"DAV:\">%s</D:href>" % (eventItem.eventUrl)) sendData = "\n".join(sendDataList) ret = util.requestData(method="REPORT", hostname=self.domainUrl, depth=1, data=static.XML_REQ_CALENDARDATA % (sendData), auth=self.client.auth) xmlTree = util.XmlObject(ret.content) for response in xmlTree.iter(): if response.find("href").text == self.calendarUrl: continue event = self.client.Event( eventUrl=response.find("href").text(), eTag=response.find("propstat").find("prop").find( "getetag").text(), eventData=response.find("propstat").find("prop").find( "calendar-data").text()) resultList.append(event) return resultList
def getCTag(self): ## load ctag ret = util.requestData(hostname=self.domainUrl, depth=1, data=static.XML_REQ_CALENDARCTAG, auth=self.client.auth) xmlTree = util.XmlObject(ret.content) cTag = xmlTree.find("response").find("propstat").find("prop").find( "getctag").text() self.cTag = cTag return cTag
def updateHomeSet(self): ## load calendar url ret = util.requestData(hostname=self.domainUrl, depth=0, data=static.XML_REQ_HOMESET, auth=self.client.auth) # xmlTree = ElementTree(fromstring(ret.content)).getroot() xmlTree = util.XmlObject(ret.content) homeset = self.client.HomeSet( hostname=self.hostname, homesetUrl=xmlTree.find("response").find("propstat").find( "prop").find("calendar-home-set").find("href").text(), client=self.client) self.homeset = homeset return homeset
def updatePrincipal(self): ret = util.requestData(hostname=self.hostname, depth=0, data=static.XML_REQ_PRINCIPAL, auth=self.auth) # xmlTree = ElementTree(fromstring(ret.content)).getroot() xmlTree = util.XmlObject(ret.content) xmlTree.find("response").text principal = self.Principal( hostname=self.hostname, principalUrl=xmlTree.find("response").find("propstat").find( "prop").find("current-user-principal").find("href").text(), client=self) self.principal = principal return principal
def getEventByRange(self, stDate, edDate): ret = util.requestData(method="REPORT", hostname=self.domainUrl, depth=1, data=static.XML_REQ_CALENDARDATEFILTER % (stDate, edDate), auth=self.client.auth) xmlTree = util.XmlObject(ret.content) eventList = [] for response in xmlTree.iter(): if response.find("href").text == self.calendarUrl: continue event = self.client.Event( eventUrl=response.find("href").text(), eTag=response.find("propstat").find("prop").find( "getetag").text()) eventList.append(event) return eventList
def updateAllEvent(self): ## load all event (etag, info) ret = util.requestData(hostname=self.domainUrl, depth=1, data=static.XML_REQ_CALENDARETAG, auth=self.client.auth) # xmlTree = ElementTree(fromstring(ret.content)).getroot() xmlTree = util.XmlObject(ret.content) eventList = [] for response in xmlTree.iter(): if response.find("href").text == self.calendarUrl: continue event = self.client.Event( eventUrl=response.find("href").text(), eTag=response.find("propstat").find("prop").find( "getetag").text()) eventList.append(event) #save event data self.eventList = eventList return eventList