1bed50a702431884c81f21dac8c15d872382f7b4
[functest.git] / testcases / security_scan / scripts / internet_check.py
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2016 Red Hat
4 # Luke Hinds (lhinds@redhat.com)
5 # This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Performs simple connection check, falls to default timeout of 10 seconds
12
13 import socket
14
15 TEST_HOST = "google.com"
16
17
18 def is_connected():
19     try:
20         host = socket.gethostbyname(TEST_HOST)
21         socket.create_connection((host, 80), 2)
22         return True
23     except:
24         return False
25 print is_connected()