summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/merge.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/merge.py b/tools/merge.py
index c137f4b..1b94581 100755
--- a/tools/merge.py
+++ b/tools/merge.py
@@ -14,6 +14,7 @@ import time
import ecdsa
import hashlib
import urlparse
+import os
from certtools import build_merkle_tree, create_sth_signature, check_sth_signature, get_eckey_from_file, timing_point, http_request
parser = argparse.ArgumentParser(description="")
@@ -36,6 +37,8 @@ logorderfile = args.mergedb + "/logorder"
own_key = (args.own_keyname, args.own_keyfile)
+hashed_dir = True
+
def parselogrow(row):
return base64.b16decode(row)
@@ -44,12 +47,26 @@ def get_logorder():
return [parselogrow(row.rstrip()) for row in f]
def write_chain(key, value):
- f = open(chainsdir + "/" + base64.b16encode(key), "w")
+ filename = base64.b16encode(key)
+ if hashed_dir:
+ path = chainsdir + "/" + filename[0:2] + "/" + filename[2:4] + "/" + filename[4:6]
+ try:
+ os.makedirs(path)
+ except Exception, e:
+ print e
+ else:
+ path = chainsdir
+ f = open(path + "/" + filename, "w")
f.write(value)
f.close()
def read_chain(key):
- f = open(chainsdir + "/" + base64.b16encode(key), "r")
+ filename = base64.b16encode(key)
+ path = chainsdir + "/" + filename[0:2] + "/" + filename[2:4] + "/" + filename[4:6]
+ try:
+ f = open(path + "/" + filename, "r")
+ except IOError, e:
+ f = open(chainsdir + "/" + filename, "r")
value = f.read()
f.close()
return value