def redirect_aware_commmunicate(p, sys=_sys):
 assert (sys is not None)
 (out, err) = p.communicate()
 if redirecting_io(sys=sys):
  if out:
   sys.stdout.write(out)
   out = None
  if err:
   sys.stderr.write(err)
   err = None
 return (out, err)

def redirect_aware_commmunicate ( p , sys = _sys ) : assert ( sys is not None ) ( out , err ) = p . communicate ( ) if redirecting_io ( sys = sys ) : if out : sys . stdout . write ( out ) out = None if err : sys . stderr . write ( err ) err = None return ( out , err )
variant of process .