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


Python Logger.error方法代码示例

本文整理汇总了Python中twext.python.log.Logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.error方法的具体用法?Python Logger.error怎么用?Python Logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twext.python.log.Logger的用法示例。


在下文中一共展示了Logger.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: returnValue

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
        returnValue(True)

    # Run report taking depth into account
    try:
        depth = request.headers.getHeader("depth", "0")
        yield report_common.applyToCalendarCollections(self, request, request.uri, depth, doQuery, (davxml.Read(),))
    except TooManyInstancesError, ex:
        log.error("Too many instances need to be computed in calendar-query report")
        raise HTTPError(ErrorResponse(
            responsecode.FORBIDDEN,
            MaxInstances.fromString(str(ex.max_allowed)),
            "Too many instances",
        ))
    except NumberOfMatchesWithinLimits:
        log.error("Too many matching components in calendar-query report")
        raise HTTPError(ErrorResponse(
            responsecode.FORBIDDEN,
            davxml.NumberOfMatchesWithinLimits(),
            "Too many components",
        ))
    except TimeRangeLowerLimit, e:
        raise HTTPError(ErrorResponse(
            responsecode.FORBIDDEN,
            caldavxml.MinDateTime(),
            "Time-range value too far in the past. Must be on or after %s." % (str(e.limit),)
        ))
    except TimeRangeUpperLimit, e:
        raise HTTPError(ErrorResponse(
            responsecode.FORBIDDEN,
            caldavxml.MaxDateTime(),
开发者ID:nunb,项目名称:calendarserver,代码行数:32,代码来源:report_calendar_query.py

示例2: HTTPError

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
        log.debug("Wiki ACL result: user [%s], wiki [%s], FAULT [%s]" % (userID,
            wikiID, fault))

        if fault.faultCode == 2: # non-existent user
            raise HTTPError(StatusResponse(responsecode.FORBIDDEN,
                fault.faultString))

        elif fault.faultCode == 12: # non-existent wiki
            raise HTTPError(StatusResponse(responsecode.NOT_FOUND,
                fault.faultString))

        else:
            # Unknown fault returned from wiki server.  Log the error and
            # return 503 Service Unavailable to the client.
            log.error("Wiki ACL error: user [%s], wiki [%s], FAULT [%s]" %
                (userID, wikiID, fault))
            raise HTTPError(StatusResponse(responsecode.SERVICE_UNAVAILABLE,
                fault.faultString))

    except WebError, w:
        status = int(w.status)

        log.debug("Wiki ACL result: user [%s], wiki [%s], status [%s]" %
            (userID, wikiID, status))

        if status == responsecode.FORBIDDEN: # non-existent user
            raise HTTPError(StatusResponse(responsecode.FORBIDDEN,
                "Unknown User"))

        elif status == responsecode.NOT_FOUND: # non-existent wiki
            raise HTTPError(StatusResponse(responsecode.NOT_FOUND,
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:33,代码来源:wiki.py

示例3: in

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
    try:
        response = (yield agent.request(method, url, headers, None))
    except Exception, e:
        log.err(str(e))
        response = None
    else:
        if response.code in (MOVED_PERMANENTLY, FOUND, TEMPORARY_REDIRECT,):
            if redirect > 3:
                log.err("Too many redirects")
            else:
                location = response.headers.getRawHeaders("location")
                if location:
                    newresponse = (yield getURL(location[0], method=method, redirect=redirect + 1))
                    if response.code == MOVED_PERMANENTLY:
                        scheme, netloc, url, _ignore_params, _ignore_query, _ignore_fragment = urlparse(location[0])
                        newresponse.location = urlunparse((scheme, netloc, url, None, None, None,))
                    returnValue(newresponse)
                else:
                    log.err("Redirect without a Location header")

    if response is not None and response.code / 100 == 2:
        protocol = AccumulatingProtocol()
        response.deliverBody(protocol)
        whenFinished = protocol.closedDeferred = Deferred()
        yield whenFinished
        response.data = protocol.data
    else:
        log.error("Failed getURL: %s" % (url,))

    returnValue(response)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:32,代码来源:geturl.py

示例4: getattr

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
        request.submethod = name

    try:
        method = getattr(self, method_name)
        
        # Also double-check via supported-reports property
        reports = self.supportedReports()
        test = lookupElement((namespace, name))
        if not test:
            raise AttributeError()
        test = davxml.Report(test())
        if test not in reports:
            raise AttributeError()
    except AttributeError:
        #
        # Requested report is not supported.
        #
        log.error("Unsupported REPORT %s for resource %s (no method %s)"
                  % (encodeXMLName(namespace, name), self, method_name))

        raise HTTPError(ErrorResponse(
            responsecode.FORBIDDEN,
            davxml.SupportedReport()
        ))

    d = waitForDeferred(method(request, doc.root_element))
    yield d
    yield d.getResult()

http_REPORT = deferredGenerator(http_REPORT)
开发者ID:anemitz,项目名称:calendarserver,代码行数:32,代码来源:report.py

示例5: getURL

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
def getURL(url, method="GET", redirect=0):

    if isinstance(url, unicode):
        url = url.encode("utf-8")
    agent = Agent(reactor)
    headers = http_headers.Headers({})

    try:
        response = (yield agent.request(method, url, headers, None))
    except Exception, e:
        log.error(str(e))
        response = None
    else:
        if response.code in (MOVED_PERMANENTLY, FOUND, TEMPORARY_REDIRECT,):
            if redirect > 3:
                log.error("Too many redirects")
            else:
                location = response.headers.getRawHeaders("location")
                if location:
                    newresponse = (yield getURL(location[0], method=method, redirect=redirect + 1))
                    if response.code == MOVED_PERMANENTLY:
                        scheme, netloc, url, _ignore_params, _ignore_query, _ignore_fragment = urlparse(location[0])
                        newresponse.location = urlunparse((scheme, netloc, url, None, None, None,))
                    returnValue(newresponse)
                else:
                    log.error("Redirect without a Location header")

    if response is not None and response.code / 100 == 2:
        protocol = AccumulatingProtocol()
        response.deliverBody(protocol)
        whenFinished = protocol.closedDeferred = Deferred()
开发者ID:eventable,项目名称:CalendarServer,代码行数:33,代码来源:geturl.py

示例6: getNCPU

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
    Determine how many process to spawn based on installed RAM and CPUs,
    returning at least "mininum"
    """

    if cpuCount is None:
        try:
            cpuCount = getNCPU()
        except NotImplementedError, e:
            log.error("Unable to detect number of CPUs: %s" % (str(e),))
            return minimum

    if memSize is None:
        try:
            memSize = getMemorySize()
        except NotImplementedError, e:
            log.error("Unable to detect amount of installed RAM: %s" % (str(e),))
            return minimum

    countByCore = perCPU * cpuCount
    countByMemory = perGB * (memSize / (1024 * 1024 * 1024))

    # Pick the smaller of the two:
    count = min(countByCore, countByMemory)

    # ...but at least "minimum"
    return max(count, minimum)


##
# Module management
##
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:33,代码来源:util.py

示例7: davXMLFromStream

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
    # Read request body
    #
    try:
        doc = (yield davXMLFromStream(request.stream))
        yield self.createCalendar(request)
    except ValueError, e:
        log.error("Error while handling MKCALENDAR: %s" % (e,))
        raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e)))

    set_supported_component_set = False
    if doc is not None:
        makecalendar = doc.root_element
        if not isinstance(makecalendar, caldavxml.MakeCalendar):
            error = ("Non-%s element in MKCALENDAR request body: %s"
                     % (caldavxml.MakeCalendar.name, makecalendar))
            log.error("Error: {err}", err=error)
            raise HTTPError(StatusResponse(responsecode.UNSUPPORTED_MEDIA_TYPE, error))

        errors = PropertyStatusResponseQueue("PROPPATCH", request.uri, responsecode.NO_CONTENT)
        got_an_error = False

        if makecalendar.children:
            # mkcalendar -> set -> prop -> property*
            for property in makecalendar.children[0].children[0].children:
                try:
                    if property.qname() == (caldavxml.caldav_namespace, "supported-calendar-component-set"):
                        yield self.setSupportedComponentSet(property)
                        set_supported_component_set = True
                    else:
                        yield self.writeProperty(property, request)
                except HTTPError:
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:33,代码来源:mkcalendar.py

示例8: SimpleRedirectResource

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
                    port = config.SSLPort
                else:
                    scheme = "http"
                    port = config.HTTPPort
                wellKnownResource.putChild(
                    wellknown_name,
                    SimpleRedirectResource(
                        principalCollections=(principalCollection,),
                        isdir=False,
                        defaultACL=SimpleResource.allReadACL,
                        scheme=scheme, port=port, path=redirected_to)
                )

    for name, info in config.Aliases.iteritems():
        if os.path.sep in name or not info.get("path", None):
            log.error("Invalid alias: %s" % (name,))
            continue
        log.info("Adding alias %s -> %s" % (name, info["path"]))
        resource = FileResource(info["path"])
        root.putChild(name, resource)

    # Timezone service is optional
    if config.EnableTimezoneService:
        log.info("Setting up time zone service resource: %r"
                      % (timezoneServiceResourceClass,))

        timezoneService = timezoneServiceResourceClass(
            root,
        )
        root.putChild("timezones", timezoneService)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:32,代码来源:util.py

示例9: SimpleRedirectResource

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
                    scheme = "http"
                    port = config.HTTPPort
                wellKnownResource.putChild(
                    wellknown_name,
                    SimpleRedirectResource(
                        principalCollections=(principalCollection,),
                        isdir=False,
                        defaultACL=SimpleResource.allReadACL,
                        scheme=scheme, port=port, path=redirected_to)
                )

    for alias in config.Aliases:
        url = alias.get("url", None)
        path = alias.get("path", None)
        if not url or not path or url[0] != "/":
            log.error("Invalid alias: URL: {url}  Path: {path}", url=url, path=path)
            continue
        urlbits = url[1:].split("/")
        parent = root
        for urlpiece in urlbits[:-1]:
            child = parent.getChild(urlpiece)
            if child is None:
                child = Resource()
                parent.putChild(urlpiece, child)
            parent = child
        if parent.getChild(urlbits[-1]) is not None:
            log.error("Invalid alias: URL: {url}  Path: {path} already exists", url=url, path=path)
            continue
        resource = FileResource(path)
        parent.putChild(urlbits[-1], resource)
        log.info("Added alias {url} -> {path}", url=url, path=path)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:33,代码来源:util.py

示例10: log_traceback

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
                log_traceback()
                log.error("ImplicitProcessing - originator '%s' to recipient '%s' with UID: '%s' - exception raised will try to fix: %s" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid, e))
                result = (yield self.doImplicitAttendeeEventFix(e))
                if result:
                    log.error("ImplicitProcessing - originator '%s' to recipient '%s' with UID: '%s' - restored organizer's copy" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
                    try:
                        result = (yield self.doImplicitAttendee())
                    except Exception, e:
                        log_traceback()
                        log.error("ImplicitProcessing - originator '%s' to recipient '%s' with UID: '%s' - exception raised after fix: %s" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid, e))
                        raise ImplicitProcessorException("5.1;Service unavailable")
                else:
                    log.error("ImplicitProcessing - originator '%s' to recipient '%s' with UID: '%s' - could not fix" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
                    raise ImplicitProcessorException("5.1;Service unavailable")
        else:
            log.error("METHOD:%s not supported for implicit scheduling." % (self.method,))
            raise ImplicitProcessorException("3.14;Unsupported capability")

        returnValue(result)


    def extractCalendarData(self):

        # Some other useful things
        self.method = self.message.propertyValue("METHOD")
        self.uid = self.message.resourceUID()


    def isOrganizerReceivingMessage(self):
        return self.method in ("REPLY", "REFRESH")
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:32,代码来源:processing.py

示例11: HTTPError

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
    except ValueError, e:
        log.error("Error while handling PROPFIND body: %s" % (e,))
        raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e)))

    if doc is None:
        # No request body means get all properties.
        search_properties = "all"
    else:
        #
        # Parse request
        #
        find = doc.root_element
        if not isinstance(find, davxml.PropertyFind):
            error = ("Non-%s element in PROPFIND request body: %s"
                     % (davxml.PropertyFind.sname(), find))
            log.error("Error: {err}", err=error)
            raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, error))

        container = find.children[0]

        if isinstance(container, davxml.AllProperties):
            # Get all properties
            search_properties = "all"
        elif isinstance(container, davxml.PropertyName):
            # Get names only
            search_properties = "names"
        elif isinstance(container, davxml.PropertyContainer):
            properties = container.children
            search_properties = [(p.namespace, p.name) for p in properties]
        else:
            raise AssertionError("Unexpected element type in %s: %s"
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:33,代码来源:propfind.py

示例12: lookupElement

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
        # Also double-check via supported-reports property
        reports = self.supportedReports()
        test = lookupElement((namespace, name))
        if not test:
            raise AttributeError()
        test = davxml.Report(test())
        if test not in reports:
            raise AttributeError()
    except AttributeError:
        #
        # Requested report is not supported.
        #
        log.error(
            "Unsupported REPORT {name} for resource {resource} (no method {method})",
            name=encodeXMLName(namespace, name),
            resource=self,
            method=method_name,
        )

        raise HTTPError(
            ErrorResponse(responsecode.FORBIDDEN, davxml.SupportedReport(), "Report not supported on this resource")
        )

    #
    # Check authentication and access controls
    #
    privileges = (davxml.Read(),)
    if method_name == "report_urn_ietf_params_xml_ns_caldav_free_busy_query":
        privileges = (caldavxml.ReadFreeBusy(),)
    yield self.authorize(request, privileges)
开发者ID:eventable,项目名称:CalendarServer,代码行数:32,代码来源:report.py

示例13: SimpleResource

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
        wellKnownResource = SimpleResource(
            principalCollections=(principalCollection,),
            isdir=True,
            defaultACL=SimpleResource.allReadACL
        )
        root.putChild(".well-known", wellKnownResource)
        for enabled, wellknown_name in (
            (config.EnableCalDAV, "caldav",),
            (config.EnableCardDAV, "carddav"),
        ):
            if enabled:
                wellKnownResource.putChild(wellknown_name, RedirectResource(path="/"))

    for name, info in config.Aliases.iteritems():
        if os.path.sep in name or not info.get("path", None):
            log.error("Invalid alias: %s" % (name,))
            continue
        log.info("Adding alias %s -> %s" % (name, info["path"]))
        resource = FileResource(info["path"])
        root.putChild(name, resource)

    # Timezone service is optional
    if config.EnableTimezoneService:
        log.info("Setting up time zone service resource: %r"
                      % (timezoneServiceResourceClass,))

        timezoneService = timezoneServiceResourceClass(
            root,
        )
        root.putChild("timezones", timezoneService)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:32,代码来源:util.py

示例14: xattrname

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
                    for attr, value in xattr.xattr(calPath).iteritems():
                        if attr == xattrname("{urn:ietf:params:xml:ns:caldav}calendar-free-busy-set"):
                            value = updateFreeBusySet(value, directory)
                            if value is not None:
                                # Need to write the xattr back to disk
                                xattr.setxattr(calPath, attr, value)
                except IOError, ioe:
                    if ioe.errno == errno.EOPNOTSUPP:
                        # On non-native xattr systems we cannot do this,
                        # but those systems will typically not be migrating
                        # from pre-v1
                        pass
                except:
                    raise
    except Exception, e:
        log.error("Failed to upgrade calendar home %s: %s" % (homePath, e))
        raise

    return errorOccurred



class UpgradeOneHome(Command):
    arguments = [('path', String())]
    response = [('succeeded', Boolean())]



class To1Driver(AMP):
    """
    Upgrade driver which runs in the parent process.
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:33,代码来源:upgrade.py

示例15: ValueError

# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import error [as 别名]
                    log.error(msg)
                    if not ignoreIPLookupFailures:
                        raise ValueError(msg)
                else:
                    actual_ips.update(ips)
            else:
                actual_ips.add(item)
        self.allowed_from_ips = actual_ips

        for uri in self.partitions.values():
            parsed_uri = urlparse.urlparse(uri)
            try:
                ips = getIPsFromHost(parsed_uri.hostname)
            except socket.gaierror, e:
                msg = "Unable to lookup ip-addr for partition '%s': %s" % (parsed_uri.hostname, str(e))
                log.error(msg)
                if ignoreIPLookupFailures:
                    ips = ()
                else:
                    raise ValueError(msg)
            self.partitions_ips.update(ips)


    def checkThisIP(self, ip):
        """
        Check that the passed in IP address corresponds to this server or one of its partitions.
        """
        return (ip in self.ips) or (ip in self.partitions_ips)


    def hasAllowedFromIP(self):
开发者ID:anemitz,项目名称:calendarserver,代码行数:33,代码来源:localservers.py


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