Source code for schrodinger.ui.qt.appframework2.debug
from schrodinger.ui.qt.appframework2 import debug_gui
from schrodinger.ui.qt.appframework2 import debugcore
#===============================================================================
# Decorators
#===============================================================================
"""
Use these decorators to automatically follow function/method calls.
debug_func tracks entry and exit every time the function is called
debug_func_args does the same and also reports argument values passed in and
return value
Example:
from schrodinger.ui.qt.appframework2 import debug
@debug.debug_func_args
def foo(bar):
print bar
return bar + 1
debug.start_stdout_debug()
foo(4)
Output:
16:19:18.132000 Functions Enter: foo(4)
16:19:18.132000 Print 4
16:19:18.132000 Functions Exit: foo. Returned: 5
"""
#===============================================================================
# Imported functions
#===============================================================================
"""
Use the log() function to generate debug output. This output only appears
when the debug viewer is started. Use a custom tag to label outputs.
Example:
>>> from schrodinger.ui.qt.appframework2 import debug
>>> debug.log('Hello world') # Shows no output
>>> debug.start_stdout_debug()
>>> debug.log('Hello world')
16:23:31.475000 Log Hello world
>>> debug.log('Hello world', 'Testing') # Custom Tag
16:24:12.656000 Testing Hello world
"""
#===============================================================================
# General functions
#===============================================================================
"""
Start and stop debug viewers. If no debug viewers are running, debug functions
are ignored. Starting a debug viewer also redirects stdout to that viewer
(this includes print statements).
"""
[docs]def start_stdout_debug():
debugcore.start(debugcore.StdoutDebugViewer)
[docs]def start_file_debug():
debugcore.start(debugcore.FileDebugViewer)
[docs]def start_gui_debug(source_obj, globals=None, locals=None):
debugcore.start(debug_gui.DebugViewer)
debugcore.debug_viewer.setSourceObj(source_obj)
debugcore.debug_viewer.setNamespace(globals, locals)
debugcore.debug_viewer.show()
debugcore.debug_viewer.raise_()
[docs]def stop_debug():
debugcore.stop()