本文整理汇总了Python中twisted.web.util.formatFailure函数的典型用法代码示例。如果您正苦于以下问题:Python formatFailure函数的具体用法?Python formatFailure怎么用?Python formatFailure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatFailure函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _process_error
def _process_error(self, reason):
"""
Called when there is an error processing the request.
*reason* (``twisted.internet.failure.Failure``) is the reason for
failure.
"""
try:
if not isinstance(reason, failure.Failure):
# LIES! This is not an error.
return
# Log errors.
log.err(reason, str(self))
if self._disconnected or self.finished:
# Since we are disconnected, return and do nothing.
return
if self._resp_error_cb:
# Call error callback.
try:
self._resp_error_cb(self, reason, self._resp_started, *self._resp_error_args, **self._resp_error_kw)
except Exception as e:
log.err(e, str(self))
if not self._resp_started:
# Display Internal Server Error.
code = http.INTERNAL_SERVER_ERROR
if self.site.displayTracebacks:
body = _server_traceback_html.format(path=urllib.escape(self.uri), traceback=webutil.formatFailure(reason))
else:
body = _server_error_html.format(path=urllib.escape(self.uri))
self.setResponseCode(code)
self.setResponseEncoding(self._resp_enc or 'UTF-8')
self.write(body)
elif 'text/html' in self.responseHeaders.getRawHeaders('content-type', ('',))[0]:
# Since an error occured but we've already started writing the
# response, do what we can.
if self.site.displayTracebacks:
body = _server_traceback_html.format(path=urllib.escape(self.uri), traceback=webutil.formatFailure(reason))
else:
body = "<h1>...Internal Server Error!</h1>"
self.write(body)
except Exception as e:
log.err(e, str(self))
finally:
self.finish()
开发者ID:cpburnz,项目名称:twisted-deferred-request,代码行数:51,代码来源:deferred_request.py
示例2: addLogWithFailure
def addLogWithFailure(self, why, logprefix=""):
# helper for showing exceptions to the users
try:
yield self.addCompleteLog(logprefix + "err.text", why.getTraceback())
yield self.addHTMLLog(logprefix + "err.html", formatFailure(why))
except Exception:
log.err(Failure(), "error while formatting exceptions")
开发者ID:daymanc,项目名称:buildbot,代码行数:7,代码来源:buildstep.py
示例3: failed
def failed(self, why):
# This can either be a BuildStepFailed exception/failure, meaning we
# should call self.finish, or it can be a real exception, which should
# be recorded as such.
if why.check(BuildStepFailed):
self.finished(FAILURE)
return
log.err(why, "BuildStep.failed; traceback follows")
try:
if self.progress:
self.progress.finish()
self.addHTMLLog("err.html", formatFailure(why))
self.addCompleteLog("err.text", why.getTraceback())
# could use why.getDetailedTraceback() for more information
self.step_status.setText([self.name, "exception"])
self.step_status.setText2([self.name])
self.step_status.stepFinished(EXCEPTION)
except:
log.msg("exception during failure processing")
log.err()
# the progress stuff may still be whacked (the StepStatus may
# think that it is still running), but the build overall will now
# finish
try:
self.releaseLocks()
except:
log.msg("exception while releasing locks")
log.err()
log.msg("BuildStep.failed now firing callback")
self.deferred.callback(EXCEPTION)
开发者ID:bobbyi,项目名称:buildbot,代码行数:32,代码来源:buildstep.py
示例4: failed
def failed(self, why):
# if isinstance(why, pb.CopiedFailure): # a remote exception might
# only have short traceback, so formatFailure is not as useful as
# you'd like (no .frames, so no traceback is displayed)
log.msg("BuildStep.failed, traceback follows")
log.err(why)
try:
if self.progress:
self.progress.finish()
self.addHTMLLog("err.html", formatFailure(why))
self.addCompleteLog("err.text", why.getTraceback())
# could use why.getDetailedTraceback() for more information
self.step_status.setText([self.name, "exception"])
self.step_status.setText2([self.name])
self.step_status.stepFinished(EXCEPTION)
except:
log.msg("exception during failure processing")
log.err()
# the progress stuff may still be whacked (the StepStatus may
# think that it is still running), but the build overall will now
# finish
try:
self.releaseLocks()
except:
log.msg("exception while releasing locks")
log.err()
log.msg("BuildStep.failed now firing callback")
self.deferred.callback(EXCEPTION)
开发者ID:wener,项目名称:buildbot,代码行数:29,代码来源:buildstep.py
示例5: _get_error_body
def _get_error_body(self, request, failure):
if self.debug_handler and self.debug_handler.is_client_allowed_debugging(request):
ajax_endpoint = request.childLink("__debug__/" + self.debug_handler.register_failure(failure))
debug_variables = dict(ajax_endpoint=ajax_endpoint, body=web_util.formatFailure(failure))
html = DEBUG_HTML_TEMPLATE % debug_variables
return html
return STANDARD_HTML_TEMPLATE
开发者ID:hooplab,项目名称:Piped,代码行数:10,代码来源:web_provider.py
示例6: processingFailed
def processingFailed(self, reason):
log.err(reason)
body = ("<html><head><title>web.Server Traceback (most recent call last)</title></head>"
"<body><b>web.Server Traceback (most recent call last):</b>\n\n"
"%s\n\n</body></html>\n"
% webutil.formatFailure(reason))
self.setResponseCode(http.INTERNAL_SERVER_ERROR)
self.setHeader('content-type',"text/html")
self.setHeader('content-length', str(len(body)))
self.write(body)
self.finish()
return reason
开发者ID:fxia22,项目名称:ASM_xf,代码行数:12,代码来源:server.py
示例7: test_returnsBytes
def test_returnsBytes(self):
"""
The return value of L{formatFailure} is a C{str} instance (not a
C{unicode} instance) with numeric character references for any non-ASCII
characters meant to appear in the output.
"""
try:
raise Exception("Fake bug")
except:
result = formatFailure(Failure())
self.assertIsInstance(result, str)
self.assertTrue(all(ord(ch) < 128 for ch in result))
# Indentation happens to rely on NO-BREAK SPACE
self.assertIn(" ", result)
开发者ID:ali-hallaji,项目名称:twisted,代码行数:15,代码来源:test_util.py
示例8: failed
def failed(self, why):
# This can either be a BuildStepFailed exception/failure, meaning we
# should call self.finished, or it can be a real exception, which should
# be recorded as such.
if why.check(BuildStepFailed):
self.finished(FAILURE)
return
# However, in the case of losing the connection to a slave, we want to
# finish with a RETRY.
if why.check(error.ConnectionLost):
self.step_status.setText(self.describe(True) +
["exception", "slave", "lost"])
self.step_status.setText2(["exception", "slave", "lost"])
self.finished(RETRY)
return
log.err(why, "BuildStep.failed; traceback follows")
try:
if self.progress:
self.progress.finish()
try:
self.addCompleteLog("err.text", why.getTraceback())
self.addHTMLLog("err.html", formatFailure(why))
except Exception:
log.err(Failure(), "error while formatting exceptions")
# could use why.getDetailedTraceback() for more information
self.step_status.setText([self.name, "exception"])
self.step_status.setText2([self.name])
self.step_status.stepFinished(EXCEPTION)
hidden = self._maybeEvaluate(self.hideStepIf, EXCEPTION, self)
self.step_status.setHidden(hidden)
except Exception:
log.err(Failure(), "exception during failure processing")
# the progress stuff may still be whacked (the StepStatus may
# think that it is still running), but the build overall will now
# finish
try:
self.releaseLocks()
except Exception:
log.err(Failure(), "exception while releasing locks")
log.msg("BuildStep.failed now firing callback")
self.deferred.callback(EXCEPTION)
开发者ID:digidesk-io,项目名称:buildbot,代码行数:46,代码来源:buildstep.py
示例9: processingFailed
def processingFailed(self, reason):
log.err(reason)
# Re-enable on Python 3 as part of #6178:
if not _PY3 and self.site.displayTracebacks:
body = ("<html><head><title>web.Server Traceback (most recent call last)</title></head>"
"<body><b>web.Server Traceback (most recent call last):</b>\n\n"
"%s\n\n</body></html>\n"
% webutil.formatFailure(reason))
else:
body = (b"<html><head><title>Processing Failed</title></head><body>"
b"<b>Processing Failed</b></body></html>")
self.setResponseCode(http.INTERNAL_SERVER_ERROR)
self.setHeader(b'content-type', b"text/html")
self.setHeader(b'content-length', intToBytes(len(body)))
self.write(body)
self.finish()
return reason
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:18,代码来源:server.py
示例10: _finishFinished
def _finishFinished(self, results):
# internal function to indicate that this step is done; this is separated
# from finished() so that subclasses can override finished()
if self.progress:
self.progress.finish()
try:
hidden = self._maybeEvaluate(self.hideStepIf, results, self)
except Exception:
why = Failure()
self.addHTMLLog("err.html", formatFailure(why))
self.addCompleteLog("err.text", why.getTraceback())
results = EXCEPTION
hidden = False
self.step_status.stepFinished(results)
self.step_status.setHidden(hidden)
self.releaseLocks()
self.deferred.callback(results)
开发者ID:MandarinConLaBarba,项目名称:buildbot,代码行数:20,代码来源:buildstep.py
示例11: processingFailed
def processingFailed(self, reason):
log.err(reason)
if self.site.displayTracebacks:
body = (b"<html><head><title>web.Server Traceback"
b" (most recent call last)</title></head>"
b"<body><b>web.Server Traceback"
b" (most recent call last):</b>\n\n" +
util.formatFailure(reason) +
b"\n\n</body></html>\n")
else:
body = (b"<html><head><title>Processing Failed"
b"</title></head><body>"
b"<b>Processing Failed</b></body></html>")
self.setResponseCode(http.INTERNAL_SERVER_ERROR)
self.setHeader(b'content-type', b"text/html")
self.setHeader(b'content-length', intToBytes(len(body)))
self.write(body)
self.finish()
return reason
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:20,代码来源:server.py
示例12: start_response
start_response('503 Service Unavailable', headers)
return content
except:
reason = failure.Failure()
reason.printTraceback(env['wsgi.errors'])
if('modu.app' in req and req.app.config.get('error_content')):
content_provider = req.app.error_content()
req['modu.failure'] = reason
content_provider.prepare_content(req)
content = [content_provider.get_content(req)]
headers = [('Content-Type', content_provider.get_content_type(req))]
else:
content = ["<html><head><title>web.Server Traceback (most recent call last)</title></head>"
"<body><b>web.Server Traceback (most recent call last):</b>\n\n"
"%s\n\n</body></html>\n" % util.formatFailure(reason)]
headers = [('Content-Type', 'text/html')]
start_response('500 Internal Server Error', headers)
return content
start_response('200 OK', req.get_headers())
return content
def check_maintenance_mode(req):
"""
Check whether maintenance mode is on or not.
At this time, this merely checks for the existence of a 'modu-maintenance' file
in /etc. There are a significant limitations with this implementation:
开发者ID:philchristensen,项目名称:modu,代码行数:29,代码来源:app.py
注:本文中的twisted.web.util.formatFailure函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论