summaryrefslogtreecommitdiff
path: root/tools/merge.py
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-04-02 18:26:09 +0200
committerMagnus Ahltorp <map@kth.se>2015-04-02 18:26:09 +0200
commitf8a36b4a27a976d56448a884b36b4ac2534f09f6 (patch)
tree2c590ef341675ff51666abd8b85edfe72bcf779c /tools/merge.py
parent8c5b1dbba571456e3b68bcf25e4ca9db9b7b669b (diff)
Retry sendlog on error
Diffstat (limited to 'tools/merge.py')
-rwxr-xr-xtools/merge.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/merge.py b/tools/merge.py
index f9c93d9..5ceb245 100755
--- a/tools/merge.py
+++ b/tools/merge.py
@@ -16,6 +16,7 @@ import hashlib
import urlparse
import os
import yaml
+import select
from certtools import build_merkle_tree, create_sth_signature, \
check_sth_signature, get_eckey_from_file, timing_point, http_request, \
get_public_key_from_file
@@ -61,7 +62,7 @@ def write_chain(key, value):
try:
os.makedirs(path)
except Exception, e:
- print e
+ pass
else:
path = chainsdir
f = open(path + "/" + filename, "w")
@@ -131,7 +132,7 @@ def sendlog(node, baseurl, submission):
return json.loads(result)
except urllib2.HTTPError, e:
print "ERROR: sendlog", e.read()
- sys.exit(1)
+ return None
except ValueError, e:
print "==== FAILED REQUEST ===="
print submission
@@ -277,7 +278,15 @@ for frontendnode in frontendnodes:
print "current position", curpos
entries = [base64.b64encode(entry) for entry in logorder[curpos:]]
for chunk in chunks(entries, 1000):
- sendlogresult = sendlog(nodename, nodeaddress, {"start": curpos, "hashes": chunk})
+ for trynumber in range(5, 0, -1):
+ sendlogresult = sendlog(nodename, nodeaddress, {"start": curpos, "hashes": chunk})
+ if sendlogresult == None:
+ if trynumber == 1:
+ sys.exit(1)
+ select.select([], [], [], 10.0)
+ print "tries left:", trynumber
+ continue
+ break
if sendlogresult["result"] != "ok":
print "sendlog:", sendlogresult
sys.exit(1)