sameer-b/AutoHathwayLogin — pull request #1 by rickysarraf (2013-12-11 19:29:35+00:00)
Title: Make it more resiliet to failures

This happens because in your connection health check, there's no
exception handling.

rrs@debtor:~/AutoHathwayLogin-master$ python AutoHathwayLogin.py
Traceback (most recent call last):
File "AutoHathwayLogin.py", line 55, in
if checkInternetConnectivity() == 0:
File "AutoHathwayLogin.py", line 37, in checkInternetConnectivity
conn.request("GET", "/")
File "/usr/lib/python2.7/httplib.py", line 973, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 791, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

Sample script output after the changes:

root@debtor:/home/rrs/AutoHathwayLogin-master# python
AutoHathwayLogin.py
1
Internet connectivity is dead. Trying to contact Hathway auth severs.
Trying to authenticate to server
http://login.hathway.com/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Failed to connect to
http://login.hathway.com/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username
thway.com&password=PASSWORD. Retrying
Trying to authenticate to server
http://203.212.193.60/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Failed to connect to
http://203.212.193.60/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Retrying
Trying to authenticate to server
http://203.212.193.61/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Failed to connect to
http://203.212.193.61/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Retrying
Internet connectivity is dead. Trying to contact Hathway auth severs.
Trying to authenticate to server
http://login.hathway.com/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Failed to connect to
http://login.hathway.com/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Retrying
Trying to authenticate to server
http://203.212.193.60/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Trying to authenticate to server
http://203.212.193.61/bsp/login.do?action=doLoginSubmit&flowId=UserLogin&username=USERNAME&password=PASSWORD.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.
Internet connectivity alive. Sleeping for 30 seconds.