]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/find-share-anomalies.py
quickstart.html: link to snapshots page, sorted with most recent first.
[tahoe-lafs/tahoe-lafs.git] / misc / find-share-anomalies.py
1 #!/usr/bin/env python
2
3 # feed this the results of 'tahoe catalog-shares' for all servers
4
5 import sys
6
7 chk_encodings = {}
8 sdmf_encodings = {}
9 sdmf_versions = {}
10
11 for catalog in sys.argv[1:]:
12     for line in open(catalog, "r").readlines():
13         line = line.strip()
14         pieces = line.split()
15         if pieces[0] == "CHK":
16             ftype, si, kN, size, ueb_hash, expiration, filename = pieces
17             if si not in chk_encodings:
18                 chk_encodings[si] = (set(), set())
19             chk_encodings[si][0].add( (si, kN) )
20             chk_encodings[si][1].add( line )
21         if pieces[0] == "SDMF":
22             ftype, si, kN, size, ver, expiration, filename = pieces
23             if si not in sdmf_encodings:
24                 sdmf_encodings[si] = (set(), set())
25             sdmf_encodings[si][0].add( (si, kN) )
26             sdmf_encodings[si][1].add( line )
27             if si not in sdmf_versions:
28                 sdmf_versions[si] = (set(), set())
29             sdmf_versions[si][0].add( ver )
30             sdmf_versions[si][1].add( line )
31
32 chk_multiple_encodings = [(si,lines)
33                           for si,(encodings,lines) in chk_encodings.items()
34                           if len(encodings) > 1]
35 chk_multiple_encodings.sort()
36 sdmf_multiple_encodings = [(si,lines)
37                            for si,(encodings,lines) in sdmf_encodings.items()
38                            if len(encodings) > 1
39                            ]
40 sdmf_multiple_encodings.sort()
41 sdmf_multiple_versions = [(si,lines)
42                           for si,(versions,lines) in sdmf_versions.items()
43                           if len(versions) > 1]
44 sdmf_multiple_versions.sort()
45
46 if chk_multiple_encodings:
47     print
48     print "CHK multiple encodings:"
49     for (si,lines) in chk_multiple_encodings:
50         print " " + si
51         for line in sorted(lines):
52             print "  " + line
53 if sdmf_multiple_encodings:
54     print
55     print "SDMF multiple encodings:"
56     for (si,lines) in sdmf_multiple_encodings:
57         print " " + si
58         for line in sorted(lines):
59             print "  " + line
60 if sdmf_multiple_versions:
61     print
62     print "SDMF multiple versions:"
63     for (si,lines) in sdmf_multiple_versions:
64         print " " + si
65         for line in sorted(lines):
66             print "  " + line