From f8a36b4a27a976d56448a884b36b4ac2534f09f6 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Thu, 2 Apr 2015 18:26:09 +0200 Subject: Retry sendlog on error --- tools/merge.py | 15 ++++++++++++--- 1 file 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) -- cgit v1.1