Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Public Member Functions
SpandspLog Class Reference

Public Member Functions

def __init__ (self, fp)
 
def __iter__ (self)
 

Detailed Description

Definition at line 193 of file spandspflow2pcap.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  fp 
)

Definition at line 194 of file spandspflow2pcap.py.

194 def __init__(self, fp):
195 self._fp = fp
196

References SpandspLog._fp.

Member Function Documentation

◆ __iter__()

def __iter__ (   self)
Looks for lines line:

    [2013-08-07 15:17:34] FAX[23479] res_fax.c: \
      FLOW T.38 Rx     5: IFP c0 01 80 00 00 ff

And yields:

    IFP(date=..., seqno=..., data=...)

Definition at line 197 of file spandspflow2pcap.py.

197 def __iter__(self):
198 r"""
199 Looks for lines line:
200
201 [2013-08-07 15:17:34] FAX[23479] res_fax.c: \
202 FLOW T.38 Rx 5: IFP c0 01 80 00 00 ff
203
204 And yields:
205
206 IFP(date=..., seqno=..., data=...)
207 """
208 prev_seqno = None
209
210 for lineno, line in enumerate(self._fp):
211 if 'FLOW T.38 Rx' not in line:
212 continue
213 if 'IFP' not in line:
214 continue
215
216 match = search(r'(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)', line)
217 assert match
218 date = datetime(*[int(i) for i in match.groups()])
219
220 match = search(r'Rx\s*(\d+):', line)
221 assert match
222 seqno = int(match.groups()[0])
223
224 match = search(r': IFP ([0-9a-f ]+)', line)
225 assert match
226 data = n2b(match.groups()[0])
227
228 if prev_seqno is not None:
229 # Expected all sequence numbers. But you can safely disable
230 # this check.
231 assert seqno == prev_seqno + 1, '%s+1 != %s' % (
232 seqno, prev_seqno)
233 pass
234 prev_seqno = seqno
235
236 yield IFP(date=date, seqno=seqno, data=data)
237
238

References SpandspLog._fp, spandspflow2pcap.IFP, and spandspflow2pcap.n2b().


The documentation for this class was generated from the following file: