def run_cmd(pl, cmd, stdin=None, strip=True):
 try:
  p = Popen(cmd, shell=False, stdout=PIPE, stdin=PIPE)
 except OSError as e:
  pl.exception(u'Could not execute command ({0}): {1}', e, cmd)
  return None
 else:
  (stdout, err) = p.communicate((stdin if (stdin is None) else stdin.encode(get_preferred_output_encoding())))
  stdout = stdout.decode(get_preferred_input_encoding())
 return (stdout.strip() if strip else stdout)

def run_cmd ( pl , cmd , stdin = None , strip = True ) : try : p = Popen ( cmd , shell = False , stdout = PIPE , stdin = PIPE ) except OSError as e : pl . exception ( u'Could not execute command ({0}): {1}' , e , cmd ) return None else : ( stdout , err ) = p . communicate ( ( stdin if ( stdin is None ) else stdin . encode ( get_preferred_output_encoding ( ) ) ) ) stdout = stdout . decode ( get_preferred_input_encoding ( ) ) return ( stdout . strip ( ) if strip else stdout )
run command and return its stdout .