当前位置: 首页>>代码示例>>Python>>正文


Python scan.Cell类代码示例

本文整理汇总了Python中wifi.scan.Cell的典型用法代码示例。如果您正苦于以下问题:Python Cell类的具体用法?Python Cell怎么用?Python Cell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: normalize

def normalize(cell_block):
    # The cell blocks come in with every line except the first indented at
    # least 20 spaces.  This removes the first 20 spaces off of those lines.
    lines = textwrap.dedent(' ' * 20 + cell_block).splitlines()
    cell = Cell()

    while lines:
        line = lines.pop(0)

        if line.startswith('Quality'):
            for re_name, quality_re in quality_re_dict.items():
                match_result = quality_re.search(line)
                if match_result is not None:
                    cell.quality, signal = match_result.groups()
                    if re_name == 'relative':
                        actual, total = map(int, signal.split('/'))
                        cell.signal = db2dbm(int((actual / total) * 100))
                    else:
                        cell.signal = int(signal)
                    break

        elif line.startswith('Bit Rates'):
            values = split_on_colon(line)[1].split('; ')

            # consume next line of bit rates, because they are split on
            # different lines, sometimes...
            while lines[0].startswith(' ' * 10):
                values += lines.pop(0).strip().split('; ')

            cell.bitrates.extend(values)
        elif ':' in line:
            key, value = split_on_colon(line)
            key = normalize_key(key)

            if key == 'ie':
                if 'Unknown' in value:
                    continue

                # consume remaining block
                values = [value]
                while lines and lines[0].startswith(' ' * 4):
                    values.append(lines.pop(0).strip())

                if 'WPA2' in value:
                    cell.encryption_type = 'wpa2'
                elif 'WPA' in value:
                    cell.encryption_type = 'wpa'
            if key == 'frequency':
                frequency, channel = frequency_re.search(value).groups()
                cell.frequency = frequency
                cell.channel = int(channel)
            elif key in normalize_value:
                setattr(cell, key, normalize_value[key](value))

    # It seems that encryption types other than WEP need to specify their
    # existence.
    if cell.encrypted and not hasattr(cell, 'encryption_type'):
        cell.encryption_type = 'wep'

    return cell
开发者ID:Mondego,项目名称:pyreco,代码行数:60,代码来源:allPythonContent.py

示例2: test_unencrypted

    def test_unencrypted(self):
        cell = Cell()
        cell.ssid = 'SSID'
        cell.encrypted = False

        scheme = Scheme.for_cell('wlan0', 'test', cell)

        self.assertEqual(scheme.options, {
            'wireless-essid': 'SSID',
            'wireless-channel': 'auto',
        })
开发者ID:Mondego,项目名称:pyreco,代码行数:11,代码来源:allPythonContent.py

示例3: test_wep

    def test_wep(self):
        cell = Cell()
        cell.ssid = 'SSID'
        cell.encrypted = True
        cell.encryption_type = 'wep'

        scheme = Scheme.for_cell('wlan0', 'test', cell, 'passkey')

        self.assertEqual(scheme.options, {
            'wireless-essid': 'SSID',
            'wireless-key': 'passkey',
        })
开发者ID:Mondego,项目名称:pyreco,代码行数:12,代码来源:allPythonContent.py

示例4: test_wpa

    def test_wpa(self):
        cell = Cell()
        cell.ssid = 'SSID'
        cell.encrypted = True
        cell.encryption_type = 'wpa'

        scheme = Scheme.for_cell('wlan0', 'test', cell, 'passkey')

        self.assertEqual(scheme.options, {
            'wpa-ssid': 'SSID',
            'wpa-psk': 'ea1548d4e8850c8d94c5ef9ed6fe483981b64c1436952cb1bf80c08a68cdc763',
            'wireless-channel': 'auto',
        })
开发者ID:Mondego,项目名称:pyreco,代码行数:13,代码来源:allPythonContent.py

示例5: update

    def update(self):
        """Update Wifi stats using the input method.

        Stats is a list of dict (one dict per hotspot)

        :returns: list -- Stats is a list of dict (hotspot)
        """
        # Reset stats
        self.reset()

        # Exist if we can not grab the stats
        if not wifi_tag:
            return self.stats

        if self.input_method == 'local':
            # Update stats using the standard system lib

            # Grab network interface stat using the PsUtil net_io_counter method
            try:
                netiocounters = psutil.net_io_counters(pernic=True)
            except UnicodeDecodeError:
                return self.stats

            for net in netiocounters:
                # Do not take hidden interface into account
                if self.is_hide(net):
                    continue

                # Grab the stats using the Wifi Python lib
                try:
                    wifi_cells = Cell.all(net)
                except InterfaceError:
                    # Not a Wifi interface
                    pass
                except Exception as e:
                    # Other error
                    logger.debug("WIFI plugin: Can not grab cellule stats ({})".format(e))
                    pass
                else:
                    for wifi_cell in wifi_cells:
                        hotspot = {
                            'key': self.get_key(),
                            'ssid': wifi_cell.ssid,
                            'signal': wifi_cell.signal,
                            'quality': wifi_cell.quality,
                            'encrypted': wifi_cell.encrypted,
                            'encryption_type': wifi_cell.encryption_type if wifi_cell.encrypted else None
                        }
                        # Add the hotspot to the list
                        self.stats.append(hotspot)

        elif self.input_method == 'snmp':
            # Update stats using SNMP

            # Not implemented yet
            pass

        return self.stats
开发者ID:NightyLive,项目名称:glances,代码行数:58,代码来源:glances_wifi.py

示例6: test_no_encryption

 def test_no_encryption(self):
     cell = Cell.from_string(IWLIST_SCAN_NO_ENCRYPTION)
     self.assertFalse(cell.encrypted)
     self.assertEqual(cell.ssid, 'My Wireless Network')
     self.assertEqual(cell.signal, -51)
     self.assertEqual(cell.quality, '59/70')
     self.assertEqual(cell.frequency, '2.437 GHz')
     self.assertEqual(cell.mode, 'Master')
     self.assertEqual(cell.channel, 6)
开发者ID:DanLipsitt,项目名称:wifi,代码行数:9,代码来源:test_parsing.py

示例7: test_wpa2

 def test_wpa2(self):
     cell = Cell.from_string(IWLIST_SCAN_WPA2)
     self.assertTrue(cell.encrypted)
     self.assertEqual(cell.encryption_type, 'wpa2')
开发者ID:DanLipsitt,项目名称:wifi,代码行数:4,代码来源:test_parsing.py

示例8: test_alternative_iwlist_output

 def test_alternative_iwlist_output(self):
     # https://github.com/rockymeza/wifi/issues/12
     cell = Cell.from_string(ALTERNATIVE_OUTPUT)
     self.assertEqual(cell.quality, '78/100')
     self.assertEqual(cell.signal, -92)
开发者ID:Develoman,项目名称:wifi,代码行数:5,代码来源:test_parsing.py

示例9: test_absolute_quality

 def test_absolute_quality(self):
     # https://github.com/rockymeza/wifi/pull/45
     cell = Cell.from_string(ABSOLUTE_QUALITY)
     self.assertEqual(cell.quality, '38/100')
     self.assertEqual(cell.signal, -92)
开发者ID:Develoman,项目名称:wifi,代码行数:5,代码来源:test_parsing.py

示例10: test_wep

 def test_wep(self):
     cell = Cell.from_string(IWLIST_SCAN_WEP)
     self.assertTrue(cell.encrypted)
     self.assertEqual(cell.encryption_type, 'wep')
开发者ID:DanLipsitt,项目名称:wifi,代码行数:4,代码来源:test_parsing.py

示例11: test_list_index_error

 def test_list_index_error(self):
     # https://github.com/rockymeza/wifi/issues/42
     cell = Cell.from_string(LIST_INDEX_ERROR)
开发者ID:Develoman,项目名称:wifi,代码行数:3,代码来源:test_parsing.py

示例12: test_frequency_no_channel_output

 def test_frequency_no_channel_output(self):
     # https://github.com/rockymeza/wifi/issues/39
     cell = Cell.from_string(FREQUENCY_NO_CHANNEL_OUTPUT)
     self.assertEqual(cell.channel, 149)
开发者ID:Develoman,项目名称:wifi,代码行数:4,代码来源:test_parsing.py

示例13: test_noname_cell

 def test_noname_cell(self):
     cell = Cell.from_string(NONAME_WIRELESS_NETWORK)
     self.assertEqual(cell.ssid, '')
开发者ID:Develoman,项目名称:wifi,代码行数:3,代码来源:test_parsing.py

示例14: test_no_channel_output

 def test_no_channel_output(self):
     # https://github.com/rockymeza/wifi/issues/24
     cell = Cell.from_string(NO_CHANNEL_OUTPUT)
     self.assertEqual(cell.channel, 11)
开发者ID:Develoman,项目名称:wifi,代码行数:4,代码来源:test_parsing.py

示例15: test_signal_level_out_of_sixty

 def test_signal_level_out_of_sixty(self):
     cell = Cell.from_string(ALTERNATIVE_OUTPUT2)
     self.assertEqual(cell.signal, -71)
开发者ID:Develoman,项目名称:wifi,代码行数:3,代码来源:test_parsing.py


注:本文中的wifi.scan.Cell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。