Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from os import *
- from httplib import *
- from subprocess import *
- import time
- import platform
- def testconnection():
- f = HTTPConnection("www.google.com")
- try:
- f.request("GET", "/")
- except Exception:
- return False
- return True;
- while True:
- ff = testconnection()
- if(ff == False):
- print("No Internet Connection! Shutting Down System!")
- if(platform.system() == 'Windows'):
- call(["shutdown","/s","/t","100"])
- elif(platform.system() == 'Linux'):
- call(["sudo", "poweroff"])
- exit(0)
- elif(ff == True):
- print("InternetConnection Intact")
- print("Time to sleep some time")
- time.sleep(60*15)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement