'Update Docker stats using the input method.'

@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):

    global docker_tag
    self.reset()
    if (not self.docker_client):
        try:
            self.docker_client = self.connect()
        except Exception:
            docker_tag = False
        else:
            if (self.docker_client is None):
                docker_tag = False
    if (not docker_tag):
        return self.stats
    if (self.input_method == 'local'):
        try:
            self.stats['version'] = self.docker_client.version()
        except Exception as e:
            logger.error('{}    plugin    -    Cannot    get    Docker    version    ({})'.format(self.plugin_name, e))
            return self.stats
        try:
            self.stats['containers'] = (self.docker_client.containers() or [])
        except Exception as e:
            logger.error('{}    plugin    -    Cannot    get    containers    list    ({})'.format(self.plugin_name, e))
            return self.stats
        for container in self.stats['containers']:
            if (container['Id'] not in self.thread_list):
                logger.debug('{}    plugin    -    Create    thread    for    container    {}'.format(self.plugin_name, container['Id'][:12]))
                t = ThreadDockerGrabber(self.docker_client, container['Id'])
                self.thread_list[container['Id']] = t
                t.start()
        nonexisting_containers = (set(iterkeys(self.thread_list)) - set([c['Id'] for c in self.stats['containers']]))
        for container_id in nonexisting_containers:
            logger.debug('{}    plugin    -    Stop    thread    for    old    container    {}'.format(self.plugin_name, container_id[:12]))
            self.thread_list[container_id].stop()
            del self.thread_list[container_id]
        for container in self.stats['containers']:
            container['key'] = self.get_key()
            container['name'] = container['Names'][0][1:]
            container['cpu'] = self.get_docker_cpu(container['Id'], self.thread_list[container['Id']].stats)
            container['memory'] = self.get_docker_memory(container['Id'], self.thread_list[container['Id']].stats)
            container['network'] = self.get_docker_network(container['Id'], self.thread_list[container['Id']].stats)
            container['io'] = self.get_docker_io(container['Id'], self.thread_list[container['Id']].stats)
    elif (self.input_method == 'snmp'):
        pass
    return self.stats
