File indexing completed on 2026-04-09 07:48:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022 bouncelog.py
0023 ==============
0024
0025 Parse the kernel print log::
0026
0027 tboolean-;tboolean-box --okg4 --align --mask 1230 --pindex 0 --pindexlog -DD
0028
0029 ## write kernel pindexlog for photon 1230
0030
0031 boucelog.py 1230
0032
0033 ## parse the log
0034
0035
0036 """
0037 from __future__ import print_function
0038 from collections import OrderedDict
0039 import os, sys, re
0040
0041
0042 class Bounce(list):
0043 def __init__(self):
0044 list.__init__(self)
0045 def __str__(self):
0046 return "\n".join([""]+self+[""])
0047
0048
0049 class BounceLog(OrderedDict):
0050 @classmethod
0051 def printlogpath(cls, pindex):
0052 return os.path.expandvars("$TMP/ox_%s.log" % pindex )
0053
0054 BOUNCE = re.compile("bounce:(\S*)")
0055
0056 def __init__(self, pindex):
0057 OrderedDict.__init__(self)
0058 self.pindex = pindex
0059 self.path = self.printlogpath(pindex)
0060 self.parse(self.path)
0061
0062 def parse(self, path):
0063 self.lines = map(lambda line:line.rstrip(),file(path).readlines())
0064
0065 curr = []
0066 bounce = -1
0067
0068 for i, line in enumerate(self.lines):
0069 m = self.BOUNCE.search(line)
0070 if m:
0071
0072 bounce += 1
0073 self[bounce] = Bounce()
0074 pass
0075 if bounce > -1:
0076 self[bounce].append(line)
0077 pass
0078
0079
0080
0081 if __name__ == '__main__':
0082
0083
0084 pindex = int(sys.argv[1]) if len(sys.argv) > 1 else 1230
0085
0086 bl = BounceLog(pindex)
0087
0088 for k, v in bl.items():
0089 print(k)
0090 print(v)
0091 print("\n\n")
0092
0093
0094