def redirect_stream(system, target):
 if (target is None):
  target_fd = os.open(os.devnull, os.O_RDWR)
 else:
  target_fd = target.fileno()
 try:
  os.dup2(target_fd, system.fileno())
 except OSError as err:
  raise DaemonError('Could not redirect {0} to {1}: {2}'.format(system, target, err))

def redirect_stream ( system , target ) : if ( target is None ) : target_fd = os . open ( os . devnull , os . O_RDWR ) else : target_fd = target . fileno ( ) try : os . dup2 ( target_fd , system . fileno ( ) ) except OSError as err : raise DaemonError ( 'Could not redirect {0} to {1}: {2}' . format ( system , target , err ) )
redirect unix streams if none .