Delete images not in use or installed via image_present

    .. warning::

        Only image_present states that are included via the
        top file will be detected.
425022
def image_vacuum(name):
    '''
    
    '''
    name = name.lower()
    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}

    # list of images to keep
    images = []

    # retrieve image_present state data for host
    for state in __salt__['state.show_lowstate']():
        # don't throw exceptions when not highstate run
        if 'state' not in state:
            continue

        # skip if not from this state module
        if state['state'] != __virtualname__:
            continue
        # skip if not image_present
        if state['fun'] not in ['image_present']:
            continue
        # keep images installed via image_present
        if 'name' in state:
            if _is_uuid(state['name']):
                images.append(state['name'])
            elif _is_docker_uuid(state['name']):
                state['name'] = __salt__['imgadm.docker_to_uuid'](state['name'])
                if not state['name']:
                    continue
                images.append(state['name'])

    # retrieve images in use by vms
    for image_uuid in __salt__['vmadm.list'](order='image_uuid'):
        if image_uuid not in images:
            images.append(image_uuid)

    # purge unused images
    ret['result'] = True
    for image_uuid in __salt__['imgadm.list']():
        if image_uuid in images:
            continue

        image = __salt__['imgadm.get'](image_uuid)
        if image['manifest']['name'] == 'docker-layer':
            # NOTE: docker images are made of multiple layers, loop over them
            while image:
                image_uuid = image['manifest']['uuid']
                if image_uuid in __salt__['imgadm.delete'](image_uuid):
                    ret['changes'][image_uuid] = None
                else:
                    ret['result'] = False
                    ret['comment'] = 'failed to delete images'
                if 'origin' in image['manifest']:
                    image = __salt__['imgadm.get'](image['manifest']['origin'])
                else:
                    image = None
        else:
            # NOTE: normal images can just be delete
            if image_uuid in __salt__['imgadm.delete'](image_uuid):
                ret['changes'][image_uuid] = None
            else:
                ret['result'] = False
                ret['comment'] = 'failed to delete images'

    if ret['result'] and not ret['changes']:
        ret['comment'] = 'no images deleted'
    elif ret['result'] and ret['changes']:
        ret['comment'] = 'images deleted'

    return ret
530944
def image_delete(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.delete_image(**kwargs)
74223
def delete(self):
        
        if os.path.isfile(self.path):
            os.remove(self.path)
        else:
            shutil.rmtree(self.path)
1015605
def clean(&block)
      @target.files.each do |object|
        unless @source.files.include? object.key
          block.call(object)
          object.destroy
        end
      end
    end
152259
public function removePortraitImage()
    {
        $sizes = $this->_mixer->getValue('sizes');

        if (empty($sizes)) {
            $sizes = explode(' ', 'original large medium small thumbnail square');
        } else {
            $sizes = array_keys($sizes);
        }

        foreach ($sizes as $size) {
            $file = $this->_mixer->getPortraitFile($size);
            $this->_mixer->deletePath($file);
        }

        $this->set('filename', null);
    }
179029
def _cleanup():
    '''
    
    '''
    for inst in _ACTIVE[:]:
        res = inst.isalive()
        if res is not True:
            try:
                _ACTIVE.remove(inst)
            except ValueError:
                # This can happen if two threads create a new Terminal instance
                # It's harmless that it was already removed, so ignore.
                pass
33876
def delete(self, id):
        
        if id in self._images.keys():
            del self._images[id]
        self.tk.delete(id)
1062404
def delete_thumbnails(self, image_file):
        
        thumbnail_keys = self._get(image_file.key, identity='thumbnails')
        if thumbnail_keys:
            # Delete all thumbnail keys from store and delete the
            # thumbnail ImageFiles.

            for key in thumbnail_keys:
                thumbnail = self._get(key)
                if thumbnail:
                    self.delete(thumbnail, False)
                    thumbnail.delete()  # delete the actual file

            # Delete the thumbnails key from store
            self._delete(image_file.key, identity='thumbnails')
1083500
def clear_imgs(self) -> None:
        ""
        self._preview_header.value = self._heading
        self._img_pane.children = tuple()
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
106020
def remove(in_bam):
    
    if utils.file_exists(in_bam):
        utils.remove_safe(in_bam)
    if utils.file_exists(in_bam + ".bai"):
        utils.remove_safe(in_bam + ".bai")
1155854
def _remove_files(self, predicate):
        
        found = False
        for i in range(len(self.files) - 1, -1, -1):
            if predicate(self.files[i]):
                self.debug_print(" removing " + self.files[i])
                del self.files[i]
                found = True
        return found
1147351
def purge
      output.each do |file, format|
        if File.exist?(file)
          rm(file)
          report "Removed #{file}"
        end
      end
    end
1018989
def delete_file
      file = Fae::File.find_by_id(params[:id])
      file.remove_asset = true
      file.save
      render body: nil
    end
204099
def clean(self):

        """"""

        for s in self.visible_files.values():
            s.clean()
        for s in [sub[1][x] for sub in self.avail_files.values() for x in sub[1]]: # Double list comprehensions aren't very
            s.clean()
382119
def delete_image(self, image_id):
        
        url = self.api_url + '/api/images/' + image_id
        response = self._request_url(url, 'delete', with_access_token=True)
        headers, result = self._parse_and_check(response)
        return Image.from_dict(result)
866314
def clearImg(self):
        """"""
        self.img.setImage(np.array([[0]]))
        self.img.image = None