当前位置: 首页>>代码示例>>Python>>正文


Python Component.fromIStream方法代码示例

本文整理汇总了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)
开发者ID:eventable,项目名称:CalendarServer,代码行数:32,代码来源:resource.py

示例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)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:9,代码来源:test_freebusyquery.py

示例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,))
开发者ID:eventable,项目名称:CalendarServer,代码行数:27,代码来源:resource.py

示例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)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:25,代码来源:test_freebusyquery.py

示例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"
            ))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:26,代码来源:scheduler.py


注:本文中的twistedcaldav.ical.Component.fromIStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。