本文整理汇总了Python中twistedcaldav.ical.Component.fromIStream方法的典型用法代码示例。如果您正苦于以下问题:Python Component.fromIStream方法的具体用法?Python Component.fromIStream怎么用?Python Component.fromIStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twistedcaldav.ical.Component
的用法示例。
在下文中一共展示了Component.fromIStream方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadCalendarFromRequest
# 需要导入模块: from twistedcaldav.ical import Component [as 别名]
# 或者: from twistedcaldav.ical.Component import fromIStream [as 别名]
def loadCalendarFromRequest(self, request):
# Must be content-type text/calendar
contentType = request.headers.getHeader("content-type")
if contentType is not None and (contentType.mediaType, contentType.mediaSubtype) != ("text", "calendar"):
self.log.error(
"MIME type {ct} not allowed in iSchedule POST request",
ct=contentType,
)
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
(ischedule_namespace, "invalid-calendar-data-type"),
"Data is not calendar data",
))
# Parse the calendar object from the HTTP request stream
try:
calendar = (yield Component.fromIStream(request.stream))
except:
# FIXME: Bare except
self.log.error(
"Error while handling iSchedule POST: {f}",
f=Failure(),
)
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
(ischedule_namespace, "invalid-calendar-data"),
description="Can't parse calendar data"
))
returnValue(calendar)
示例2: do_test
# 需要导入模块: from twistedcaldav.ical import Component [as 别名]
# 或者: from twistedcaldav.ical.Component import fromIStream [as 别名]
def do_test(response):
response = IResponse(response)
if response.code != responsecode.OK:
self.fail("REPORT failed: %s" % (response.code,))
return Component.fromIStream(response.stream).addCallback(got_calendar)
示例3: loadCalendarFromRequest
# 需要导入模块: from twistedcaldav.ical import Component [as 别名]
# 或者: from twistedcaldav.ical.Component import fromIStream [as 别名]
def loadCalendarFromRequest(self, request):
# Must be content-type text/calendar
contentType = request.headers.getHeader("content-type")
format = self.determineType(contentType)
if format is None:
self.log.error("MIME type %s not allowed in calendar collection" % (contentType,))
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
(caldav_namespace, "supported-calendar-data"),
"Data is not calendar data",
))
# Parse the calendar object from the HTTP request stream
try:
calendar = (yield Component.fromIStream(request.stream, format=format))
except:
# FIXME: Bare except
self.log.error("Error while handling POST: %s" % (Failure(),))
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
(caldav_namespace, "valid-calendar-data"),
description="Can't parse calendar data"
))
returnValue((calendar, format,))
示例4: free_busy_query
# 需要导入模块: from twistedcaldav.ical import Component [as 别名]
# 或者: from twistedcaldav.ical.Component import fromIStream [as 别名]
def free_busy_query(self, calendar_uri, query, got_calendar):
request = SimpleRequest(self.site, "MKCALENDAR", calendar_uri)
response = yield self.send(request)
response = IResponse(response)
if response.code != responsecode.CREATED:
self.fail("MKCALENDAR failed: %s" % (response.code,))
yield addEventsDir(self, FilePath(self.holidays_dir), calendar_uri)
request = SimpleRequest(self.site, "REPORT", calendar_uri)
request.stream = MemoryStream(query.toxml())
response = yield self.send(request)
response = IResponse(response)
if response.code != responsecode.OK:
self.fail("REPORT failed: %s" % (response.code,))
result = yield Component.fromIStream(response.stream).addCallback(
got_calendar
)
returnValue(result)
示例5: loadCalendarFromRequest
# 需要导入模块: from twistedcaldav.ical import Component [as 别名]
# 或者: from twistedcaldav.ical.Component import fromIStream [as 别名]
def loadCalendarFromRequest(self):
# Must be content-type text/calendar
contentType = self.request.headers.getHeader("content-type")
if contentType is not None and (contentType.mediaType, contentType.mediaSubtype) != ("text", "calendar"):
log.err("MIME type %s not allowed in calendar collection" % (contentType,))
raise HTTPError(self.errorResponse(
responsecode.FORBIDDEN,
self.errorElements["invalid-calendar-data-type"],
"Data is not calendar data",
))
# Parse the calendar object from the HTTP request stream
try:
self.calendar = (yield Component.fromIStream(self.request.stream))
self.preProcessCalendarData()
except:
# FIXME: Bare except
log.err("Error while handling %s: %s" % (self.method, Failure(),))
raise HTTPError(self.errorResponse(
responsecode.FORBIDDEN,
self.errorElements["invalid-calendar-data"],
description="Can't parse calendar data"
))