本文整理汇总了Python中twisted.python.reflect.fullyQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:Python reflect.fullyQualifiedName方法的具体用法?Python reflect.fullyQualifiedName怎么用?Python reflect.fullyQualifiedName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.reflect
的用法示例。
在下文中一共展示了reflect.fullyQualifiedName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_runErrorWithFrames
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def test_runErrorWithFrames(self):
"""
L{LocalWorkerAMP._buildFailure} recreates the C{Failure.frames} from
the C{frames} argument passed to C{AddError}.
"""
results = []
errorClass = fullyQualifiedName(ValueError)
d = self.worker.callRemote(managercommands.AddError,
testName=self.testName, error=b'error',
errorClass=errorClass.encode("ascii"),
frames=[b"file.py", b"invalid code", b"3"])
d.addCallback(lambda result: results.append(result['success']))
self.pumpTransports()
self.assertEqual(self.testCase, self.result.errors[0][0])
self.assertEqual(
[(b'file.py', b'invalid code', 3, [], [])],
self.result.errors[0][1].frames)
self.assertTrue(results)
示例2: _ensureOldClass
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def _ensureOldClass(cls):
"""
Ensure that C{cls} is an old-style class.
@param cls: The class to check.
@return: The class, if it is an old-style class.
@raises: L{ValueError} if it is a new-style class.
"""
if not type(cls) is types.ClassType:
from twisted.python.reflect import fullyQualifiedName
raise ValueError(
("twisted.python._oldstyle._oldStyle is being used to decorate a "
"new-style class ({cls}). This should only be used to "
"decorate old-style classes.").format(
cls=fullyQualifiedName(cls)))
return cls
示例3: doRead
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def doRead(self):
"""
Called when my socket is ready for reading.
"""
read = 0
while read < self.maxThroughput:
try:
data = self._system.read(self._fileno, self.maxPacketSize)
except EnvironmentError as e:
if e.errno in (errno.EWOULDBLOCK, errno.EAGAIN, errno.EINTR):
return
else:
raise
except:
raise
read += len(data)
# TODO pkt.isPartial()?
try:
self.protocol.datagramReceived(data, partial=0)
except:
cls = fullyQualifiedName(self.protocol.__class__)
log.err(
None,
"Unhandled exception from %s.datagramReceived" % (cls,))
示例4: test_runErrorWithFrames
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def test_runErrorWithFrames(self):
"""
L{LocalWorkerAMP._buildFailure} recreates the C{Failure.frames} from
the C{frames} argument passed to C{AddError}.
"""
results = []
errorClass = fullyQualifiedName(ValueError)
d = self.worker.callRemote(managercommands.AddError,
testName=self.testName, error='error',
errorClass=errorClass,
frames=["file.py", "invalid code", "3"])
d.addCallback(lambda result: results.append(result['success']))
self.pumpTransports()
self.assertEqual(self.testCase, self.result.errors[0][0])
self.assertEqual(
[('file.py', 'invalid code', 3, [], [])],
self.result.errors[0][1].frames)
self.assertTrue(results)
示例5: getHandleErrorCode
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def getHandleErrorCode(self):
"""
Return the argument L{SSL.Error} will be constructed with for this
case. This is basically just a random OpenSSL implementation detail.
It would be better if this test worked in a way which did not require
this.
"""
# Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for
# SSL.Connection.write for some reason. The twisted.protocols.tls
# implementation of IReactorSSL doesn't suffer from this imprecation,
# though, since it is isolated from the Windows I/O layer (I suppose?).
# If test_properlyCloseFiles waited for the SSL handshake to complete
# and performed an orderly shutdown, then this would probably be a
# little less weird: writing to a shutdown SSL connection has a more
# well-defined failure mode (or at least it should).
name = fullyQualifiedName(getClass(reactor))
if platform.getType() == 'win32' and name != self._iocp:
return errno.WSAENOTSOCK
# This is terribly implementation-specific.
return [('SSL routines', 'SSL_write', 'protocol is shutdown')]
示例6: test_start_up_logs_failure_if_all_endpoint_options_fail
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def test_start_up_logs_failure_if_all_endpoint_options_fail(self):
service = RegionService(sentinel.ipcWorker)
error_1 = factory.make_exception_type()
error_2 = factory.make_exception_type()
endpoint_1 = Mock()
endpoint_1.listen.return_value = fail(error_1())
endpoint_2 = Mock()
endpoint_2.listen.return_value = fail(error_2())
service.endpoints = [[endpoint_1, endpoint_2]]
with TwistedLoggerFixture() as logger:
yield service.startService()
self.assertDocTestMatches(
"""\
RegionServer endpoint failed to listen.
Traceback (most recent call last):
...
%s:
"""
% fullyQualifiedName(error_2),
logger.output,
)
示例7: type
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def type(self, request, tag):
"""
Render the exception type as a child of C{tag}.
"""
return tag(fullyQualifiedName(self.failure.type))
示例8: test_runError
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def test_runError(self):
"""
Run a test, and encounter an error.
"""
results = []
errorClass = fullyQualifiedName(ValueError)
d = self.worker.callRemote(managercommands.AddError,
testName=self.testName, error=b'error',
errorClass=errorClass.encode("ascii"),
frames=[])
d.addCallback(lambda result: results.append(result['success']))
self.pumpTransports()
self.assertEqual(self.testCase, self.result.errors[0][0])
self.assertTrue(results)
示例9: test_runFailure
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def test_runFailure(self):
"""
Run a test, and fail.
"""
results = []
failClass = fullyQualifiedName(RuntimeError)
d = self.worker.callRemote(managercommands.AddFailure,
testName=self.testName, fail=b'fail',
failClass=failClass.encode("ascii"),
frames=[])
d.addCallback(lambda result: results.append(result['success']))
self.pumpTransports()
self.assertEqual(self.testCase, self.result.failures[0][0])
self.assertTrue(results)
示例10: __repr__
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def __repr__(self):
args = (fullyQualifiedName(self.protocol.__class__),)
if self.connected:
args = args + ("",)
else:
args = args + ("not ",)
args = args + (self._mode.name, self.interface)
return "<%s %slistening on %s/%s>" % args
示例11: _retry_exception
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def _retry_exception(f, steps=(0.1,) * 10, sleep=sleep):
"""
Retry a function if it raises an exception.
:return: Whatever the function returns.
"""
steps = iter(steps)
while True:
try:
Message.new(
message_type=(
u"flocker:provision:libcloud:retry_exception:trying"
),
function=fullyQualifiedName(f),
).write()
return f()
except:
# Try to get the next sleep time from the steps iterator. Do it
# without raising an exception (StopIteration) to preserve the
# current exception context.
for step in steps:
write_traceback()
sleep(step)
break
else:
# Didn't hit the break, so didn't iterate at all, so we're out
# of retry steps. Fail now.
raise
示例12: _callable_repr
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def _callable_repr(method):
"""Get a useful representation ``method``."""
try:
return fullyQualifiedName(method)
except AttributeError:
return safe_repr(method)
示例13: _callAppFunction
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def _callAppFunction(function):
"""
Call C{function}. If it raises an exception, log it with a minimal
description of the source.
@return: L{None}
"""
try:
function()
except:
_moduleLog.failure(
u"Unexpected exception from {name}",
name=fullyQualifiedName(function)
)
示例14: test_runError
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def test_runError(self):
"""
Run a test, and encounter an error.
"""
results = []
errorClass = fullyQualifiedName(ValueError)
d = self.worker.callRemote(managercommands.AddError,
testName=self.testName, error='error',
errorClass=errorClass,
frames=[])
d.addCallback(lambda result: results.append(result['success']))
self.pumpTransports()
self.assertEqual(self.testCase, self.result.errors[0][0])
self.assertTrue(results)
示例15: test_runFailure
# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import fullyQualifiedName [as 别名]
def test_runFailure(self):
"""
Run a test, and fail.
"""
results = []
failClass = fullyQualifiedName(RuntimeError)
d = self.worker.callRemote(managercommands.AddFailure,
testName=self.testName, fail='fail',
failClass=failClass,
frames=[])
d.addCallback(lambda result: results.append(result['success']))
self.pumpTransports()
self.assertEqual(self.testCase, self.result.failures[0][0])
self.assertTrue(results)