diff options
author | Linus Nordberg <linus@nordu.net> | 2015-09-25 19:49:39 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2015-11-10 12:48:47 +0100 |
commit | 87e5dd2bfd293f229bab472e946ef12580facf6c (patch) | |
tree | 30f1fb6331d8db74aa454fb06be1debcdac7cd7f /tools/loginfo.py | |
parent | 5825db44c73510e71e34f020e3efd03bd49ffd0c (diff) |
Add a test for when merge backup fails.
Also, avoid tracebacks on ECONNREFUSED by catching urrllib2.URLError.
Diffstat (limited to 'tools/loginfo.py')
-rwxr-xr-x | tools/loginfo.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/loginfo.py b/tools/loginfo.py new file mode 100755 index 0000000..c61ad1b --- /dev/null +++ b/tools/loginfo.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2015, NORDUnet A/S. +# See LICENSE for licensing information. + +import sys +import argparse +import yaml +from certtools import create_ssl_context, get_sth + +def main(): + parser = argparse.ArgumentParser(description='') + parser.add_argument('--raw', action='store_true', + help="Print all") + parser.add_argument('--timestamp', action='store_true', + help="Print timestamp") + parser.add_argument('--roothash', action='store_true', + help="Print root hash") + parser.add_argument('--treesize', action='store_true', + help="Print tree size") + parser.add_argument('--signature', action='store_true', + help="Print signature") + parser.add_argument('--config', help="System configuration", required=True) + parser.add_argument('--localconfig', help="Local configuration", + required=True) + parser.add_argument('baseurl', help="Log base URL") + args = parser.parse_args() + #config = yaml.load(open(args.config)) + localconfig = yaml.load(open(args.localconfig)) + paths = localconfig["paths"] + + create_ssl_context(cafile=paths["https_cacertfile"]) + sth = get_sth(args.baseurl) + + if args.raw: + print sth + if args.timestamp: + print sth['timestamp'] + if args.roothash: + print sth['sha256_root_hash'] + if args.treesize: + print sth['tree_size'] + if args.signature: + print sth['tree_head_signature'] + +if __name__ == '__main__': + sys.exit(main()) |