-
Notifications
You must be signed in to change notification settings - Fork 2
/
stat_netmail_route.py
executable file
·58 lines (41 loc) · 1.17 KB
/
stat_netmail_route.py
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
#!/usr/local/bin/python3 -bb
import textwrap
import ftnconfig
import ftnimport
db=ftnconfig.connectdb()
x=db.prepare("""select t.text, sr.text
from subscriptions s, addresses t, addresses sr
where t.id=s.target and sr.id=s.subscriber and t.domain=$1""")
outp = []
peers = {}
for t, sr in x(db.FTN_domains["node"]):
peers.setdefault(sr, []).append(t if t!=sr else "self")
plist = list(peers.keys())
plist.sort()
direct = []
outp.append ("Route netmail via:\n")
outp.append ("\n")
for p in plist:
ts = peers[p]
ts.sort()
targstr=", ".join(ts)
if targstr == "self":
direct.append(p)
else:
pre = "%-17s: "%p
for l in textwrap.wrap(targstr, 55):
outp.append (pre + l + "\n")
pre = " "*19
outp.append ("\n")
dirstr = ", ".join(direct) or "none"
outp.append ("Direct links:\n")
for l in textwrap.wrap(dirstr, 70):
outp.append (" %s\n"%l)
#print("".join(outp))
#exit()
with ftnimport.session(db) as sess:
sess.send_message(("node", ftnconfig.ADDRESS), "Sergey Dorofeev", ("echo", "FLUID.REPORTS"), "All", None, "схема роутинга нетмейла",
"""Привет All
%s
Вот так
"""%("".join(outp)))