<s> """<STR_LIT>""" <EOL> import logging <EOL> import pdb <EOL> import Queue <EOL> import sys <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> class Pipe ( Queue . Queue ) : <EOL> def __init__ ( self , name , mode = '<STR_LIT:r>' , * args , ** kwargs ) : <EOL> self . __name = name <EOL> Queue . Queue . __init__ ( self , * args , ** kwargs ) <EOL> def write ( self , data ) : <EOL> logger . debug ( "<STR_LIT>" % ( self . __name , data ) ) <EOL> self . put ( data ) <EOL> def flush ( self ) : <EOL> logger . debug ( "<STR_LIT>" % self . __name ) <EOL> self . put ( None ) <EOL> self . join ( ) <EOL> logger . debug ( "<STR_LIT>" % self . __name ) <EOL> def read ( self , count = None , timeout = None ) : <EOL> logger . debug ( "<STR_LIT>" % ( self . __name , ) ) <EOL> data = self . get ( block = True , timeout = timeout ) <EOL> self . task_done ( ) <EOL> logger . debug ( "<STR_LIT>" % ( self . __name , data ) ) <EOL> return data <EOL> def readline ( self ) : <EOL> logger . debug ( "<STR_LIT>" % ( self . __name , ) ) <EOL> return self . read ( ) <EOL> pipe_in = Pipe ( '<STR_LIT>' ) <EOL> pipe_out = Pipe ( '<STR_LIT>' ) <EOL> debugger = pdb . Pdb ( completekey = None , stdin = pipe_in , stdout = pipe_out , ) <EOL> def set_trace ( ) : <EOL> "<STR_LIT>" <EOL> logger . info ( "<STR_LIT>" ) <EOL> debugger . set_trace ( sys . _getframe ( ) . f_back ) <EOL> def stop_trace ( ) : <EOL> "<STR_LIT>" <EOL> logger . info ( "<STR_LIT>" ) <EOL> pipe_out . write ( "<STR_LIT>" ) <EOL> pipe_out . write ( None ) <EOL> def communicate ( command = None ) : <EOL> "<STR_LIT>" <EOL> if command is not None : <EOL> logger . info ( "<STR_LIT>" % command ) <EOL> pipe_in . write ( command ) <EOL> result = [ ] <EOL> while True : <EOL> data = pipe_out . read ( ) <EOL> if data is None : <EOL> break <EOL> result . append ( data ) <EOL> logger . info ( "<STR_LIT>" % repr ( result ) ) <EOL> return '<STR_LIT>' . join ( result ) <EOL> import gluon . contrib . qdb as qdb <EOL> from threading import RLock <EOL> interact_lock = RLock ( ) <EOL> run_lock = RLock ( ) <EOL> def check_interaction ( fn ) : <EOL> "<STR_LIT>" <EOL> def check_fn ( self , * args , ** kwargs ) : <EOL> interact_lock . acquire ( ) <EOL> try : <EOL> if self . filename : <EOL> self . clear_interaction ( ) <EOL> return fn ( self , * args , ** kwargs ) <EOL> finally : <EOL> interact_lock . release ( ) <EOL> return check_fn <EOL> class WebDebugger ( qdb . Frontend ) : <EOL> "<STR_LIT>" <EOL> def __init__ ( self , pipe , completekey = '<STR_LIT>' , stdin = None , stdout = None ) : <EOL> qdb . Frontend . __init__ ( self , pipe ) <EOL> self . clear_interaction ( ) <EOL> def clear_interaction ( self ) : <EOL> self . filename = None <EOL> self . lineno = None <EOL> self . exception_info = None <EOL> self . context = None <EOL> def run ( self ) : <EOL> run_lock . acquire ( ) <EOL> try : <EOL> while self . pipe . poll ( ) : <EOL> qdb . Frontend . run ( self ) <EOL> finally : <EOL> run_lock . release ( ) <EOL> def interaction ( self , filename , lineno , line , ** context ) : <EOL> interact_lock . acquire ( ) <EOL> try : <EOL> self . filename = filename <EOL> self . lineno = lineno <EOL> self . context = context <EOL> finally : <EOL> interact_lock . release ( ) <EOL> def exception ( self , title , extype , exvalue , trace , request ) : <EOL> self . exception_info = { '<STR_LIT:title>' : title , <EOL> '<STR_LIT>' : extype , '<STR_LIT>' : exvalue , <EOL> '<STR_LIT>' : trace , '<STR_LIT>' : request } <EOL> @ check_interaction <EOL> def do_continue ( self ) : <EOL> qdb . Frontend . do_continue ( self ) <EOL> @ check_interaction <EOL> def do_step ( self ) : <EOL> qdb . Frontend . do_step ( self ) <EOL> @ check_interaction <EOL> def do_return ( self ) : <EOL> qdb . Frontend . do_return ( self ) <EOL> @ check_interaction <EOL> def do_next ( self ) : <EOL> qdb . Frontend . do_next ( self ) <EOL> @ check_interaction <EOL> def do_quit ( self ) : <EOL> qdb . Frontend . do_quit ( self ) <EOL> def do_exec ( self , statement ) : <EOL> interact_lock . acquire ( ) <EOL> try : <EOL> if self . filename : <EOL> self . set_burst ( <NUM_LIT:2> ) <EOL> return qdb . Frontend . do_exec ( self , statement ) <EOL> finally : <EOL> interact_lock . release ( ) <EOL> parent_queue , child_queue = Queue . Queue ( ) , Queue . Queue ( ) <EOL> front_conn = qdb . QueuePipe ( "<STR_LIT>" , parent_queue , child_queue ) <EOL> child_conn = qdb . QueuePipe ( "<STR_LIT>" , child_queue , parent_queue ) <EOL> web_debugger = WebDebugger ( front_conn ) <EOL> qdb_debugger = qdb . Qdb ( pipe = child_conn , redirect_stdio = False , skip = None ) <EOL> dbg = qdb_debugger <EOL> qdb_debugger . set_params ( dict ( call_stack = True , environment = True ) ) <EOL> import gluon . main <EOL> gluon . main . global_settings . debugging = True </s>
