summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/certtools.py10
-rwxr-xr-xtools/loginfo.py4
-rwxr-xr-xtools/testcase1.py9
3 files changed, 12 insertions, 11 deletions
diff --git a/tools/certtools.py b/tools/certtools.py
index f5482cb..7a5f9fc 100644
--- a/tools/certtools.py
+++ b/tools/certtools.py
@@ -18,6 +18,7 @@ import shutil
import requests
import warnings
import logging
+from time import sleep
from certkeys import publickeys
@@ -131,6 +132,15 @@ def get_sth(baseurl):
result.raise_for_status()
return result.json()
+def get_sth_retry(baseurl, tries=1):
+ for i in range(tries):
+ try:
+ return get_sth(baseurl)
+ except requests.exceptions.HTTPError, e:
+ if e.response.status_code == 500:
+ sleep(1)
+ raise e
+
def get_proof_by_hash(baseurl, hash, tree_size):
params = {"hash":base64.b64encode(hash),
"tree_size":tree_size}
diff --git a/tools/loginfo.py b/tools/loginfo.py
index c742b33..1356806 100755
--- a/tools/loginfo.py
+++ b/tools/loginfo.py
@@ -7,7 +7,7 @@
import sys
import argparse
import readconfig
-from certtools import create_ssl_context, get_sth
+from certtools import create_ssl_context, get_sth_retry
def main():
parser = argparse.ArgumentParser(description='')
@@ -29,7 +29,7 @@ def main():
paths = localconfig["paths"]
create_ssl_context(cafile=paths["https_cacertfile"])
- sth = get_sth(args.baseurl)
+ sth = get_sth_retry(args.baseurl, tries=10)
if args.raw:
print sth
diff --git a/tools/testcase1.py b/tools/testcase1.py
index 233415a..fb081e5 100755
--- a/tools/testcase1.py
+++ b/tools/testcase1.py
@@ -150,15 +150,6 @@ def get_and_check_entry(timestamp, chain, leaf_index, baseurl):
len(submittedcertchain),
len(submittedcertchain))
-def get_sth_retry(baseurl, tries=1):
- for i in range(tries):
- try:
- return get_sth(baseurl)
- except requests.exceptions.HTTPError, e:
- if e.response.status_code == 500:
- sleep(1)
- raise e
-
def correct_tree_size(expected):
for baseurl in baseurls:
sth = get_sth_retry(baseurl, tries=10)