Get device name by its SNMP sysObjectID property from the file map

    :param str file_name:
    :param str sys_obj_id:
    :param str delimiter:
    :rtype: str
499324
def get_device_name(file_name, sys_obj_id, delimiter=":"):
    

    try:
        with open(file_name, "rb") as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=delimiter)
            for row in csv_reader:
                if len(row) >= 2 and row[0] == sys_obj_id:
                    return row[1]
    except IOError:
        pass  # file does not exists

    return sys_obj_id
787684
def name(self, id):
        
        data = self.bytes(id, 'N')
        if not data:
            print("%x has no name" % id)
            return
        if data[:1] == b'\x00':
            nameid, = struct.unpack_from(">" + self.fmt, data, 1)
            nameblob = self.blob(self.nodebase, 'S', nameid * 256, nameid * 256 + 32)
            return nameblob.rstrip(b"\x00").decode('utf-8')
        return data.rstrip(b"\x00").decode('utf-8')
194612
def from_sysdisk(cls, label):
        """"""
        disks = cls.safe_call('hosting.disk.list', {'name': label})
        if len(disks):
            return disks[0]['id']
1343956
def file_id_to_name(self, file_id):
        """"""
        sql = 'select name from files where id = ?'
        logging.debug('%s %s', sql, (file_id,))
        self.cursor.execute(sql, (file_id,))
        name = self.cursor.fetchone()
        if name:
            return name[0]
        return ''
753752
def get_file_info(codeobj):
        
        fname = getattr(codeobj, '__file__', None)
        linenum = 0
        if fname is None:
            func_code = codeobj.__code__
            fname = func_code.co_filename
            linenum = func_code.co_firstlineno
        fname = fname.replace('.pyc', '.py')
        return fname, linenum
1270351
def get_remote_sys_name(self, tlv_data):
        
        ret, parsed_val = self._check_common_tlv_format(
            tlv_data, "\n", "System Name TLV")
        if not ret:
            return None
        return parsed_val[1].strip()
788786
def get_display_name(self, short=False):
        
        if self.location is None:
            return '[New file]'
        elif short:
            return os.path.basename(self.location)
        else:
            return self.location
839656
def get_device_for_network_linux(self, network_name):
        
        log = logging.getLogger(self.cls_logger + '.get_device_for_network_linux')

        if get_os() not in ['Linux']:
            log.warn('Non-linux OS detected, returning...')
            return

        # Get the IP address for the network name according to cons3rt
        ip_address = self.get_ip_on_network(network_name=network_name)
        if not ip_address:
            log.warn('IP address not found for network with name: {n}'.format(n=network_name))
            return

        # Get the system device names and ip addresses
        sys_info = ip_addr()

        # Check for a matching IP address
        device_name = None
        for device_name, sys_ip_address in sys_info.iteritems():
            if sys_ip_address == ip_address:
                log.debug('Found matching system IP [{i}] for device: {d}'.format(i=ip_address, d=device_name))

        if not device_name:
            log.warn('Network device not found with IP address {i} in system network data: {d}'.format(
                i=ip_address, d=str(sys_info)))
            return
        log.debug('Found device name [{d}] with IP address [{i}] for network: {n}'.format(
            d=device_name, i=ip_address, n=network_name))
        return device_name
999827
def _getFilename(self, fileNumber):
        
        cur = self._connection.cursor()
        cur.execute('SELECT name FROM files WHERE id = ?', (fileNumber,))
        row = cur.fetchone()
        if row is None:
            return None
        else:
            return row[0]
1090578
def port_id_from_name(port_name, device_id, nodes):
        
        port_id = None
        for node in nodes:
            if device_id == node['id']:
                for port in node['ports']:
                    if port_name == port['name']:
                        port_id = port['id']
                        break
                break
        return port_id
132706
def _get_id(self, file_path):
        
        '''  '''
        
        title = '%s._get_id' % self.__class__.__name__
        
    # construct request kwargs
        list_kwargs = {
            'spaces': self.drive_space,
            'fields': 'files(id, parents)'
        }
    
    # determine path segments
        path_segments = file_path.split(os.sep)
        
    # walk down parents to file name
        parent_id = ''
        empty_string = ''
        while path_segments:
            walk_query = "name = '%s'" % path_segments.pop(0)
            if parent_id:
                walk_query += "and '%s' in parents" % parent_id
            list_kwargs['q'] = walk_query
            try:
                response = self.drive.list(**list_kwargs).execute()
            except:
                raise DriveConnectionError(title)
            file_list = response.get('files', [])
            if file_list:
                if path_segments:
                    parent_id = file_list[0].get('id')
                else:
                    file_id = file_list[0].get('id')
                    return file_id, parent_id
            else:
                return empty_string, empty_string
1000162
private String getIdFromFilename(String filename) {
        if (!StringUtils.hasText(filename) || filename.indexOf('_') < 0) {
            return null;
        }
        return filename.substring(0, filename.lastIndexOf('_'));
    }
172626
def interface_by_name(self, name):
        '''
        
        '''
        if name in self._devinfo:
            return self._devinfo[name]
        raise KeyError("No device named {}".format(name))
862442
def get_rtr_name(self, router_id):
        
        try:
            body = {}
            router = self.neutronclient.show_router(router_id, body=body)
            return router.get('router').get('name')
        except Exception as exc:
            LOG.error("Failed to show router interface %(id)s "
                      "Exc %(exc)s", {'id': router_id, 'exc': str(exc)})
1185542
def device_id_from_name(device_name, nodes):
        
        device_id = None
        for node in nodes:
            if device_name == node['properties']['name']:
                device_id = node['id']
                break
        return device_id
1220719
def fileobj_name(fileobj):
    

    value = getattr(fileobj, "name", u"")
    if not isinstance(value, (text_type, bytes)):
        value = text_type(value)
    return value
991805
def get_device_name(self):
        
        command = const.CMD_OPTIONS_RRQ
        command_string = b'~DeviceName\x00'
        response_size = 1024

        cmd_response = self.__send_command(command, command_string, response_size)
        if cmd_response.get('status'):
            device = self.__data.split(b'=', 1)[-1].split(b'\x00')[0]
            return device.decode()
        else:
            return ""