summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2017-02-07 22:17:33 +0100
committerMagnus Ahltorp <map@kth.se>2017-02-07 22:17:33 +0100
commit62ffe6ec3df17d48f92c01bbdf27aca5845eb189 (patch)
treef46aec8610ab568e493220e45feef5b3b92d0d97 /tools
parent142b19cda6f9c6133c3559f320bb96b10447fb3b (diff)
Handle lack of STH in mergestatusbetter-start-stop-2
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mergestatus.py9
-rwxr-xr-xtools/testcase1.py12
2 files changed, 15 insertions, 6 deletions
diff --git a/tools/mergestatus.py b/tools/mergestatus.py
index 80d755e..f47cc68 100755
--- a/tools/mergestatus.py
+++ b/tools/mergestatus.py
@@ -10,6 +10,7 @@ import urllib2
import time
import requests
import base64
+import errno
from base64 import b64encode
from mergetools import parse_args, get_nfetched, hexencode, hexdecode, \
get_logorder, get_sth
@@ -25,7 +26,6 @@ def main():
sthfile = mergedb + "/sth"
currentsizefile = mergedb + "/fetched"
- sth = json.loads(open(sthfile, "r").read())
currentsize = json.loads(open(currentsizefile, "r").read())
print >>sys.stderr, currentsize["index"]+1,
@@ -39,7 +39,12 @@ def main():
print >>sys.stderr, tree["tree_size"],
except (IOError, ValueError):
pass
- print >>sys.stderr, sth["tree_size"],
+ try:
+ sth = json.loads(open(sthfile, "r").read())
+ print >>sys.stderr, sth["tree_size"],
+ except IOError, e:
+ if e.errno != errno.ENOENT:
+ raise
print
if __name__ == '__main__':
diff --git a/tools/testcase1.py b/tools/testcase1.py
index 63be2e1..233415a 100755
--- a/tools/testcase1.py
+++ b/tools/testcase1.py
@@ -13,6 +13,8 @@ import struct
import hashlib
import itertools
import os.path
+import readconfig
+import errno
from time import sleep
from certtools import *
@@ -165,8 +167,6 @@ def correct_tree_size(expected):
return False
return True
-import readconfig
-
def mergestatus(configfile, localconfigfile):
localconfig = readconfig.read_config(localconfigfile)
config = readconfig.verify_and_read_config(configfile, localconfig["logadminkey"])
@@ -177,7 +177,6 @@ def mergestatus(configfile, localconfigfile):
sthfile = mergedb + "/sth"
currentsizefile = mergedb + "/fetched"
- sth = json.loads(open(sthfile, "r").read())
currentsize = json.loads(open(currentsizefile, "r").read())
print >>sys.stderr, currentsize["index"]+1,
@@ -191,7 +190,12 @@ def mergestatus(configfile, localconfigfile):
print >>sys.stderr, tree["tree_size"],
except (IOError, ValueError):
pass
- print >>sys.stderr, sth["tree_size"],
+ try:
+ sth = json.loads(open(sthfile, "r").read())
+ print >>sys.stderr, sth["tree_size"],
+ except IOError, e:
+ if e.errno != errno.ENOENT:
+ raise
print