Commit 690b9b7e authored by Benjamin Blanc's avatar Benjamin Blanc

erp5_bootstrap: add while/try for getConnection

parent c6877aff
...@@ -7,6 +7,7 @@ import time ...@@ -7,6 +7,7 @@ import time
MAX_INSTALLATION_TIME = 60*30 MAX_INSTALLATION_TIME = 60*30
MAX_TESTING_TIME = 60 MAX_TESTING_TIME = 60
MAX_GETTING_CONNECTION_TIME = 60*5
user = "%(user)s" user = "%(user)s"
password = "%(password)s" password = "%(password)s"
...@@ -21,12 +22,20 @@ header_dict = {'Authorization': 'Basic %%s' %% \ ...@@ -21,12 +22,20 @@ header_dict = {'Authorization': 'Basic %%s' %% \
def getConnection(): def getConnection():
print "Getting new connection" print "Getting new connection"
if protocol == 'https': start_time = time.time()
return httplib.HTTPSConnection(host) count = 0
elif protocol == 'http': while MAX_GETTING_CONNECTION_TIME > time.time()-start_time:
return httplib.HTTPConnection(host) try:
else: count = count + 1
raise ValueError("Protocol not implemented") if protocol == 'https':
return httplib.HTTPSConnection(host)
elif protocol == 'http':
return httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
except:
print "Getting new connection failed, retry"
raise ValueError("Cannot get new connection after %%d try (for %%s s)" %%(count, str(time.time()-start_time)))
def testIfExist(page, unexcepted_content="Site Error"): def testIfExist(page, unexcepted_content="Site Error"):
print "Test if %%s exists" %%(page) print "Test if %%s exists" %%(page)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment