import logging
import platform

import pywifi

pywifi.set_loglevel(logging.INFO)

def go_interfaces():

    wifi = pywifi.PyWiFi() #创建wifi对象

    assert wifi.interfaces() #抓取网卡接口

    if platform.system().lower() == 'windows': #判断平台
        print(wifi.interfaces()[0].name())
        assert wifi.interfaces()[0].name() ==\
            'Intel(R) Dual Band Wireless-AC 3160'

go_interfaces()
Exemple #2
0
import pytest
import sys
import time
import platform
import logging

# For mocking
import os
import stat
import socket

import pywifi
from pywifi import const

pywifi.set_loglevel(logging.INFO)


class SockMock:

    default_scan_results =\
        "bssid / frequency / signal level / flags / ssid\n"\
        "14:4d:67:14:1e:44\t2412\t-67\t[WPA2-PSK-CCMP][WPS][ESS]\tTOTOLINK N302RE\n"\
        "ac:9e:17:31:85:fc\t2437\t-63\t[WPA2-PSK-CCMP][WPS][ESS]\tEvan\n"\
        "0c:80:63:2b:0d:a8\t2417\t-79\t[WPA2-PSK-CCMP][WPS][ESS]\tKevin_H2\n"\
        "78:32:1b:63:96:05\t2422\t-91\t[WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]\tjoyfulness\n"

    def __init__(self):
        self._last_cmd = None
        self._last_state = None
        self._network_profiles = []
import pywifi
import logging
import time
import chardet

pywifi.set_loglevel(logging.WARNING)
wifi = pywifi.PyWiFi().interfaces()[0]
wifi.scan()
time.sleep(3)
wifi_nets = wifi.scan_results()
for x in wifi_nets:
    print(x.ssid)
    print(chardet(x.ssid))
Exemple #4
0
#测试链接
import pywifi, time, platform, threading, logging
from pywifi import const

pywifi.set_loglevel()


def go_scan():
    wifi = pywifi.PyWiFi()  #初始化
    iface = wifi.interfaces()[0]  #第一个无线网卡
    iface.scan()  #扫描
    time.sleep(2)
    bsses = iface.scan_results()  #扫描结果
    print("WiFi扫描结束")
    return bsses


def go_interfaces():
    wifi = pywifi.PyWiFi()
    assert wifi.interfaces()  #抓取网卡接口
    if platform.system().lower() == 'windows':  #判断平台
        assert wifi.interfaces()[0].name() == '####'  #自己网络的接口
    print("无线网卡测试完成")


class testwifi(threading.Thread):
    def __init__(self, wifiname, password):
        threading.Thread.__init__(self)
        self.wifiname = wifiname
        self.password = password