File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -121,8 +121,8 @@ def 更新plist(self,CurrentDir):
121
121
122
122
class 密码机制 :
123
123
def __init__ (self ):
124
- windows_username = getpass .getuser ()
125
- ExeFileLocation = "/Users/" + windows_username + "/Documents/WIFI助手"
124
+ Username = getpass .getuser ()
125
+ ExeFileLocation = "/Users/" + Username + "/Documents/WIFI助手"
126
126
self .ConfigureFile = ExeFileLocation + "/Configure.ini"
127
127
self .config = configparser .ConfigParser ()
128
128
self .config .read (self .ConfigureFile , encoding = 'utf-8' )
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
2
# coding=utf-8
3
+ # pip install pywin32 requests, pythonping
4
+
3
5
from win32api import *
4
6
from win32gui import *
5
7
import win32con
@@ -191,6 +193,7 @@ class 执行:
191
193
def __init__ (self ):
192
194
登陆登出 ().登出 ()
193
195
self .ThisWindows = WindowsBalloonTip (software_name = 'WIFI助手' )
196
+ self .OfflineCount = 0
194
197
def 登陆 (self ):
195
198
self .用户密码 = 密码机制 ().read ()
196
199
if self .用户密码 != 1 :
@@ -216,9 +219,19 @@ def 登陆(self):
216
219
def 检查网络 (self ):
217
220
try :
218
221
if not (ping ('baidu.com' , count = 1 ).success ()):
219
- self .ThisWindows .Notify ("WIFI状态更新" , "认证已失效,正在重新认证" )
222
+ self .OfflineCount += 1
223
+ if self .OfflineCount < 3 :
224
+ self .ThisWindows .Notify ("WIFI状态更新" , "认证已失效,正在重新认证" )
225
+ else :
226
+ if self .OfflineCount == 3 :
227
+ self .ThisWindows .Notify ("WIFI故障" , "此WIFI目前存在故障,暂时屏蔽通知。待WIFI网络恢复,将再次通知" )
220
228
self .登陆 ()
221
229
time .sleep (2 )
222
- self .ThisWindows .Notify ("WIFI状态更新" , "网络已恢复,已成功认证" )
230
+ if ping ('baidu.com' , count = 1 ).success ():
231
+ self .ThisWindows .Notify ("WIFI状态更新" , "网络已恢复,已成功认证" )
232
+ else :
233
+ if self .OfflineCount >= 3 :
234
+ self .ThisWindows .Notify ("WIFI故障恢复" ,"WIFI故障已恢复,已成功认证" )
235
+ self .OfflineCount = 0
223
236
except :
224
237
self .ThisWindows .Notify (title = 'WIFI已断开' , msg = '请手动重连相关WIFI' )
You can’t perform that action at this time.
0 commit comments