Return alias for device name if found.

        :param argin: The device name
        :type: tango.DevString
        :return: The alias found
        :rtype: tango.DevString
502756
def DbGetDeviceAlias(self, argin):
        
        self._log.debug("In DbGetDeviceAlias()")
        ret, dev_name, dfm = check_device_name(argin)
        if not ret:
            th_exc(DB_IncorrectDeviceName,
                  "device name (" + argin + ") syntax error (should be [tango:][//instance/]domain/family/member)",
                  "DataBase::DbGetDeviceAlias()")

        return self.db.get_device_alias(dev_name)
181684
def add_device(dev):
    """"""
    global DEV_IDX, DEFAULT_DEV
    with DEV_LOCK:
        for idx in range(len(DEVS)):
            test_dev = DEVS[idx]
            if test_dev.dev_name_short == dev.dev_name_short:
                # This device is already in our list. Delete the old one
                if test_dev is DEFAULT_DEV:
                    DEFAULT_DEV = None
                del DEVS[idx]
                break
        if find_device_by_name(dev.name):
            # This name is taken - make it unique
            dev.name += '-%d' % DEV_IDX
        dev.name_path = '/' + dev.name + '/'
        DEVS.append(dev)
        DEV_IDX += 1
        if DEFAULT_DEV is None:
            DEFAULT_DEV = dev
511019
def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-statements
        """"""
        # There are some times we want to trick the platform detection
        # say if a raspberry pi doesn't have the right ID, or for testing
        try:
            return os.environ['BLINKA_FORCECHIP']
        except KeyError: # no forced chip, continue with testing!
            pass

        # Special case, if we have an environment var set, we could use FT232H
        try:
            if os.environ['BLINKA_FT232H']:
                # we can't have ftdi1 as a dependency cause its wierd
                # to install, sigh.
                import ftdi1 as ftdi # pylint: disable=import-error
                try:
                    ctx = None
                    ctx = ftdi.new()  # Create a libftdi context.
                    # Enumerate FTDI devices.
                    count, _ = ftdi.usb_find_all(ctx, 0, 0)
                    if count < 0:
                        raise RuntimeError('ftdi_usb_find_all returned error %d : %s' %
                                           count, ftdi.get_error_string(self._ctx))
                    if count == 0:
                        raise RuntimeError('BLINKA_FT232H environment variable' + \
                                           'set, but no FT232H device found')
                finally:
                    # Make sure to clean up list and context when done.
                    if ctx is not None:
                        ftdi.free(ctx)
            return FT232H
        except KeyError: # no FT232H environment var
            pass

        platform = sys.platform
        if platform == "linux" or platform == "linux2":
            return self._linux_id()
        if platform == "esp8266":
            return ESP8266
        if platform == "samd21":
            return SAMD21
        if platform == "pyboard":
            return STM32
        # nothing found!
        return None
1227123
def get_device_by_name(self, device_name):
        

        # Find the device for the vera device name we are interested in
        found_device = None
        for device in self.get_devices():
            if device.name == device_name:
              found_device = device
              # found the first (and should be only) one so we will finish
              break

        if found_device is None:
            logger.debug('Did not find device with {}'.format(device_name))

        return found_device
1357105
def search_for_devices_by_serial_number(self, sn):
        
        import re

        sn_search = re.compile(sn)

        matches = []
        for dev_o in self.get_all_devices_in_portal():
            # print("Checking {0}".format(dev_o['sn']))
            try:
                if sn_search.match(dev_o['sn']):

                    matches.append(dev_o)
            except TypeError as err:
                print("Problem checking device {!r}: {!r}".format(
                                    dev_o['info']['description']['name'],
                                    str(err)))
        return matches
1334090
def DbUnExportDevice(self, argin):
        
        self._log.debug("In DbUnExportDevice()")
        dev_name = argin[0].lower()
        self.db.unexport_device(dev_name)
172626
def interface_by_name(self, name):
        '''
        
        '''
        if name in self._devinfo:
            return self._devinfo[name]
        raise KeyError("No device named {}".format(name))
65784
def getDisplayName(self):
        """"""
        if self.alias == "":
            return self.name
        return self.name + " as " + self.alias
910536
public static String getfullNameForDevice(final String deviceName) throws DevFailed {
        checkNullOrEmptyString(deviceName);
        final String[] fields = deviceName.split(DEVICE_SEPARATOR);

        if (deviceName.contains(DBASE_NO) || fields.length != 1) {
            return deviceName;
        } else {
            final Database db = ApiUtil.get_db_obj();
            return db.get_device_from_alias(fields[0]);
        }
    }
783763
def aliased_slot_name(self, slot: SLOT_OR_SLOTNAME) -> str:
        
        if isinstance(slot, str):
            slot = self.schema.slots[slot]
        return slot.alias if slot.alias else slot.name
1356790
def find_device(device=None):
    '''
    
    '''

    data = [{'uid': '/zport/dmd/Devices', 'params': {}, 'limit': None}]
    all_devices = _router_request('DeviceRouter', 'getDevices', data=data)
    for dev in all_devices['devices']:
        if dev['name'] == device:
            # We need to save the has for later operations
            dev['hash'] = all_devices['hash']
            log.info('Found device %s in Zenoss', device)
            return dev

    log.info('Unable to find device %s in Zenoss', device)
    return None
1150769
def register_element(self, dev_name, idx=None):
        
        if dev_name not in self.devices:
            logger.error(
                'Device {} missing. call add_device before adding elements'.
                format(dev_name))
            return
        group_name = self.system.__dict__[dev_name]._group
        if idx is None:  # "if not idx" will fail for idx==0.0
            idx = dev_name + '_' + str(len(self.group[group_name].keys()))
        self.group[group_name][idx] = dev_name
        return idx
1373013
def get_device_host(target)
      info = Socket.getaddrinfo(target, nil, Socket::AF_INET)
      info[0][2]
    rescue SocketError
      target
    end
488436
def detectNintendo(self):
        
        return UAgentInfo.deviceNintendo in self.__userAgent \
            or UAgentInfo.deviceNintendo in self.__userAgent \
            or UAgentInfo.deviceNintendo in self.__userAgent
1310376
def get_by_name(self, name): # pylint: disable=invalid-name,redefined-builtin
        
        rs, _ = self.list(filter=field('name').eq(name), limit=1)
        if len(rs) is 0:
            raise CDRouterError('no such device')
        return rs[0]
1305228
def alias(self):
        
        if self._alias is None:
            if self.name in self.aliases_fix:
                self._alias = self.aliases_fix[self.name]
            else:
                self._alias = self.name.lower()\
                                  .replace(' ', '-')\
                                  .replace('(', '')\
                                  .replace(')', '')
        return self._alias
335593
def get_device_names(self):
        """"""
        dev_names = {}
        for device in self.get_device_ids():
            dev_names[device] = self.get_device_name(device)
        return dev_names