#NEWLINE# def wait_for_command( control_port ) : #NEWLINE# #INDENT# global _is_prelaunched_process #NEWLINE# _is_prelaunched_process = True #NEWLINE# s = socket . socket ( ) #NEWLINE# try : #NEWLINE# #INDENT# trace_begin ( 'bind_to_control_port' ) #NEWLINE# bound = False #NEWLINE# for i in range ( 10 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# s . bind ( ( '' , control_port ) ) #NEWLINE# bound = True #NEWLINE# break #NEWLINE# #UNINDENT# except socket . error : #NEWLINE# #INDENT# time . sleep ( 0.1 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not bound ) : #NEWLINE# #INDENT# raise Exception ( 'could not bind!' ) #NEWLINE# #UNINDENT# trace_end ( 'bind_to_control_port' ) #NEWLINE# s . listen ( 1 ) #NEWLINE# trace_begin ( 'socket.accept' ) #NEWLINE# ( c , a ) = s . accept ( ) #NEWLINE# trace_end ( 'socket.accept' ) #NEWLINE# f = c . makefile ( ) #NEWLINE# trace_begin ( 'read_command' ) #NEWLINE# args = eval ( f . readline ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# trace_end ( 'read_command' ) #NEWLINE# import quickopen #NEWLINE# import optparse #NEWLINE# old_stdout = sys . stdout #NEWLINE# new_stdout = StringIO . StringIO ( ) #NEWLINE# sys . stdout = new_stdout #NEWLINE# old_argv = sys . argv #NEWLINE# try : #NEWLINE# #INDENT# sys . argv = [ sys . argv [ 0 ] ] #NEWLINE# sys . argv . extend ( args ) #NEWLINE# parser = optparse . OptionParser ( usage = quickopen . main_usage ( ) ) #NEWLINE# quickopen . main ( old_argv ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# sys . stdout = old_stdout #NEWLINE# import traceback #NEWLINE# traceback . print_exc ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# sys . argv = old_argv #NEWLINE# sys . stdout = old_stdout #NEWLINE# #UNINDENT# trace_end ( 'exec_command' ) #NEWLINE# v = new_stdout . getvalue ( ) #NEWLINE# f . write ( repr ( v ) ) #NEWLINE# f . write ( '\n' ) #NEWLINE# f . close ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# s . close ( ) #NEWLINE# sys . exit ( 0 )