#NEWLINE# def _run_process( self , command , * args , **kwargs ) : #NEWLINE# #INDENT# stdout = kwargs . get ( 'stdout' , sys . stdout ) #NEWLINE# stderr = kwargs . get ( 'stderr' , sys . stderr ) #NEWLINE# kwargs . setdefault ( 'cwd' , self . path ) #NEWLINE# if isinstance ( command , basestring ) : #NEWLINE# #INDENT# command = shlex . split ( command ) #NEWLINE# #UNINDENT# command = map ( str , command ) #NEWLINE# env = os . environ . copy ( ) #NEWLINE# env [ 'PYTHONUNBUFFERED' ] = '1' #NEWLINE# if kwargs . get ( 'env' ) : #NEWLINE# #INDENT# for ( key , value ) in kwargs [ 'env' ] . iteritems ( ) : #NEWLINE# #INDENT# env [ key ] = value #NEWLINE# #UNINDENT# #UNINDENT# kwargs [ 'env' ] = env #NEWLINE# kwargs [ 'bufsize' ] = 0 #NEWLINE# self . log . info ( 'Running {}' . format ( command ) ) #NEWLINE# try : #NEWLINE# #INDENT# proc = Popen ( command , * args , ** msg ) #NEWLINE# #UNINDENT# except OSError as exc : #NEWLINE# #INDENT# if ( not self . whereis ( command [ 0 ] , env ) ) : #NEWLINE# #INDENT# msg = 'ERROR: Command not found: {}' . format ( command [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg = traceback . format_exc ( ) #NEWLINE# #UNINDENT# raise CommandError ( command , 1 , stdout = None , stderr = msg ) #NEWLINE# #UNINDENT# return proc