'Update stats for the given server (picked from the server list)'

def __update_stats(self, server):

    uri = self.__get_uri(server)
    t = GlancesClientTransport()
    t.set_timeout(3)
    try:
        s = ServerProxy(uri, transport=t)
    except Exception as e:
        logger.warning("Client    browser    couldn't    create    socket    {}:    {}".format(uri, e))
    else:
        try:
            cpu_percent = (100 - json.loads(s.getCpu())['idle'])
            server['cpu_percent'] = '{:.1f}'.format(cpu_percent)
            server['mem_percent'] = json.loads(s.getMem())['percent']
            server['hr_name'] = json.loads(s.getSystem())['hr_name']
        except (socket.error, Fault, KeyError) as e:
            logger.debug('Error    while    grabbing    stats    form    {}:    {}'.format(uri, e))
            server['status'] = 'OFFLINE'
        except ProtocolError as e:
            if (e.errcode == 401):
                server['password'] = None
                server['status'] = 'PROTECTED'
            else:
                server['status'] = 'OFFLINE'
            logger.debug('Cannot    grab    stats    from    {}    ({}    {})'.format(uri, e.errcode, e.errmsg))
        else:
            server['status'] = 'ONLINE'
            try:
                load_min5 = json.loads(s.getLoad())['min5']
                server['load_min5'] = '{:.2f}'.format(load_min5)
            except Exception as e:
                logger.warning('Error    while    grabbing    stats    form    {}:    {}'.format(uri, e))
    return server
