Check if a container with a given tag exists. Kill it if it exists.
    No extra side effects. Handles and reraises TypeError, and
    APIError exceptions.
971192
def removeContainer(tag):
    '''
    '''
    container = getContainerByTag(tag)

    if container:
        # Build an Image using the dockerfile in the path
        try:
            container.remove(force=True)
            #print("Removed container", tag, "...")
        except APIError as exc:
            eprint("Unhandled error while removing container", tag)
            raise exc
30356
def stop(name):
    '''
    
    '''
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)
    cmd = ['lxc-stop', '-n', name]
    subprocess.check_call(cmd)
701185
def tag(name, tag_name):
    

    with LOCK:
        # just to check if <name> exists
        metric(name)

        TAGS.setdefault(tag_name, set()).add(name)
326862
function(container) {
      var index = WireIt.indexOf(container, this.containers);
      if( index != -1 ) {
	  
	container.remove();
	    
        this.containers[index] = null;
        this.containers = WireIt.compact(this.containers);
      
	this.eventRemoveContainer.fire(container);

	this.eventChanged.fire(this);
      }
   }
335295
def container_exists(self, id=None, name=None):
        
        exists = False
        if id and self.container_by_id(id):
            exists = True
        elif name and self.container_by_name(name):
            exists = True

        return exists
347846
private void checkTaglet(Object taglet) {
        if (taglet instanceof Taglet) {
            checkTagName(((Taglet) taglet).getName());
        } else if (taglet instanceof com.sun.tools.doclets.Taglet) {
            com.sun.tools.doclets.Taglet legacyTaglet = (com.sun.tools.doclets.Taglet) taglet;
            customTags.remove(legacyTaglet.getName());
            customTags.put(legacyTaglet.getName(), new LegacyTaglet(legacyTaglet));
            checkTagName(legacyTaglet.getName());
        } else {
            throw new IllegalArgumentException("Given object is not a taglet.");
        }
    }
604634
def remove_container(config, container=None, force=True, v=False, *args, **kwargs):
    '''
    
    '''
    err = "Unknown"
    client = _get_client(config)
    dcontainer = None
    try:
        try:
            dcontainer = _get_container_infos(config, container)['Id']
        except Exception:
#            print "Container not existing."
            return True
        else:
            if not dcontainer:
                return True
            if is_running(config, dcontainer):
                if not force:
                    utils.error("Container running, won't remove it.")
                    return False
                else:
                    kill(config, dcontainer)
            client.remove_container(dcontainer, v=v)
            try:
                infos = _get_container_infos(config, dcontainer)
                if not infos:
                    return True
            except Exception:
#                print "Container has been successfully removed."
                return True
    except Exception as e:
        err = e
    utils.error("Unable to remove container: %s"%err)
    return False
1079863
async def _kill_it_with_fire(self, container_id):
        
        if container_id in self._watching:
            self._watching.remove(container_id)
            self._container_had_error.add(container_id)
            try:
                await self._docker_interface.kill_container(container_id)
            except:
                pass
34692
def assert_valid_input(cls, tag):
        """"""

        # Fail on unexpected types.
        if not cls.is_tag(tag):
            raise TypeError("Expected a BeautifulSoup 'Tag', but instead recieved type {}".format(type(tag)))
1180406
def terminate(self, container):
        
        self._client_chk.check(container)
        args = {
            'container': int(container),
        }
        response = self._client.raw('corex.terminate', args)

        result = response.get()
        if result.state != 'SUCCESS':
            raise RuntimeError('failed to terminate container: %s' % result.data)
193345
function parseEndTag(tag, tagName) {

      // If no tag name is provided, clean shop
      if (!tagName)
        var pos = 0;

      // Find the closest opened tag of the same type
      else {
        tagName = tagName.toLowerCase();
        for (var pos = stack.length - 1; pos >= 0; pos--)
          if (stack[pos] == tagName)
            break;
      }

      if (pos >= 0) {
        // Close all the open elements, up the stack
        for (var i = stack.length - 1; i >= pos; i--)
          results += "</" + stack[i] + ">";

        // Remove the open elements from the stack
        stack.length = pos;
      }

    }
647401
private boolean checkRequiredTag(IfdTags metadata, String tagName, int cardinality) {
    return checkRequiredTag(metadata, tagName, cardinality, null);
  }
903541
def handle_endtag(self, tagName):
        '''
            
        '''
        inTag = self._inTag
        if len(inTag) == 0:
            # Attempted to close, but no open tags
            raise InvalidCloseException(tagName, [])

        foundIt = False
        i = len(inTag) - 1
        while i >= 0:
            if inTag[i].tagName == tagName:
                foundIt = True
                break
            i -= 1

        if not foundIt:
            # Attempted to close, but did not match anything
            raise InvalidCloseException(tagName, inTag)

        if inTag[-1].tagName != tagName:
            raise MissedCloseException(tagName, [x for x in inTag[-1 * (i+1): ] ] )

        inTag.pop()
1327596
def delete_tag(tag)
      raise ArgumentError, "Expected String, got #{tag.class}." unless tag.is_a?(String)
      raise ArgumentError, "Expected a valid tag of format 'GGGG,EEEE', got #{tag}." unless tag.tag?
      @delete[tag] = true
    end
1006826
public void submitSafe(Object tag, Object subTag, Runnable runnable) {
        submitSafe(tag, subTag, false, runnable);
    }
1071067
def assert_exists(tag, element_id)
			if RWebSpec.framework == "Watir"
      	perform_assertion { assert(eval("#{tag}(:id, '#{element_id.to_s}').exists?"), "Element '#{tag}' with id: '#{element_id}' not found") }		
			else
				perform_assertion { assert( @web_browser.driver.find_element(:tag_name => tag, :id => element_id))}
			end
		
    end
1106184
def kill(name, signal):
    '''
    
    '''
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)
    cmd = ['lxc-kill', '--name=%s' % name, signal]
    subprocess.check_call(cmd)