def no_internet(host='<STR_LIT>', port=<NUM_LIT>, timeout=<NUM_LIT:1>):
try:<EOL><INDENT>socket.setdefaulttimeout(timeout)<EOL>socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))<EOL>return False<EOL><DEDENT>except OSError:<EOL><INDENT>return True<EOL><DEDENT>
Test whether internet is available

    http://stackoverflow.com/a/33117579/2449192