本文整理汇总了Python中twisted.python.log.flushErrors函数的典型用法代码示例。如果您正苦于以下问题:Python flushErrors函数的具体用法?Python flushErrors怎么用?Python flushErrors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flushErrors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _flushErrors
def _flushErrors(self, *types):
# This bit about log flushing seems to be necessary with twisted < 2.5.
try:
self.flushLoggedErrors(*types)
except AttributeError:
from twisted.python import log as tlog
tlog.flushErrors(*types)
示例2: openFailed
def openFailed(self, reason):
"""
good .... good
"""
log.msg('unknown open failed')
log.flushErrors()
self.conn.addResult()
示例3: testRefusedAnonymousClientConnection
def testRefusedAnonymousClientConnection(self):
onServerLost = defer.Deferred()
onClientLost = defer.Deferred()
self.loopback(sslverify.OpenSSLCertificateOptions(privateKey=self.sKey, certificate=self.sCert, verify=True, caCerts=[self.sCert], requireCertificate=True),
sslverify.OpenSSLCertificateOptions(requireCertificate=False),
onServerLost=onServerLost,
onClientLost=onClientLost)
d = defer.DeferredList([onClientLost, onServerLost], consumeErrors=True)
def afterLost(((cSuccess, cResult), (sSuccess, sResult))):
self.failIf(cSuccess)
self.failIf(sSuccess)
# XXX Twisted doesn't report SSL errors as SSL errors, but in the
# future it will.
# cResult.trap(SSL.Error)
# sResult.trap(SSL.Error)
# Twisted trunk will do the correct thing here, and not log any
# errors. Twisted 2.1 will do the wrong thing. We're flushing
# errors until the buildbot is updated to a reasonable facsimilie
# of 2.2.
log.flushErrors(SSL.Error)
示例4: testLink
def testLink(self):
linkRes = self._getCmdResult('ln testLink testfile1')
self.failIf(linkRes)
lslRes = self._getCmdResult('ls -l testLink')
log.flushErrors()
self.failUnless(lslRes.startswith('l'), 'link failed')
self.failIf(self._getCmdResult('rm testLink'))
示例5: _ebConnect
def _ebConnect(self, f):
# probably because the server wasn't listening in time
# but who knows, just try again
log.msg('ERROR CONNECTING TO %s' % self.port)
log.err(f)
log.flushErrors()
reactor.callLater(1, self._connect)
示例6: testPBFailures
def testPBFailures(self):
auth = authorizer.DefaultAuthorizer()
appl = app.Application("pbfailure", authorizer=auth)
SimpleService("pbfailure",auth,appl,self).getPerspectiveNamed("guest").makeIdentity("guest")
p = reactor.listenTCP(0, pb.BrokerFactory(pb.AuthRoot(auth)), interface="127.0.0.1")
self.n = p.getHost()[2]
appl.run(save=0)
log.flushErrors(PoopError, FailError, DieError)
示例7: testErrors
def testErrors(self):
for e, ig in [("hello world","hello world"),
(KeyError(), KeyError),
(failure.Failure(RuntimeError()), RuntimeError)]:
log.err(e)
i = self.catcher.pop()
self.assertEquals(i['isError'], 1)
log.flushErrors(ig)
示例8: testChAttrs
def testChAttrs(self):
lsRes = self._getCmdResult('ls -l testfile1')
self.failUnless(lsRes.startswith('-rw-r--r--'), lsRes)
self.failIf(self._getCmdResult('chmod 0 testfile1'))
lsRes = self._getCmdResult('ls -l testfile1')
self.failUnless(lsRes.startswith('----------'), lsRes)
self.failIf(self._getCmdResult('chmod 644 testfile1'))
log.flushErrors()
示例9: testDeferredStopService
def testDeferredStopService(self):
ms = app.MultiService("MultiService")
self.s1 = StoppingService("testService", 0)
self.s2 = StoppingService("testService2", 1)
ms.addService(self.s1)
ms.addService(self.s2)
ms.stopService().addCallback(self.woohoo)
log.flushErrors (StopError)
示例10: testStopServiceNone
def testStopServiceNone(self):
"""MultiService.stopService returns Deferred when service returns None.
"""
ms = app.MultiService("MultiService")
self.s1 = StoppingServiceII("testService")
ms.addService(self.s1)
d = ms.stopService()
d.addCallback(self.cb_nonetest)
log.flushErrors (StopError)
示例11: tearDown
def tearDown(self):
try:
self.flushLoggedErrors(errors.NotAuthenticatedError)
except AttributeError:
tlog.flushErrors(errors.NotAuthenticatedError)
log._getTheFluLogObserver().clearIgnores()
d = self.feedServer.shutdown()
d.addCallback(lambda _: self._bouncer.stop())
d.addCallback(lambda _: self.assertAdditionalFDsOpen(0, 'tearDown'))
return d
示例12: do_logErrCheck
def do_logErrCheck(cls):
if log._keptErrors:
L = []
for err in log._keptErrors:
if isinstance(err, failure.Failure):
L.append(err)
else:
L.append(repr(err))
log.flushErrors()
raise LoggedErrors(L)
示例13: testErrors
def testErrors(self):
for code, methodName in [(666, "fail"), (666, "deferFail"),
(12, "fault"), (23, "noSuchMethod"),
(17, "deferFault")]:
l = []
d = self.proxy().callRemote(methodName).addErrback(l.append)
while not l:
reactor.iterate()
l[0].trap(xmlrpc.Fault)
self.assertEquals(l[0].value.faultCode, code)
log.flushErrors(RuntimeError, ValueError)
示例14: testRegeneratingIt
def testRegeneratingIt(self):
for mod in self.removedModules:
self.failIf(mod.__name__ in sys.modules, 'Started with %r loaded: %r' % (mod.__name__, sys.path))
_regeneratePluginCache(['axiom', 'xmantissa'])
log.flushErrors(ImportError) # This is necessary since there are Axiom
# plugins that depend on Mantissa, so when
# Axiom is installed, Mantissa-dependent
# powerups are, but Mantissa isn't some
# harmless tracebacks are printed.
for mod in self.removedModules:
self.failIf(mod.__name__ in sys.modules, 'Loaded %r: %r' % (mod.__name__, sys.path))
示例15: testBadLogin
def testBadLogin(self):
factory = pb.PBClientFactory()
for username, password in [("nosuchuser", "pass"), ("user", "wrongpass")]:
d = factory.login(credentials.UsernamePassword(username, password), "BRAINS!")
c = reactor.connectTCP("127.0.0.1", self.portno, factory)
p = unittest.deferredError(d)
self.failUnless(p.check("twisted.cred.error.UnauthorizedLogin"))
c.disconnect()
reactor.iterate()
reactor.iterate()
reactor.iterate()
from twisted.cred.error import UnauthorizedLogin
log.flushErrors(UnauthorizedLogin)