#NEWLINE# def dogshell( self , args , stdin = None , check_return_code = True , use_cl_args = False ) : #NEWLINE# #INDENT# ' Helper function to call the dog shell command\n        ' #NEWLINE# cmd = ( [ 'dog' , '--config' , self . config_file . name ] + args ) #NEWLINE# if use_cl_args : #NEWLINE# #INDENT# cmd = ( [ 'dog' , '--api-key={0}' . format ( os . environ [ 'DATADOG_API_KEY' ] ) , '--application-key={0}' . format ( os . environ [ 'DATADOG_APP_KEY' ] ) ] + args ) #NEWLINE# #UNINDENT# proc = subprocess . Popen ( err , stdout = subprocess . PIPE , stderr = subprocess . PIPE , stdin = subprocess . PIPE ) #NEWLINE# if stdin : #NEWLINE# #INDENT# ( out , err ) = proc . communicate ( stdin . encode ( 'utf-8' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( out , err ) = proc . communicate ( ) #NEWLINE# #UNINDENT# proc . wait ( ) #NEWLINE# return_code = proc . returncode #NEWLINE# if check_return_code : #NEWLINE# #INDENT# self . assertEquals ( return_code , 0 , err ) #NEWLINE# self . assertEquals ( err , b'' ) #NEWLINE# #UNINDENT# return ( out . decode ( 'utf-8' ) , err . decode ( 'utf-8' ) , return_code )