return info about server as dict object
173637
def info(self):
        """"""
        proc_info = {"name": self.name,
                     "params": self.cfg,
                     "alive": self.is_alive,
                     "optfile": self.config_path}
        if self.is_alive:
            proc_info['pid'] = self.proc.pid
        logger.debug("proc_info: {proc_info}".format(**locals()))
        mongodb_uri = ''
        server_info = {}
        status_info = {}
        if self.hostname and self.cfg.get('port', None):
            try:
                c = self.connection
                server_info = c.server_info()
                logger.debug("server_info: {server_info}".format(**locals()))
                mongodb_uri = 'mongodb://' + self.hostname
                status_info = {"primary": c.is_primary, "mongos": c.is_mongos}
                logger.debug("status_info: {status_info}".format(**locals()))
            except (pymongo.errors.AutoReconnect, pymongo.errors.OperationFailure, pymongo.errors.ConnectionFailure):
                server_info = {}
                status_info = {}

        result = {"mongodb_uri": mongodb_uri, "statuses": status_info,
                  "serverInfo": server_info, "procInfo": proc_info,
                  "orchestration": 'servers'}
        if self.login:
            result['mongodb_auth_uri'] = self.mongodb_auth_uri(self.hostname)
        logger.debug("return {result}".format(result=result))
        return result
460174
def to_dict(self) -> Dict[str, str]:
        
        return {
            'type': 'remote',
            'name': self.name,
            'location': self.location,
            'url': self.url,
            'version': self.version
        }
282547
def AsDict(self, dt=True):
        
        data = {}

        if self.id:
            data['id'] = self.id
        if self.name:
            data['name'] = self.name
        if self.owner:
            data['owner'] = self.owner.AsDict()
        if self.url:
            data['url'] = self.url
        if self.thumbnail_url:
            data['thumbnail_url'] = self.thumbnail_url
        if self.description:
            data['description'] = self.description
        if self.type:
            data['type'] = self.type

        if dt:
            if self.created_at:
                data['created_at'] = self.created_at
            if self.updated_at:
                data['updated_at'] = self.updated_at
        else:
            if self.created_at:
                data['created_at'] = self.created_at_iso
            if self.updated_at:
                data['updated_at'] = self.updated_at_iso

        return data
753150
def server_info(self):
        
        retry = 0
        j = self._get_json('serverInfo')
        while not j and retry < 3:
            logging.warning("Bug https://jira.atlassian.com/browse/JRA-59676 trying again...")
            retry += 1
            j = self._get_json('serverInfo')
        return j
1289110
def get_info(self):
        '''  '''
        return {
            'Connected': self.is_connected(),
            'Port': self.port,
            'Bytes Waiting': self.ser.in_waiting if self.ser else 0
        }
1141047
def to_dict(self):
        
        return {
            'hostname': self.hostname,
            'port': self.port,
            'transport': self.transport,
            'virtual_host': self.virtual_host
        }
1364987
def parse_info(response):
    ''''''
    info = {}
    response = response.decode('utf-8')

    def get_value(value):
        if ',' and '=' not in value:
            return value
        sub_dict = {}
        for item in value.split(','):
            k, v = item.split('=')
            try:
                sub_dict[k] = int(v)
            except ValueError:
                sub_dict[k] = v
        return sub_dict
    data = info
    for line in response.splitlines():
        keyvalue = line.split(':')
        if len(keyvalue) == 2:
            key, value = keyvalue
            try:
                data[key] = int(value)
            except ValueError:
                data[key] = get_value(value)
        else:
            data = {}
            info[line[2:]] = data
    return info
728570
def to_dict(self):
        ''''''
        return dict(
            raw=self.raw,
            scheme=self.scheme,
            authority=self.authority,
            netloc=self.authority,
            path=self.path,
            query=self.query,
            fragment=self.fragment,
            userinfo=self.userinfo,
            username=self.username,
            password=self.password,
            host=self.host,
            hostname=self.hostname,
            port=self.port,
            resource=self.resource,
            url=self.url,
            encoding=self.encoding,
        )
1302621
def from_dict(cls, info_d):
        '''
        
        '''
        info = SessionInfo()
        for k, v in info_d.items():
            setattr(info, k, v)
        return info
1330547
def get_my_info():
    
    result = {}
    result['host_name'] = platform.node()
    result['real_host_name'] = platform.node()
    result['dist'] = platform.dist()
    result['nago_version'] = nago.get_version()
    return result
606264
def s_info(self, server=None):
        
        with self.lock:
            if not server:
                self.send('INFO')
            else:
                self.send('INFO %s' % server)
            sinfo = []
            while self.readable():
                msg = self._recv(expected_replies=('371', '374'))
                if msg[0] == '371':
                    sinfo.append(' '.join(msg[2:])[1:])
                elif msg[0] == '374':
                    break

            return sinfo
