#NEWLINE# def do_execute( self , code , silent , store_history = True , user_expressions = None , allow_stdin = False ) : #NEWLINE# #INDENT# code = code . strip ( ) #NEWLINE# reply = { #NEWLINE# #INDENT# 'status' : 'ok' , #NEWLINE# 'user_expressions' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# if ( code == 'start' ) : #NEWLINE# #INDENT# child = Popen ( [ 'bash' , '-i' , '-c' , 'sleep 30' ] , stderr = PIPE ) #NEWLINE# self . children . append ( child ) #NEWLINE# reply [ 'user_expressions' ] [ 'pid' ] = self . children [ ( - 1 ) ] . pid #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( code == 'check' ) : #NEWLINE# #INDENT# reply [ 'user_expressions' ] [ 'poll' ] = [ child . poll ( ) for child in self . children ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( code == 'sleep' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# time . sleep ( 10 ) #NEWLINE# #UNINDENT# except KeyboardInterrupt : #NEWLINE# #INDENT# reply [ 'user_expressions' ] [ 'interrupted' ] = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# reply [ 'user_expressions' ] [ 'interrupted' ] = False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# reply [ 'status' ] = 'error' #NEWLINE# reply [ 'ename' ] = 'Error' #NEWLINE# reply [ 'evalue' ] = code #NEWLINE# reply [ 'traceback' ] = [ ( 'no such command: %s' % code ) ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return reply