本文整理汇总了Python中twisted.python.failure.startDebugMode方法的典型用法代码示例。如果您正苦于以下问题:Python failure.startDebugMode方法的具体用法?Python failure.startDebugMode怎么用?Python failure.startDebugMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.failure
的用法示例。
在下文中一共展示了failure.startDebugMode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def setUp(self):
"""
Override pdb.post_mortem so we can make sure it's called.
"""
# Make sure any changes we make are reversed:
post_mortem = pdb.post_mortem
if _shouldEnableNewStyle:
origInit = failure.Failure.__init__
else:
origInit = failure.Failure.__dict__['__init__']
def restore():
pdb.post_mortem = post_mortem
if _shouldEnableNewStyle:
failure.Failure.__init__ = origInit
else:
failure.Failure.__dict__['__init__'] = origInit
self.addCleanup(restore)
self.result = []
pdb.post_mortem = self.result.append
failure.startDebugMode()
示例2: process_options
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def process_options(self, args, opts):
try:
self.settings.setdict(arglist_to_dict(opts.set),
priority='cmdline')
except ValueError:
raise UsageError("Invalid -s value, use -s NAME=VALUE", print_help=False)
if opts.logfile:
self.settings.set('LOG_ENABLED', True, priority='cmdline')
self.settings.set('LOG_FILE', opts.logfile, priority='cmdline')
if opts.loglevel:
self.settings.set('LOG_ENABLED', True, priority='cmdline')
self.settings.set('LOG_LEVEL', opts.loglevel, priority='cmdline')
if opts.nolog:
self.settings.set('LOG_ENABLED', False, priority='cmdline')
if opts.pidfile:
with open(opts.pidfile, "w") as f:
f.write(str(os.getpid()) + os.linesep)
if opts.pdb:
failure.startDebugMode()
示例3: opt_debug
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def opt_debug(self):
"""
Run the application in the Python Debugger (implies nodaemon),
sending SIGUSR2 will drop into debugger
"""
defer.setDebugging(True)
failure.startDebugMode()
self['debug'] = True
示例4: test_regularFailure
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def test_regularFailure(self):
"""
If startDebugMode() is called, calling Failure() will first call
pdb.post_mortem with the traceback.
"""
try:
1/0
except:
typ, exc, tb = sys.exc_info()
f = failure.Failure()
self.assertEqual(self.result, [tb])
self.assertFalse(f.captureVars)
示例5: test_captureVars
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def test_captureVars(self):
"""
If startDebugMode() is called, passing captureVars to Failure() will
not blow up.
"""
try:
1/0
except:
typ, exc, tb = sys.exc_info()
f = failure.Failure(captureVars=True)
self.assertEqual(self.result, [tb])
self.assertTrue(f.captureVars)
示例6: _initialDebugSetup
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def _initialDebugSetup(config):
# do this part of debug setup first for easy debugging of import failures
if config['debug']:
failure.startDebugMode()
if config['debug'] or config['debug-stacktraces']:
defer.setDebugging(True)
示例7: setUp
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def setUp(self):
"""
Override pdb.post_mortem so we can make sure it's called.
"""
# Make sure any changes we make are reversed:
post_mortem = pdb.post_mortem
origInit = failure.Failure.__init__
def restore():
pdb.post_mortem = post_mortem
failure.Failure.__init__ = origInit
self.addCleanup(restore)
self.result = []
pdb.post_mortem = self.result.append
failure.startDebugMode()
示例8: opt_debug
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def opt_debug(self):
"""
run the application in the Python Debugger (implies nodaemon),
sending SIGUSR2 will drop into debugger
"""
defer.setDebugging(True)
failure.startDebugMode()
self['debug'] = True
示例9: cli
# 需要导入模块: from twisted.python import failure [as 别名]
# 或者: from twisted.python.failure import startDebugMode [as 别名]
def cli(ctx, loglevel, config, pdb):
"""
feeds creates feeds for pages that don't have feeds.
"""
if pdb:
failure.startDebugMode()
# A pip-installed Feeds does not have a scrapy.cfg in its project root.
os.environ["SCRAPY_SETTINGS_MODULE"] = "feeds.default_settings"
settings = load_feeds_settings(config)
settings.set("LOG_LEVEL", loglevel.upper())
ctx.obj["settings"] = settings