#NEWLINE# def exec_command( cmd , timeout = 5 , stdout = subprocess . PIPE ) : #NEWLINE# #INDENT# proc = subprocess . Popen ( cmd , stdout = stdout , stderr = subprocess . PIPE ) #NEWLINE# timer = Timer ( timeout , proc . kill ) #NEWLINE# timer . start ( ) #NEWLINE# ( stdout , stderr ) = proc . communicate ( ) #NEWLINE# timer . cancel ( ) #NEWLINE# return { #NEWLINE# #INDENT# 'return_code' : proc . returncode , #NEWLINE# 'stdout' : stdout , #NEWLINE# 'stderr' : stderr , #NEWLINE# #UNINDENT# }