本文整理汇总了Python中twext.python.log.Logger.err方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.err方法的具体用法?Python Logger.err怎么用?Python Logger.err使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twext.python.log.Logger
的用法示例。
在下文中一共展示了Logger.err方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HTTPError
# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import err [as 别名]
except ValueError, e:
log.err("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.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"
示例2: waitForDeferred
# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import err [as 别名]
# Read request body
#
doc = waitForDeferred(davXMLFromStream(request.stream))
yield doc
try:
doc = doc.getResult()
except ValueError, e:
log.err("Error while handling ACL body: %s" % (e,))
raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e)))
#
# Set properties
#
if doc is None:
error = "Request XML body is required."
log.err(error)
raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, error))
#
# Parse request
#
acl = doc.root_element
if not isinstance(acl, davxml.ACL):
error = ("Request XML body must be an acl element."
% (davxml.PropertyUpdate.sname(),))
log.err(error)
raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, error))
#
# Do ACL merger
#
示例3: getURL
# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import err [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.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()
示例4: returnValue
# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import err [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.err("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.err("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(),
示例5: returnValue
# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import err [as 别名]
destinationparent = parent,
calendar = calendardata,
)
result = (yield storer.run())
returnValue(result)
except ValueError, e:
log.err("Error while handling (calendar) PUT: %s" % (e,))
raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e)))
elif isAddressBookCollectionResource(parent):
# Content-type check
content_type = request.headers.getHeader("content-type")
if content_type is not None and (content_type.mediaType, content_type.mediaSubtype) != ("text", "vcard"):
log.err("MIME type %s not allowed in address book collection" % (content_type,))
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "supported-address-data")))
# Read the vcard component from the stream
try:
vcarddata = (yield allDataFromStream(request.stream))
if not hasattr(request, "extendedLogItems"):
request.extendedLogItems = {}
request.extendedLogItems["cl"] = str(len(vcarddata)) if vcarddata else "0"
# We must have some data at this point
if vcarddata is None:
# Use correct DAV:error response
raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "valid-address-data"), description="No vcard data"))
storer = StoreAddressObjectResource(
示例6: getattr
# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import err [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.err("Unsupported REPORT {%s}%s for resource %s (no method %s)"
% (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)
示例7: getattr
# 需要导入模块: from twext.python.log import Logger [as 别名]
# 或者: from twext.python.log.Logger import err [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.err("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)