本文整理汇总了Python中wdb.Wdb类的典型用法代码示例。如果您正苦于以下问题:Python Wdb类的具体用法?Python Wdb怎么用?Python Wdb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Wdb类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
"""Wdb entry point"""
sys.path.insert(0, os.getcwd())
args, extrargs = parser.parse_known_args()
sys.argv = ['wdb'] + extrargs
if args.file:
file = os.path.join(os.getcwd(), args.file)
if args.source:
print('The source argument cannot be used with file.')
sys.exit(1)
if not os.path.exists(file):
print('Error:', file, 'does not exist')
sys.exit(1)
Wdb.get().run_file(file)
else:
source = None
if args.source:
source = os.path.join(os.getcwd(), args.source)
if not os.path.exists(source):
print('Error:', source, 'does not exist')
sys.exit(1)
Wdb.get().shell(source)
开发者ID:baiyunping333,项目名称:wdb,代码行数:26,代码来源:__main__.py
示例2: main
def main():
"""Inspired by python -m pdb. Debug any python script with wdb"""
if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
print("usage: wdb.py scriptfile [arg] ...")
sys.exit(2)
mainpyfile = sys.argv[1]
if not os.path.exists(mainpyfile):
print('Error:', mainpyfile, 'does not exist')
sys.exit(1)
del sys.argv[0]
sys.path[0] = os.path.dirname(mainpyfile)
Wdb.get().run_file(mainpyfile)
开发者ID:Avinash9,项目名称:wdb,代码行数:15,代码来源:__main__.py
示例3: init_new_wdbr
def init_new_wdbr(frame, event, args):
"""First settrace call start the debugger for the current thread"""
import threading
import sys
from wdb import Wdb
thread = threading.currentThread()
if getattr(thread, 'no_trace', False):
sys.settrace(None)
return
wdbr_thread = Wdb.make_server()
thread._wdbr = wdbr_thread
frame = sys._getframe().f_back
wdbr_thread.stopframe = frame
wdbr_thread.botframe = frame
while frame:
frame.f_trace = wdbr_thread.trace_dispatch
frame = frame.f_back
wdbr_thread.stoplineno = -1
def trace(frame, event, arg):
rv = wdbr_thread.trace_dispatch(frame, event, arg)
fn = frame.f_code.co_filename
if (rv is None and not
(fn == os.path.abspath(fn) or fn.startswith('<')) and not
fn.startswith(
os.path.dirname(os.path.abspath(sys.argv[0])))):
return
return trace
sys.settrace(trace)
return wdbr_thread.trace_dispatch
开发者ID:seletz,项目名称:wdb,代码行数:34,代码来源:__main__.py
示例4: tracing_fork
def tracing_fork():
import sys
import multiprocessing
from wdb import Wdb
pid = osfork()
if pid == 0:
# Doesn't work with Wdb.trace()...
sys.settrace(None)
wdbr_process = Wdb.make_server()
def trace(frame, event, arg):
process = multiprocessing.current_process()
if not hasattr(process, '_wdbr'):
process._wdbr = wdbr_process
rv = wdbr_process.trace_dispatch(frame, event, arg)
fn = frame.f_code.co_filename
if (rv is None and
(fn == os.path.abspath(fn) or fn.startswith('<')) and not
fn.startswith(
os.path.dirname(os.path.abspath(sys.argv[0])))):
return
return trace
frame = sys._getframe().f_back
wdbr_process.stoplineno = -1
wdbr_process.stopframe = frame
while frame:
frame.f_trace = wdbr_process.trace_dispatch
wdbr_process.botframe = frame
frame = frame.f_back
sys.settrace(trace)
return pid
开发者ID:seletz,项目名称:wdb,代码行数:34,代码来源:__main__.py
示例5: f
def f():
# Enable wdb
wdb = Wdb.get()
Wdb.enabled = True
start_response('200 OK', [
('Content-Type', 'text/html'), ('X-Thing', wdb.uuid)])
yield to_bytes(' ' * 4096)
wdb = set_trace()
wdb.die()
yield to_bytes('Exited')
开发者ID:niziou,项目名称:wdb,代码行数:10,代码来源:ext.py
示例6: main
def main():
"""Wdb entry point"""
sys.path.insert(0, os.getcwd())
args, extrargs = parser.parse_known_args()
sys.argv = ['wdb'] + args.args + extrargs
if args.file:
file = os.path.join(os.getcwd(), args.file)
if args.source:
print('The source argument cannot be used with file.')
sys.exit(1)
if not os.path.exists(file):
print('Error:', file, 'does not exist')
sys.exit(1)
if args.trace:
Wdb.get().run_file(file)
else:
def wdb_pm(xtype, value, traceback):
sys.__excepthook__(xtype, value, traceback)
wdb = Wdb.get()
wdb.reset()
wdb.interaction(None, traceback, post_mortem=True)
sys.excepthook = wdb_pm
with open(file) as f:
code = compile(f.read(), file, 'exec')
execute(code, globals(), globals())
else:
source = None
if args.source:
source = os.path.join(os.getcwd(), args.source)
if not os.path.exists(source):
print('Error:', source, 'does not exist')
sys.exit(1)
Wdb.get().shell(source)
开发者ID:Kozea,项目名称:wdb,代码行数:40,代码来源:__main__.py
示例7: trace_wsgi
def trace_wsgi(environ, start_response):
wdb = Wdb.get()
wdb.closed = False
appiter = None
try:
with trace(close_on_exit=True, under=self.app):
appiter = self.app(environ, start_response)
for item in appiter:
yield item
except Exception:
start_response('500 INTERNAL SERVER ERROR', [
('Content-Type', 'text/html')])
yield _handle_off()
finally:
hasattr(appiter, 'close') and appiter.close()
wdb.closed = False
开发者ID:niziou,项目名称:wdb,代码行数:16,代码来源:ext.py
示例8: catch
def catch(environ, start_response):
wdb = Wdb.get()
wdb.closed = False
appiter = None
try:
appiter = self.app(environ, start_response)
for item in appiter:
yield item
except Exception:
start_response('500 INTERNAL SERVER ERROR', [
('Content-Type', 'text/html')])
yield _handle_off()
finally:
# Close set_trace debuggers
stop_trace(close_on_exit=True)
hasattr(appiter, 'close') and appiter.close()
wdb.closed = False
开发者ID:niziou,项目名称:wdb,代码行数:17,代码来源:ext.py
示例9: _wdb_execute
def _wdb_execute(*args, **kwargs):
from wdb import trace, Wdb
wdb = Wdb.get()
wdb.closed = False # Activate request ignores
interesting = True
if len(args) > 0 and isinstance(args[0], ErrorHandler):
interesting = False
elif len(args) > 2 and isinstance(
args[0], StaticFileHandler) and args[2] == 'favicon.ico':
interesting = False
if Wdb.enabled and interesting:
with trace(close_on_exit=True, under=under):
old_execute(*args, **kwargs)
else:
old_execute(*args, **kwargs)
# Close set_trace debuggers
stop_trace(close_on_exit=True)
# Reset closed state
wdb.closed = False
开发者ID:niziou,项目名称:wdb,代码行数:22,代码来源:ext.py
示例10: run
def run():
from wdb import Wdb
Wdb.get().run_file(fn)
开发者ID:hekevintran,项目名称:wdb,代码行数:3,代码来源:__init__.py
示例11: run
def run():
from wdb import Wdb
Wdb.get().run_file(fn[0].decode('utf-8'))
开发者ID:TFenby,项目名称:wdb,代码行数:3,代码来源:__init__.py
示例12: main
def main():
"""Inspired by python -m pdb. Debug any python script with wdb"""
if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
print("usage: wdb.py scriptfile [arg] ...")
sys.exit(2)
mainpyfile = sys.argv[1]
if not os.path.exists(mainpyfile):
print('Error:', mainpyfile, 'does not exist')
sys.exit(1)
del sys.argv[0]
sys.path[0] = os.path.dirname(mainpyfile)
# Let's make a server in case of
wdbr = Wdb.trace()
# Multithread support
# Monkey patch threading to have callback to kill thread debugger
old_thread_start = threading.Thread.start
def wdb_thread_start(self):
"""Monkey patched start monkey patching run"""
self.old_run = self.run
def run(self):
"""Monkey patched run"""
try:
self.old_run()
finally:
if hasattr(self, '_wdbr'):
self._wdbr.die()
from wdb._compat import bind
self.run = bind(self, run)
old_thread_start(self)
threading.Thread.start = wdb_thread_start
def init_new_wdbr(frame, event, args):
"""First settrace call start the debugger for the current thread"""
import threading
import sys
from wdb import Wdb
thread = threading.currentThread()
if getattr(thread, 'no_trace', False):
sys.settrace(None)
return
wdbr_thread = Wdb.make_server()
thread._wdbr = wdbr_thread
frame = sys._getframe().f_back
wdbr_thread.stopframe = frame
wdbr_thread.botframe = frame
while frame:
frame.f_trace = wdbr_thread.trace_dispatch
frame = frame.f_back
wdbr_thread.stoplineno = -1
def trace(frame, event, arg):
rv = wdbr_thread.trace_dispatch(frame, event, arg)
fn = frame.f_code.co_filename
if (rv is None and not
(fn == os.path.abspath(fn) or fn.startswith('<')) and not
fn.startswith(
os.path.dirname(os.path.abspath(sys.argv[0])))):
return
return trace
sys.settrace(trace)
return wdbr_thread.trace_dispatch
threading.settrace(init_new_wdbr)
# Multiprocess support
# Monkey patch threading to have callback to kill thread debugger
old_process_start = multiprocessing.Process.start
def wdb_process_start(self):
"""Monkey patched start monkey patching run"""
self.old_run = self.run
def run(self):
"""Monkey patched run"""
try:
self.old_run()
finally:
if hasattr(self, '_wdbr'):
self._wdbr.die()
from wdb._compat import bind
self.run = bind(self, run)
old_process_start(self)
multiprocessing.Process.start = wdb_process_start
# Monkey patching fork
osfork = os.fork
def tracing_fork():
import sys
#.........这里部分代码省略.........
开发者ID:seletz,项目名称:wdb,代码行数:101,代码来源:__main__.py
示例13: run
def run():
from wdb import Wdb
Wdb.get().shell()
开发者ID:JacekPliszka,项目名称:wdb,代码行数:3,代码来源:__init__.py
示例14: wdb_pm
def wdb_pm(xtype, value, traceback):
sys.__excepthook__(xtype, value, traceback)
wdb = Wdb.get()
wdb.reset()
wdb.interaction(None, traceback, post_mortem=True)
开发者ID:Kozea,项目名称:wdb,代码行数:5,代码来源:__main__.py
注:本文中的wdb.Wdb类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论