@contextmanager
def run_interactive_shell_command(command, **kwargs):
 if ((not kwargs.get('shell', False)) and isinstance(command, str)):
  command = shlex.split(command)
 args = {'stdout': PIPE, 'stderr': PIPE, 'stdin': PIPE, 'universal_newlines': True}
 args.update(kwargs)
 process = Popen(command, **args)
 try:
  (yield process)
 finally:
  if (args['stdout'] is PIPE):
   process.stdout.close()
  if (args['stderr'] is PIPE):
   process.stderr.close()
  if (args['stdin'] is PIPE):
   process.stdin.close()
  process.wait()

@ contextmanager def run_interactive_shell_command ( command , ** kwargs ) : if ( ( not kwargs . get ( 'shell' , False ) ) and isinstance ( command , str ) ) : command = shlex . split ( command ) args = { 'stdout' : PIPE , 'stderr' : PIPE , 'stdin' : PIPE , 'universal_newlines' : True } args . update ( kwargs ) process = Popen ( command , ** args ) try : ( yield process ) finally : if ( args [ 'stdout' ] is PIPE ) : process . stdout . close ( ) if ( args [ 'stderr' ] is PIPE ) : process . stderr . close ( ) if ( args [ 'stdin' ] is PIPE ) : process . stdin . close ( ) process . wait ( )
runs a single command in shell and provides stdout .