928934
def as_json(self):
        
        info = {
            'host': self.host,
            'port': self.port,
            'geo': {
                'country': {'code': self._geo.code, 'name': self._geo.name},
                'region': {
                    'code': self._geo.region_code,
                    'name': self._geo.region_name,
                },
                'city': self._geo.city_name,
            },
            'types': [],
            'avg_resp_time': self.avg_resp_time,
            'error_rate': self.error_rate,
        }

        order = lambda tp_lvl: (len(tp_lvl[0]), tp_lvl[0][-1])  # noqa: 731
        for tp, lvl in sorted(self.types.items(), key=order):
            info['types'].append({'type': tp, 'level': lvl or ''})
        return info
347017
def url_info(request):
    

    return {
        'MEDIA_URL' : core_settings.MEDIA_URL,
        'STATIC_URL': core_settings.STATIC_URL,
        'VERSION' : core_settings.VERSION,
        'SERVER_INFO' : core_settings.SERVER_INFO,
        'SITE_NAME' : current_site_name,
        'CURRENT_SITE': current_site,
    }
294513
def get_server_info(self):
        
        # NB: can't do it this way due to recursion
        # codec = self._get_codec(ttb_supported=False)
        codec = PbufCodec()
        msg = Msg(riak.pb.messages.MSG_CODE_GET_SERVER_INFO_REQ, None,
                  riak.pb.messages.MSG_CODE_GET_SERVER_INFO_RESP)
        resp_code, resp = self._request(msg, codec)
        return codec.decode_get_server_info(resp)
475686
def _get_info(info, name):
    
    try:
        idx = info[name]
    except KeyError:
        idx = info[name] = dict()
    return idx
927896
def to_dict(self):
        """"""
        return {"address": self.address,
                "port": self.port,
                "condition": self.condition,
                "type": self.type,
                "id": self.id,
                }
1316489
def get_host_info_dict_from_describe_dict(self, describe_dict):
        '''  '''

        # I really don't agree with prefixing everything with 'ec2'
        # because EC2, RDS and ElastiCache are different services.
        # I'm just following the pattern used until now to not break any
        # compatibility.

        host_info = {}
        for key in describe_dict:
            value = describe_dict[key]
            key = self.to_safe('ec2_' + self.uncammelize(key))

            # Handle complex types

            # Target: Memcached Cache Clusters
            if key == 'ec2_configuration_endpoint' and value:
                host_info['ec2_configuration_endpoint_address'] = value['Address']
                host_info['ec2_configuration_endpoint_port'] = value['Port']

            # Target: Cache Nodes and Redis Cache Clusters (single node)
            if key == 'ec2_endpoint' and value:
                host_info['ec2_endpoint_address'] = value['Address']
                host_info['ec2_endpoint_port'] = value['Port']

            # Target: Redis Replication Groups
            if key == 'ec2_node_groups' and value:
                host_info['ec2_endpoint_address'] = value[0]['PrimaryEndpoint']['Address']
                host_info['ec2_endpoint_port'] = value[0]['PrimaryEndpoint']['Port']
                replica_count = 0
                for node in value[0]['NodeGroupMembers']:
                    if node['CurrentRole'] == 'primary':
                        host_info['ec2_primary_cluster_address'] = node['ReadEndpoint']['Address']
                        host_info['ec2_primary_cluster_port'] = node['ReadEndpoint']['Port']
                        host_info['ec2_primary_cluster_id'] = node['CacheClusterId']
                    elif node['CurrentRole'] == 'replica':
                        host_info['ec2_replica_cluster_address_'+ str(replica_count)] = node['ReadEndpoint']['Address']
                        host_info['ec2_replica_cluster_port_'+ str(replica_count)] = node['ReadEndpoint']['Port']
                        host_info['ec2_replica_cluster_id_'+ str(replica_count)] = node['CacheClusterId']
                        replica_count += 1

            # Target: Redis Replication Groups
            if key == 'ec2_member_clusters' and value:
                host_info['ec2_member_clusters'] = ','.join([str(i) for i in value])

            # Target: All Cache Clusters
            elif key == 'ec2_cache_parameter_group':
                host_info["ec2_cache_node_ids_to_reboot"] = ','.join([str(i) for i in value['CacheNodeIdsToReboot']])
                host_info['ec2_cache_parameter_group_name'] = value['CacheParameterGroupName']
                host_info['ec2_cache_parameter_apply_status'] = value['ParameterApplyStatus']

            # Target: Almost everything
            elif key == 'ec2_security_groups':

                # Skip if SecurityGroups is None
                # (it is possible to have the key defined but no value in it).
                if value is not None:
                    sg_ids = []
                    for sg in value:
                        sg_ids.append(sg['SecurityGroupId'])
                    host_info["ec2_security_group_ids"] = ','.join([str(i) for i in sg_ids])

            # Target: Everything
            # Preserve booleans and integers
            elif type(value) in [int, bool]:
                host_info[key] = value

            # Target: Everything
            # Sanitize string values
            elif isinstance(value, six.string_types):
                host_info[key] = value.strip()

            # Target: Everything
            # Replace None by an empty string
            elif type(value) == type(None):
                host_info[key] = ''

            else:
                # Remove non-processed complex types
                pass

        return host_info