Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
优化逻辑,提升速度
  • Loading branch information
amluckydave committed Sep 8, 2019
1 parent 2a10f9c commit b03a607
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions ruijie.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

linkpath = shuPath()


class shuConnect:
def __init__(self, user=0, passwd='shu'):
self.user = user
Expand Down
24 changes: 12 additions & 12 deletions wifiConnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def wifi_connect_status(user, passwd):
if not psutil.net_if_stats()[nameHi].isup: # wifi未连接到wifi或未打开WiFi开关
if not psutil.net_if_stats()[nameHi].isup: # wifi未连接到Shu(ForAll) 或未打开WiFi开关
try:
s = connect_wifi(user, passwd)
except Exception as e:
Expand All @@ -30,25 +30,25 @@ def wifi_connect_status(user, passwd):


def connect_wifi(user, passwd):
wifi = PyWiFi() # 创建一个wifi对象
iface = wifi.interfaces()[0] # 取第一个无限网卡
iface.disconnect() # 断开网卡连接
try:
wifi = PyWiFi() # 创建一个wifi对象
iface = wifi.interfaces()[0] # 取第一个无限网卡

profile = Profile() # 配置文件
profile.ssid = "Shu(ForAll)" # wifi名称
iface.disconnect() # 断开网卡连接
profile = Profile() # 配置文件
profile.ssid = "Shu(ForAll)" # wifi名称

iface.remove_all_network_profiles() # 删除其他配置文件
tmp_profile = iface.add_network_profile(profile) # 加载配置文件
iface.remove_all_network_profiles() # 删除其他配置文件
tmp_profile = iface.add_network_profile(profile) # 加载配置文件

iface.connect(tmp_profile) # 连接
sleep(1.5) # 不延时,状态码来不及改变
iface.connect(tmp_profile) # 连接
sleep(0.5) # 不延时,wifi反应不过来

if iface.status() == const.IFACE_CONNECTED:
s0 = "Shu(ForAll) 连接成功\n"
shu = shuConnect(user, passwd)
s = s0 + shu.start_connect()

else:
except:
s = "无线网卡未打开,请打开 WLAN 开关\n"

return s

0 comments on commit b03a607

Please sign in to comment.