generate functionSun, 13 Nov 2022

Check if internet is detected. If not, restart the computer.

import time import os import requests def check_internet(): url='http://www.google.com/' timeout=5 try: _ = requests.get(url, timeout=timeout) return True except requests.ConnectionError: print("No internet connection available.") os.system("sudo shutdown -r now") return False x = check_internet()

Questions about programming?Chat with your personal AI assistant