Deregister existing image with the same name in the destination region
172314
function(next) {
           logger.log("DeregisterImage:", images);
           if (shell.isArg("-dry-run", options)) return next();
           lib.forEachSeries(images, function(img, next2) {
               aws.ec2DeregisterImage(img.imageId, { snapshots: 1 }, next2);
           }, next);
       }
497168
function imagetransfer($src_im, $dst_im) {
        if (is_resource($dst_im)) imagedestroy($dst_im);
        $dst_im = & $src_im;
        return $dst_im;
    }
1178464
def image_meta_delete(self,
                          image_id=None,     # pylint: disable=C0103
                          name=None,
                          keys=None):
        '''
        
        '''
        nt_ks = self.compute_conn
        if name:
            for image in nt_ks.images.list():
                if image.name == name:
                    image_id = image.id  # pylint: disable=C0103
        pairs = keys.split(',')
        if not image_id:
            return {'Error': 'A valid image name or id was not specified'}
        nt_ks.images.delete_meta(image_id, pairs)
        return {image_id: 'Deleted: {0}'.format(pairs)}
530944
def image_delete(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.delete_image(**kwargs)
544631
def deinterlace(self, raw):
        

        # Values per row (of the target image)
        vpr = self.width * self.planes

        # Make a result array, and make it big enough.  Interleaving
        # writes to the output array randomly (well, not quite), so the
        # entire output array must be in memory.
        fmt = 'BH'[self.bitdepth > 8]
        a = array(fmt, [0]*vpr*self.height)
        source_offset = 0

        for xstart, ystart, xstep, ystep in _adam7:
            if xstart >= self.width:
                continue
            # The previous (reconstructed) scanline.  None at the
            # beginning of a pass to indicate that there is no previous
            # line.
            recon = None
            # Pixels per row (reduced pass image)
            ppr = int(math.ceil((self.width-xstart)/float(xstep)))
            # Row size in bytes for this pass.
            row_size = int(math.ceil(self.psize * ppr))
            for y in range(ystart, self.height, ystep):
                filter_type = raw[source_offset]
                source_offset += 1
                scanline = raw[source_offset:source_offset+row_size]
                source_offset += row_size
                recon = self.undo_filter(filter_type, scanline, recon)
                # Convert so that there is one element per pixel value
                flat = self.serialtoflat(recon, ppr)
                if xstep == 1:
                    assert xstart == 0
                    offset = y * vpr
                    a[offset:offset+vpr] = flat
                else:
                    offset = y * vpr + xstart * self.planes
                    end_offset = (y+1) * vpr
                    skip = self.planes * xstep
                    for i in range(self.planes):
                        a[offset+i:end_offset:skip] = \
                            flat[i::self.planes]
        return a
391769
function (elbName, instanceId, cb) {
      // support removing array of instances at once
      var instance = mapInstances(instanceId),
        params   = { Instances: instance, LoadBalancerName: elbName };
      api.deregisterInstancesFromLoadBalancer(params, cb);
    }
910417
def redo(self):
        """"""
        image = self.channel.get_current_image()
        if image is None:
            return True

        path = image.get('path', None)
        if path is None:
            self.fv.show_error(
                "Cannot open image: no value for metadata key 'path'")
            return

        # TODO: How to properly reset GUI components?
        #       They are still showing info from prev FITS.
        # No-op for ASDF
        if path.endswith('asdf'):
            return True

        if path != self.img_path:
            # <-- New file is being looked at
            self.img_path = path

            # close previous file opener, if any
            if self.file_obj is not None:
                try:
                    self.file_obj.close()
                except Exception:
                    pass

            self.file_obj = io_fits.get_fitsloader(logger=self.logger)

            # TODO: specify 'readonly' somehow?
            self.file_obj.open_file(path)

            upper = len(self.file_obj) - 1
            self.prep_hdu_menu(self.w.hdu, self.file_obj.hdu_info)
            self.num_hdu = upper
            self.logger.debug("there are %d hdus" % (upper + 1))
            self.w.numhdu.set_text("%d" % (upper + 1))

            self.w.hdu.set_enabled(len(self.file_obj) > 0)

        name = image.get('name', iohelper.name_image_from_path(path))
        idx = image.get('idx', None)
        # remove index designation from root of name, if any
        match = re.match(r'^(.+)\[(.+)\]$', name)
        if match:
            name = match.group(1)
        self.name_pfx = name

        htype = None
        if idx is not None:
            # set the HDU in the drop down if known
            info = self.file_obj.hdu_db.get(idx, None)
            if info is not None:
                htype = info.htype.lower()
                toc_ent = self._toc_fmt % info
                self.w.hdu.show_text(toc_ent)

        # rebuild the NAXIS controls, if necessary
        # No two images in the same channel can have the same name.
        # Here we keep track of the name to decide if we need to rebuild
        if self.img_name != name:
            self.img_name = name
            dims = [0, 0]
            data = image.get_data()
            if data is None:
                # <- empty data part to this HDU
                self.logger.warning("Empty data part in HDU %s" % (str(idx)))

            elif htype in ('bintablehdu', 'tablehdu',):
                pass

            elif htype not in ('imagehdu', 'primaryhdu', 'compimagehdu'):
                self.logger.warning("HDU %s is not an image (%s)" % (
                    str(idx), htype))

            else:
                mddata = image.get_mddata()
                if mddata is not None:
                    dims = list(mddata.shape)
                    dims.reverse()

            self.build_naxis(dims, image)
855124
def remove_uri(self, image):
        '''
        '''
        image = image or ''
        uri = self.get_uri(image) or ''
        image = image.replace('%s://' %uri,'', 1)
        return image.strip('-').rstrip('/')
927601
def image_mapped(name):
    """"""
    try:
        out = check_output(['rbd', 'showmapped'])
        if six.PY3:
            out = out.decode('UTF-8')
    except CalledProcessError:
        return False

    return name in out
545856
def _delete_images(self, instance):
        """"""
        UserMediaImage.objects.filter(
            content_type=ContentType.objects.get_for_model(instance),
            object_id=instance.pk,
            user=instance.user,
        ).delete()
411824
def terminate_and_create_image(name):
    '''
    
    '''
    node = _host_node()
    operation = _gcp().instances().delete(project=DEFAULT_PROJECT, zone=DEFAULT_ZONE,
                                          instance=node['real_name']).execute()
    while True:
        status = get_zone_operation_status(operation=operation)
        if status == 'DONE':
            break

        print 'Terminating instance [OPERATION %s]' % status
        time.sleep(5)

    body = {
        'name': name,
        'sourceDisk': node['source_disk'],
    }

    operation = _gcp().images().insert(project=DEFAULT_PROJECT, body=body).execute()
    while True:
        status = get_global_operation_status(operation=operation)
        if status == 'DONE':
            break

        print 'Creating image [OPERATION %s]' % status
        time.sleep(5)

    print 'Created image: %s' % operation['targetLink']
765019
def delete(resource_group_name, image_name, custom_headers:nil)
      response = delete_async(resource_group_name, image_name, custom_headers:custom_headers).value!
      nil
    end
241602
function destroy()
    {
        if ( $this->ImageObjectRef === null )
            return;
        if ( is_resource( $this->ImageObject ) and get_resource_type( $this->ImageObject ) == 'gd' )
            ImageDestroy( $this->ImageObject );
        eZImageInterface::unregisterImage( $this->ImageObjectRef );
        unset( $this->ImageObject );
        $this->ImageObject = null;
        $this->ImageObjectRef = null;
    }
220773
def remove_image_info_cb(self, gshell, channel, iminfo):
        """"""
        chname = channel.name
        if chname not in self.name_dict:
            return

        fileDict = self.name_dict[chname]

        name = iminfo.name
        if name not in fileDict:
            return

        del fileDict[name]
        self.logger.debug('{0} removed from ChangeHistory'.format(name))

        if not self.gui_up:
            return False

        self.clear_selected_history()
        self.recreate_toc()
8312
private static void renameCheckpointInDir(StorageDirectory sd, long txid)
      throws IOException {
    File ckpt = NNStorage.getStorageFile(sd, NameNodeFile.IMAGE_NEW, txid);
    File curFile = NNStorage.getStorageFile(sd, NameNodeFile.IMAGE, txid);
    // renameTo fails on Windows if the destination file 
    // already exists.
    LOG.info("Renaming  " + ckpt.getAbsolutePath() + " to "
        + curFile.getAbsolutePath());
    if (!ckpt.renameTo(curFile)) {
      if (!curFile.delete() || !ckpt.renameTo(curFile)) {
        throw new IOException("renaming  " + ckpt.getAbsolutePath() + " to "  + 
            curFile.getAbsolutePath() + " FAILED");
      }
    }    
  }
607973
async def rename(self, src, dst):
        
        if src == dst:
            raise ResponseError("source and destination objects are the same")

        data = await self.dump(src)

        if data is None:
            raise ResponseError("no such key")

        ttl = await self.pttl(src)

        if ttl is None or ttl < 1:
            ttl = 0

        await self.delete(dst)
        await self.restore(dst, ttl, data)
        await self.delete(src)

        return True
641494
def demean(in_file, in_mask, only_mask=False, newpath=None):
    """"""
    import os
    import numpy as np
    import nibabel as nb
    from nipype.utils.filemanip import fname_presuffix

    out_file = fname_presuffix(in_file, suffix='_demeaned',
                               newpath=os.getcwd())
    nii = nb.load(in_file)
    msk = nb.load(in_mask).get_data()
    data = nii.get_data()
    if only_mask:
        data[msk > 0] -= np.median(data[msk > 0])
    else:
        data -= np.median(data[msk > 0])
    nb.Nifti1Image(data, nii.affine, nii.header).to_filename(
        out_file)
    return out_file