disabled server.py check internet

This commit is contained in:
Justin 2022-03-02 19:25:42 +08:00 committed by GitHub
parent 15e839f6e3
commit 8afe025d37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -412,23 +412,23 @@ def set_wifi():
os.system('wpa_cli -i wlan0 reconfigure')
return index()
def check_internet_connection(host='http://google.com'):
#def check_internet_connection(host='http://google.com'):
try:
urllib.request.urlopen(host) #Python 3.x
return True
except:
return False
#try:
#urllib.request.urlopen(host) #Python 3.x
#return True
#except:
#return False
def check_network_connection():
ps = subprocess.Popen(['iwconfig'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
try:
output = subprocess.check_output(('grep', 'ESSID'), stdin=ps.stdout)
return True
except subprocess.CalledProcessError:
#def check_network_connection():
#ps = subprocess.Popen(['iwconfig'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
#try:
#output = subprocess.check_output(('grep', 'ESSID'), stdin=ps.stdout)
#return True
#except subprocess.CalledProcessError:
# grep did not match any lines
print("No wireless networks connected")
return False
#print("No wireless networks connected")
#return False
def edit_hosts(hostname):
current_hosts = open('/etc/hosts')