Created
April 20, 2015 17:56
-
-
Save marshyski/30eeafd3de2b1bf616ef to your computer and use it in GitHub Desktop.
Wait for website listening on port 443 to become available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configuration as config | |
from subprocess import call | |
import requests | |
import time, socket | |
''' Turn off SSL errors ''' | |
requests.packages.urllib3.disable_warnings() | |
''' Wait for port 443 is listening ''' | |
while True: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
try: | |
conn = s.connect_ex((pub_ip, 443)) | |
if conn == 0: | |
break | |
except: | |
print "Waiting for port 443 to listen on" | |
time.sleep(20) | |
''' Make web request with basic auth and get status code ''' | |
r = requests.get('https://' + pub_ip, auth=(config.USERNAME, config.PASSWORD), verify=False) | |
if r.status_code == 200: | |
''' Open website in web browser ''' | |
call (['open', 'https://' + pub_ip]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment