-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathftnfileexport.py
More file actions
executable file
·32 lines (25 loc) · 866 Bytes
/
Copy pathftnfileexport.py
File metadata and controls
executable file
·32 lines (25 loc) · 866 Bytes
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
#!/usr/bin/python3 -bb
import ftnexport
import ftnconfig
import os
db=ftnconfig.connectdb()
address="2:5058/104"
password=""
classes=["echo"]
outdir=os.path.join("static", address.replace("/", ".").replace(":","."))
os.makedirs(outdir, exist_ok=True)
def log(s):
print("fileexport:", s)
for outbfile, committer in ftnexport.file_export(db, address, password, classes):
if outbfile is not None:
log("outbound file "+outbfile.filename+ " " + str(outbfile.length) + " bytes")
outf=open(os.path.join(outdir,outbfile.filename), "xb")
while True:
d = outbfile.data.read(16*1024*1024)
if len(d)==0:
break
written = outf.write(d)
if written != len(d):
raise Exception("error on write %d of %d"%(written, len(d)))
outf.close()
committer.commit()