-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_files.py
More file actions
22 lines (22 loc) · 759 Bytes
/
send_files.py
File metadata and controls
22 lines (22 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1. def send_files(files):
2. """
3. Transfers files & calls posttransfer_check func
4. to varify file transfer.
5. Returns two strings to be used as subject line and body
6. of notification email
7. """
8.
9. from definitions import posttransfer_check
10. import pysftp
11. cnopts = pysftp.CnOpts()
12. cnopts.hostkeys = None
13. with pysftp.Connection(host="xxx.x.x.x", port=xxxx, username="USERNAME", password="PASSWORD",
14. cnopts=cnopts) as con:
15. con.chdir("/home/tamer/from_win")
16. [con.put(file) for file in files]
17. after =[f for f in con.listdir() if f.endswith("csv")]
18. subj, body = posttransfer_check(files, after)
19. if subj is None:
20. con.execute("touch success.txt")
21.
22. return subj, body