def get_tx_power(self, tx_power):
        """Validates tx_power against self.tx_power_table

        @param tx_power: index into the self.tx_power_table list; if tx_power
            is 0 then the max power from self.tx_power_table
        @return: a dict {antenna: (tx_power_index, power_dbm)} from
            self.tx_power_table
        @raise: LLRPError if the requested index is out of range
        """
        if not self.tx_power_table:
            logger.warn('get_tx_power(): tx_power_table is empty!')
            return {}

        logger.debug('requested tx_power: %s', tx_power)
        min_power = self.tx_power_table.index(min(self.tx_power_table))
        max_power = self.tx_power_table.index(max(self.tx_power_table))

        ret = {}
        for antid, tx_power in tx_power.items():
            if tx_power == 0:
                # tx_power = 0 means max power
                max_power_dbm = max(self.tx_power_table)
                tx_power = self.tx_power_table.index(max_power_dbm)
                ret[antid] = (tx_power, max_power_dbm)

            try:
                power_dbm = self.tx_power_table[tx_power]
                ret[antid] = (tx_power, power_dbm)
            except IndexError:
                raise LLRPError('Invalid tx_power for antenna {}: '
                                'requested={}, min_available={}, '
                                'max_available={}'.format(
                                    antid, self.tx_power, min_power,
                                    max_power))
        return ret
def get_tx_power ( self , tx_power ) : if not self . tx_power_table : logger . warn ( 'get_tx_power(): tx_power_table is empty!' ) return { } logger . debug ( 'requested tx_power: %s' , tx_power ) min_power = self . tx_power_table . index ( min ( self . tx_power_table ) ) max_power = self . tx_power_table . index ( max ( self . tx_power_table ) ) ret = { } for antid , tx_power in tx_power . items ( ) : if tx_power == 0 : max_power_dbm = max ( self . tx_power_table ) tx_power = self . tx_power_table . index ( max_power_dbm ) ret [ antid ] = ( tx_power , max_power_dbm ) try : power_dbm = self . tx_power_table [ tx_power ] ret [ antid ] = ( tx_power , power_dbm ) except IndexError : raise LLRPError ( 'Invalid tx_power for antenna {}: ' 'requested={}, min_available={}, ' 'max_available={}' . format ( antid , self . tx_power , min_power , max_power ) ) return ret
Validates tx_power against self.tx_power_table

        @param tx_power: index into the self.tx_power_table list; if tx_power
            is 0 then the max power from self.tx_power_table
        @return: a dict {antenna: (tx_power_index, power_dbm)} from
            self.tx_power_table
        @raise: LLRPError if the requested index is out of range