#NEWLINE# def autorun_get_interactive_session( cmds , **kargs ) : #NEWLINE# #INDENT# class StringWriter ( ) : #NEWLINE# #INDENT# def __init__( self ) : #NEWLINE# #INDENT# self . s = '' #NEWLINE# #UNINDENT# def write( self , x ) : #NEWLINE# #INDENT# self . s += x #NEWLINE# #UNINDENT# #UNINDENT# sw = StringWriter ( ) #NEWLINE# ( sstdout , sstderr ) = ( sys . stdout , sys . stderr ) #NEWLINE# try : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# sys . stdout = sys . stderr = sw #NEWLINE# res = autorun_commands ( cmds , ** kargs ) #NEWLINE# #UNINDENT# except StopAutorun as e : #NEWLINE# #INDENT# e . code_run = sw . s #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# ( sys . stdout , sys . stderr ) = ( sstdout , sstderr ) #NEWLINE# #UNINDENT# return ( sw . s , res )