This file is indexed.

/usr/share/pyshared/ZEO/scripts/parsezeolog.py is in python-zodb 1:3.10.5-0ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python2.3

"""Parse the BLATHER logging generated by ZEO2.

An example of the log format is:
2002-04-15T13:05:29 BLATHER(-100) ZEO Server storea(3235680, [714], 235339406490168806) ('10.0.26.30', 45514)
"""

import re
import time

rx_time = re.compile('(\d\d\d\d-\d\d-\d\d)T(\d\d:\d\d:\d\d)')

def parse_time(line):
    """Return the time portion of a zLOG line in seconds or None."""
    mo = rx_time.match(line)
    if mo is None:
        return None
    date, time_ = mo.group(1, 2)
    date_l = [int(elt) for elt in date.split('-')]
    time_l = [int(elt) for elt in time_.split(':')]
    return int(time.mktime(date_l + time_l + [0, 0, 0]))

rx_meth = re.compile("zrpc:\d+ calling (\w+)\((.*)")

def parse_method(line):
    pass

def parse_line(line):
    """Parse a log entry and return time, method info, and client."""
    t = parse_time(line)
    if t is None:
        return None, None
    mo = rx_meth.search(line)
    if mo is None:
        return None, None
    meth_name = mo.group(1)
    meth_args = mo.group(2).strip()
    if meth_args.endswith(')'):
        meth_args = meth_args[:-1]
    meth_args = [s.strip() for s in meth_args.split(",")]
    m = meth_name, tuple(meth_args)
    return t, m

class TStats:

    counter = 1

    def __init__(self):
        self.id = TStats.counter
        TStats.counter += 1

    fields = ("time", "vote", "done", "user", "path")
    fmt = "%-24s %5s %5s %-15s %s"
    hdr = fmt % fields

    def report(self):
        """Print a report about the transaction"""
        t = time.ctime(self.begin)
        if hasattr(self, "vote"):
            d_vote = self.vote - self.begin
        else:
            d_vote = "*"
        if hasattr(self, "finish"):
            d_finish = self.finish - self.begin
        else:
            d_finish =  "*"
        print self.fmt % (time.ctime(self.begin), d_vote, d_finish,
                          self.user, self.url)

class TransactionParser:

    def __init__(self):
        self.txns = {}
        self.skipped = 0

    def parse(self, line):
        t, m = parse_line(line)
        if t is None:
            return
        name = m[0]
        meth = getattr(self, name, None)
        if meth is not None:
            meth(t, m[1])

    def tpc_begin(self, time, args):
        t = TStats()
        t.begin = time
        t.user = args[1]
        t.url = args[2]
        t.objects = []
        tid = eval(args[0])
        self.txns[tid] = t

    def get_txn(self, args):
        tid = eval(args[0])
        try:
            return self.txns[tid]
        except KeyError:
            print "uknown tid", repr(tid)
            return None

    def tpc_finish(self, time, args):
        t = self.get_txn(args)
        if t is None:
            return
        t.finish = time

    def vote(self, time, args):
        t = self.get_txn(args)
        if t is None:
            return
        t.vote = time

    def get_txns(self):
        L = [(t.id, t) for t in self.txns.values()]
        L.sort()
        return [t for (id, t) in L]

if __name__ == "__main__":
    import fileinput

    p = TransactionParser()
    i = 0
    for line in fileinput.input():
        i += 1
        try:
            p.parse(line)
        except:
            print "line", i
            raise
    print "Transaction: %d" % len(p.txns)
    print TStats.hdr
    for txn in p.get_txns():
        txn.report()