def win_cmd(command, **kwargs):
 logging_command = kwargs.get('logging_command', None)
 try:
  proc = NonBlockingPopen(command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stream_stds=kwargs.get('display_ssh_output', True), logging_command=logging_command)
  if (logging_command is None):
   log.debug("Executing command(PID %s): '%s'", proc.pid, command)
  else:
   log.debug("Executing command(PID %s): '%s'", proc.pid, logging_command)
  proc.poll_and_read_until_finish()
  proc.communicate()
  return proc.returncode
 except Exception as err:
  log.error("Failed to execute command '{0}': {1}\n".format(logging_command, err), exc_info=True)
 return 1

def win_cmd ( command , ** kwargs ) : logging_command = kwargs . get ( 'logging_command' , None ) try : proc = NonBlockingPopen ( command , shell = True , stderr = subprocess . PIPE , stdout = subprocess . PIPE , stream_stds = kwargs . get ( 'display_ssh_output' , True ) , logging_command = logging_command ) if ( logging_command is None ) : log . debug ( "Executing command(PID %s): '%s'" , proc . pid , command ) else : log . debug ( "Executing command(PID %s): '%s'" , proc . pid , logging_command ) proc . poll_and_read_until_finish ( ) proc . communicate ( ) return proc . returncode except Exception as err : log . error ( "Failed to execute command '{0}': {1}\n" . format ( logging_command , err ) , exc_info = True ) return 1
wrapper for commands to be run against windows boxes .