update a container's image,
        :param container_name: `class`:`str`, container name
        :param image_name: `class`:`str`, the full image name, like alpine:3.3
        :return: `class`:`bool`, True if success, otherwise False.
435508
def update_image(self, container_name, image_name):
        
        code, container = self.get_container(container_name)
        if code != httplib.OK:
            self.logger.error("Container %s is not exists. error code %s, error message %s", container_name, code,
                              container)
            return False

        _, old_image_name, _ = utils.parse_image_name(container.image)
        repository, name, version = utils.parse_image_name(image_name)
        if not repository or repository.lower() != DOCKER_NEG:
            self.logger.error("You image %s must have a 'docker.neg/' prefix string", image_name)
            return False

        if not repo.image_exists(name, tag=version):
            self.logger.error("You image %s must be location in docker.neg repository.", image_name)
            return False

        if old_image_name.lower() != name.lower():
            self.logger.error("You image %s must be same with container's Image.", image_name, container.image)
            return False

        code, result = self.update(container_name, tag=version)
        if code != httplib.OK:
            self.logger.error("Update container %s with image failure, code %s, result %s", container_name, code,
                              result)
            return False

        return True
692819
def set_image(self, image, filename=None, resize=False):
        
        if self.id:
            data = self.connection.post('add_image', filename,
                video_id=self.id, image=image.to_dict(), resize=resize)
            if data:
                self.image = Image(data=data)
775128
def update_image_position(image, new_pos)
      raise ArgumentError, "Invalid argument 'image'. Expected Image, got #{image.class}." unless image.is_a?(Image)
      # Remove old position key:
      @image_positions.delete(image.pos_slice)
      # Add the new position:
      @image_positions[new_pos] = image
    end
124203
async def tag(self, name: str, repo: str, *, tag: str = None) -> bool:
        
        params = {"repo": repo}

        if tag:
            params["tag"] = tag

        await self.docker._query(
            "images/{name}/tag".format(name=name),
            "POST",
            params=params,
            headers={"content-type": "application/json"},
        )
        return True
570645
def load_img(name):
    """"""

    fullname = name
    try:
        image = pygame.image.load(fullname)
        if image.get_alpha() is None:
            image = image.convert()
        else:
            image = image.convert_alpha()
    except pygame.error, message:
        print "Error: couldn't load image: ", fullname
        raise SystemExit, message
    return (image, image.get_rect())
1338739
def update_image(self, image_id, user_name, desc=None):
        """"""
        desc = desc if desc else ''
        data = {"username": user_name,
                "description": desc}

        return self._post('/images/%s' % image_id, data)
1067971
def _update_container_metrics(self, instance, subcontainer, kube_labels):
        """"""
        tags = list(instance.get('tags', []))  # add support for custom tags

        if len(subcontainer.get('aliases', [])) >= 1:
            # The first alias seems to always match the docker container name
            container_name = subcontainer['aliases'][0]
        else:
            self.log.debug("Subcontainer doesn't have a name, skipping.")
            return

        tags.append('container_name:%s' % container_name)

        container_image = self.kubeutil.image_name_resolver(subcontainer['spec'].get('image'))
        if container_image:
            tags.append('container_image:%s' % container_image)

            split = container_image.split(":")
            if len(split) > 2:
                # if the repo is in the image name and has the form 'docker.clearbit:5000'
                # the split will be like [repo_url, repo_port/image_name, image_tag]. Let's avoid that
                split = [':'.join(split[:-1]), split[-1]]

            tags.append('image_name:%s' % split[0])
            if len(split) == 2:
                tags.append('image_tag:%s' % split[1])

        try:
            cont_labels = subcontainer['spec']['labels']
        except KeyError:
            self.log.debug("Subcontainer, doesn't have any labels")
            cont_labels = {}

        # Collect pod names, namespaces, rc...
        if KubeUtil.NAMESPACE_LABEL in cont_labels and KubeUtil.POD_NAME_LABEL in cont_labels:
            # Kubernetes >= 1.2
            tags += self._get_post_1_2_tags(cont_labels, subcontainer, kube_labels)

        elif KubeUtil.POD_NAME_LABEL in cont_labels:
            # Kubernetes <= 1.1
            tags += self._get_pre_1_2_tags(cont_labels, subcontainer, kube_labels)

        else:
            # Those are containers that are not part of a pod.
            # They are top aggregate views and don't have the previous metadata.
            tags.append("pod_name:no_pod")

        # if the container should be filtered we return its tags without publishing its metrics
        is_filtered = self.kubeutil.are_tags_filtered(tags)
        if is_filtered:
            self._filtered_containers.add(subcontainer['id'])
            return tags

        stats = subcontainer['stats'][-1]  # take the latest
        self._publish_raw_metrics(NAMESPACE, stats, tags)

        if subcontainer.get("spec", {}).get("has_filesystem") and stats.get('filesystem', []) != []:
            fs = stats['filesystem'][-1]
            if fs['capacity'] > 0:
                fs_utilization = float(fs['usage'])/float(fs['capacity'])
                self.publish_gauge(self, NAMESPACE + '.filesystem.usage_pct', fs_utilization, tags)
            else:
                self.log.debug("Filesystem capacity is 0: cannot report usage metrics.")

        if subcontainer.get("spec", {}).get("has_network"):
            net = stats['network']
            self.publish_rate(self, NAMESPACE + '.network_errors',
                              sum(float(net[x]) for x in NET_ERRORS),
                              tags)

        return tags
