コード例 #1
0
ファイル: query.py プロジェクト: SOFTowaha/ichnaea
    def wifi(self, values):
        if not values:
            values = []
        values = list(values)
        self._wifi_unvalidated = values

        filtered = []
        for value in values:
            valid = WifiLookup.validate(value)
            if valid:
                filtered.append(valid)
        if len(filtered) < MIN_WIFIS_IN_QUERY:
            filtered = []
        self._wifi = filtered
コード例 #2
0
    def _prepare_wifi(self, wifi):
        validated_wifi = WifiLookup.validate(wifi)
        if validated_wifi is None:
            return None

        result = {}
        wifi_map = {
            'key': 'macAddress',
            'channel': 'channel',
            'signal': 'signalStrength',
            'snr': 'signalToNoiseRatio',
        }
        for source, target in wifi_map.items():
            if validated_wifi.get(source):
                result[target] = validated_wifi[source]

        return result
コード例 #3
0
    def _get_clean_wifi_keys(self, data):
        wifis = []

        # Pre-process wifi data
        for wifi in data.get('wifi', ()):
            wifi = WifiLookup.validate(wifi)
            if wifi:
                wifis.append(wifi)

        # Estimate signal strength at -100 dBm if none is provided,
        # which is worse than the 99th percentile of wifi dBms we
        # see in practice (-98).

        wifi_signals = dict([(w['key'], w['signal'] or -100) for w in wifis])
        wifi_keys = set(wifi_signals.keys())

        return (wifis, wifi_signals, wifi_keys)
コード例 #4
0
ファイル: query.py プロジェクト: amjadm61/ichnaea
    def wifi(self, values):
        if not values:
            values = []
        values = list(values)
        self._wifi_unvalidated = values

        filtered = OrderedDict()
        for value in values:
            valid_wifi = WifiLookup.create(**value)
            if valid_wifi:
                existing = filtered.get(valid_wifi.macAddress)
                if existing is not None and existing.better(valid_wifi):
                    pass
                else:
                    filtered[valid_wifi.macAddress] = valid_wifi

        if len(filtered) < MIN_WIFIS_IN_QUERY:
            filtered = {}
        self._wifi = list(filtered.values())
コード例 #5
0
ファイル: query.py プロジェクト: uvinduperera/ichnaea
    def wifi(self, values):
        if not values:
            values = []
        values = list(values)
        self._wifi_unvalidated = values

        filtered = OrderedDict()
        for value in values:
            valid_wifi = WifiLookup.create(**value)
            if valid_wifi:
                existing = filtered.get(valid_wifi.macAddress)
                if existing is not None and existing.better(valid_wifi):
                    pass
                else:
                    filtered[valid_wifi.macAddress] = valid_wifi

        if len(filtered) < MIN_WIFIS_IN_QUERY:
            filtered = {}
        self._wifi = list(filtered.values())