]> git.proxmox.com Git - mirror_frr.git/blame - tests/topotests/bgp-ecmp-topo1/peer11/exa-receive.py
tests: Run python formatter (black) for topotests
[mirror_frr.git] / tests / topotests / bgp-ecmp-topo1 / peer11 / exa-receive.py
CommitLineData
ac1087fa
MW
1#!/usr/bin/env python
2
3"""
4exa-receive.py: Save received routes form ExaBGP into file
5"""
6
787e7624 7from sys import stdin, argv
ac1087fa
MW
8from datetime import datetime
9
10# 1st arg is peer number
11peer = int(argv[1])
12
13# When the parent dies we are seeing continual newlines, so we only access so many before stopping
14counter = 0
15
787e7624 16routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
ac1087fa
MW
17
18while True:
19 try:
20 line = stdin.readline()
787e7624 21 timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
ac1087fa
MW
22 routesavefile.write(timestamp + line)
23 routesavefile.flush()
24
25 if line == "":
26 counter += 1
27 if counter > 100:
28 break
29 continue
30
31 counter = 0
32 except KeyboardInterrupt:
33 pass
34 except IOError:
35 # most likely a signal during readline
36 pass
37
38routesavefile.close()