| « HTML colors | Coupons » |
Monday, February 23rd, 2009
M2Crypto FTPS
I have been trying a ton to find something about FTPS with python. I desperately need to automate a process that I have to manually do twice daily, and at very inconvenient hours. I finally came up with this:
from M2Crypto import ftpslib
def handleDownload(block):
file.write(block)
print ".",
f = ftpslib.FTP_TLS()
f.connect('ftp.server.com',21)
f.login('testaccount', 'testaccount')
f.auth_tls()
f.set_pasv(0)
file = open('localfile.txt', 'wb')
f.retrbinary('RETR test.txt', handleDownload)
file.close()
f.quit()
I'm not positive how secure it actually is, but it seems to me that M2Crypto should hold it's ground, since every internet search regarding FTPS with Python returns something about M2Crypto.
9:10pm by Brandon //comment 768 views