1064866
def image_meta_set(self,
                       image_id=None,
                       name=None,
                       **kwargs):  # pylint: disable=C0103
        '''
        
        '''
        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
        if not image_id:
            return {'Error': 'A valid image name or id was not specified'}
        nt_ks.images.set_meta(image_id, kwargs)
        return {image_id: kwargs}
1064555
def commit_container(self, container_id, image=None, message=None):
        
        logger.info("committing container '%s'", container_id)
        logger.debug("container_id = '%s', image = '%s', message = '%s'",
                     container_id, image, message)
        tag = None
        if image:
            tag = image.tag
            image = image.to_str(tag=False)
        response = self.d.commit(container_id, repository=image, tag=tag, message=message)
        logger.debug("response = '%s'", response)
        try:
            return response['Id']
        except KeyError:
            logger.error("ID missing from commit response")
            raise RuntimeError("ID missing from commit response")
37895
def update(self, title=None, description=None):
        """"""
        url = (self._imgur._base_url + "/3/image/"
               "{0}".format(self._delete_or_id_hash))
        is_updated = self._imgur._send_request(url, params=locals(),
                                               method='POST')
        if is_updated:
            self.title = title or self.title
            self.description = description or self.description
        return is_updated
1336529
async def inspect(self, name: str) -> Mapping:
        
        response = await self.docker._query_json("images/{name}/json".format(name=name))
        return response
38578
def has_image(self, image_name):
        

        try:
            self.docker_client.images.get(image_name)
            return True
        except docker.errors.ImageNotFound:
            return False
477443
def update_image(self):
        
        if self._image:
            self._image.set_cmap(self.get_cmap())
            _pylab.draw()
1219456
def names_container(self):
        
        if not self.stream:
            return os.path.isdir(self.object_name)
        else:
            return False
16099
def has_image(self, name: str) -> bool:
        
        path = "docker/images/{}".format(name)
        r = self.__api.head(path)
        if r.status_code == 204:
            return True
        elif r.status_code == 404:
            return False
        self.__api.handle_erroneous_response(r)
20944
def apply(self, resource):
        
        if isinstance(resource, Image.Image):
            return getattr(self, '_' + self.method)(resource)
        else:
            raise ValueError('Unsupported resource format: %s' % str(type(resource)))
566018
def start_container(self, image, container_name: str, repo_path: Path):
        
        command = "bash -i"

        if self.inherit_image:
            command = "sh -i"

        container = self.client.containers.run(image, command=command, detach=True, tty=True, name=container_name,
                                               working_dir=str((Path("/srv/data") / self.cwd).resolve()),
                                               auto_remove=True)

        container.exec_run(["mkdir", "-p", "/srv/scripts"])
        container.put_archive("/srv", self.tar_files(repo_path))
        container.put_archive("/srv/scripts", self.tar_runner())

        return container