def _removeSafely(path):
    """
    Safely remove a path, recursively.

    If C{path} does not contain a node named C{_trial_marker}, a
    L{_NoTrialmarker} exception is raised and the path is not removed.
    """
    if not path.child('_trial_marker').exists():
        raise _NoTrialMarker(
            '%r is not a trial temporary path, refusing to remove it'
            % (path,))
    try:
        path.remove()
    except __HOLE__, e:
        print ("could not remove %r, caught OSError [Errno %s]: %s"
               % (path, e.errno, e.strerror))
        try:
            newPath = FilePath('_trial_temp_old%s' % (randrange(1000000),))
            path.moveTo(newPath)
        except OSError, e:
            print ("could not rename path, caught OSError [Errno %s]: %s"
                   % (e.errno,e.strerror))
            raise
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/trial/util.py/_removeSafely