From 99306083f68513cd04e3d1634ad7eb71b5733132 Mon Sep 17 00:00:00 2001 From: josef Date: Tue, 10 Nov 2015 12:57:53 +0100 Subject: debugging --- monitor/josef_experimental.py | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'monitor/josef_experimental.py') diff --git a/monitor/josef_experimental.py b/monitor/josef_experimental.py index 2ccfceb..ba85a71 100755 --- a/monitor/josef_experimental.py +++ b/monitor/josef_experimental.py @@ -183,31 +183,31 @@ if __name__ == '__main__': # Data gathering for Niklas if True: - log = CTLOGS[0] - sth = get_sth(log["url"]) - # size = sth["tree_size"] - # for i in range(15,200): - start = 0 - end = int(sth["tree_size"]) - 1 - print "Getting " + str(start) + " to " + str(end) - entries = get_entries(log["url"],start ,end)["entries"] - - # TODO set filename - filename = log["name"] + "_content.txt" - # TODO remove file if exists - if os.path.exists(filename): - if prompt_confirm("You are about to overwrite " + filename): - os.remove(filename) - else: - sys.exit() - # TODO open file - with open(filename, 'a') as f: - # TODO write lines - for i in range(len(entries)): - entry = entries[i] - res = check_domain_extended(entry) - string = parse_entry(res, i + start, log) - f.write(string + "\n") + logs = [CTLOGS[7]] + for log in logs: + filename = log["name"] + "_content.txt" + if os.path.exists(filename): + if prompt_confirm("You are about to overwrite " + filename): + os.remove(filename) + else: + sys.exit() + + sth = get_sth(log["url"]) + start = 0 + idx = 0 + end = int(sth["tree_size"]) - 1 + + while idx < end: + entries = get_entries(log["url"],start + idx ,end)["entries"] + print log["name"] + ": Got " + str(start + idx) + " to " + str(start + idx + len(entries) - 1) + idx = idx + len(entries) + + with open(filename, 'a') as f: + for i in range(len(entries)): + entry = entries[i] + res = check_domain_extended(entry) + string = parse_entry(res, i + start, log) + f.write(string + "\n") -- cgit v1.1