Remove file, and raise OSError if still exists.
438656
def remove_file(path, remove=os.remove, exists=os.path.exists):
    """"""
    try:
        remove(path)
    except OSError:
        if exists(path):
            raise
1684
def delete(self):
        """"""
        if self.isfile:
            os.remove(self.fn)
        elif self.isdir:
            shutil.rmtree(self.fn)
1133602
def remove(path):
    '''
    
    '''
    try:
        os.remove(path)
    except OSError as exc:
        if exc.errno != errno.ENOENT:
            raise
1090803
def cleanup(self):
        """"""
        shutil.rmtree(self.name, onerror=lambda *a: os.chmod(a[1], __import__('stat').S_IWRITE) or os.unlink(a[1]))
        if os.path.exists(self.name):
            raise IOError(17, "File exists: '{}'".format(self.name))
92533
def try_remove(self):
        
        if self.islink():
            self.unlink()
        elif self.isfile():
            self.remove()
        elif self.isdir():
            self.empty_directory()
            if self.isdir():
                self.rmdir()
        else:
            return False
        return True
696147
def delete_if_exists(file)
      # Windows cannot delete open files, but we only have a path at this point
      # so it's too late to close the file. report failure to delete files but
      # otherwise continue without failing test.
      begin
        File.delete(file) if File.file?(file)
      rescue Exception => e
        puts "\nWARNING: #{e.message}"
      end
    end
1257907
def remove_file(self, name):
        """"""
        assert compat.is_native(name)
        self.check_write(name)
        # self.cur_dir_meta.remove(name)
        self.ftp.delete(name)
        self.remove_sync_info(name)
1110418
def remove_file(self):
        """"""
        if not self.fullpath or not self.archived:
            raise RuntimeError("""Can't remove a non-archived data product""")
        try:
            os.remove(self.fullpath)
        except:
            print("Error removing %s: %s" % (self.fullpath, sys.exc_info()[1]))
850373
def kill(self):
        
        if os.path.isfile(self.filename):
            os.remove(self.filename)
        return
1132852
def remove(path, **kwargs):
    '''
    
    '''
    path = os.path.expanduser(path)

    if not os.path.isabs(path):
        raise SaltInvocationError('File path must be absolute: {0}'.format(path))

    try:
        if os.path.isfile(path) or os.path.islink(path):
            os.remove(path)
            return True
        elif os.path.isdir(path):
            shutil.rmtree(path)
            return True
    except (OSError, IOError) as exc:
        raise CommandExecutionError(
            'Could not remove \'{0}\': {1}'.format(path, exc)
        )
    return False
601447
def remove_file(self, path):
        """"""
        self.get_file(path).remove()
        self.remove_cache_buster(path)
667257
def delete(self, *args, **kwargs):
        
        try:
            os.remove(self.file.file.name)
        # image does not exist
        except (OSError, IOError):
            pass
        super(Image, self).delete(*args, **kwargs)
636354
def delete_if_error(path):
    ''''''
    try:
        yield
    except Exception:
        if os.path.exists(path):
            os.remove(path)
        raise
604022
def remove(self, path):
        """"""
        p = self.cmd('shell', 'rm', path)
        stdout, stderr = p.communicate()
        if stdout or stderr:
            return False
        else:
            return True
182661
def _cleanup(path: str) -> None:
    """"""
    if os.path.isdir(path):
        shutil.rmtree(path)
209425
def delete(self, file_path):
        """"""
        if os.sep in file_path:
            directory, file_name = file_path.rsplit(os.sep, 1)
            self.chdir(directory)
            return self.session.delete(file_name)

        else:
            return self.session.delete(file_path)
562362
def rm(filename, recursive=False, force=False):
    """"""
    return auto(remove_file, filename, recursive, force)