This commit is contained in:
Jing Ling
2020-09-17 23:18:00 +08:00
parent 53ce7591f3
commit b1a42dcf16
-13
View File
@@ -732,25 +732,13 @@ def sort_by_subdomain(data):
def ping(host, path):
"""
:param host:
:param path:
:return:
"""
param = '-n' if platform.system().lower() == 'windows' else '-c'
command = ['ping', param, '3', host]
with open(path, "w") as f:
return subprocess.call(command, stdout=f, stderr=f)
def ping_avg_time(nameserver):
"""
:param nameserver:
:return:
"""
check_dir(settings.temp_save_dir)
temp_path = settings.temp_save_dir.joinpath('ping')
ping(nameserver, path=temp_path)
@@ -769,7 +757,6 @@ def ping_avg_time(nameserver):
def auto_select_nameserver():
""""""
logger.log('INFOR', f'Ping test start, to select nameservers.')
avg_time1 = ping_avg_time('114.114.114.114')
avg_time2 = ping_avg_time('8.8.8.8')