-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_export.py
More file actions
executable file
·67 lines (48 loc) · 1.97 KB
/
Copy pathtest_export.py
File metadata and controls
executable file
·67 lines (48 loc) · 1.97 KB
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
#!/bin/env python3
link_addr = "2:5058/104"
encoding = "utf-8"
import os
import time
get_time = time.time
try:
os.mkdir("test")
except:
pass
if not os.path.isdir("test"):
print ("please make dir test")
exit()
import ftnconfig
import ftnaccess
from ftnexport import get_subscriptions_x
from ftnconfig import BUNDLETIMELIMIT
def get_subscriber_messages_e(db, subscriber, domain):
start_time = get_time()
print(start_time)
for target_id, target_name, target_last, subs_id, subs_last in get_subscriptions_x(db, subscriber, domain):
if get_time()-start_time>BUNDLETIMELIMIT-5:
print("Abandoning do to export time limit")
break
if target_last>subs_last:
print ("something new", target_id, target_name, target_last, subs_id, subs_last)
start_id = subs_last # position to start export
# after exporting block ('LIMIT 200') start from position after last exported message
while True:
last_id = None # update to number if something is exported
query = db.prepare(
"select m.id, m.source, m.destination, m.msgid, m.header, "
"m.body, m.origcharset, m.receivedfrom, m.processed from messages m where destination=$1 and id>$2 order by id limit 200")
data = query.chunks(target_id, start_id)
for x in data:
for mid,msrc,mdst,mmsgid,mhdr,mbody,mchr,mrecvfrom,mproc in x:
last_id = mid
yield mid, msrc, mdst, mmsgid, mhdr, mbody, mchr, mrecvfrom, subs_id, mproc
if last_id is None:
break
start_id = last_id
db=ftnconfig.connectdb()
link_id = ftnconfig.find_link(db, link_addr)
my_id, password = ftnaccess.link_password(db, link_id, forrobots=False)
print (link_addr, my_id, password)
addr_id = ftnconfig.get_addr_id(db, db.FTN_domains["node"], link_addr)
for id_msg, xxsrc, dest, msgid, header, body, origcharset, recvfrom, withsubscr, processed in get_subscriber_messages_e(db, addr_id, db.FTN_domains["echo"]):
print("id", id_msg)