Pyftpsync仅在没有TLS的情况下工作

时间:2017-03-31 14:53:16

标签: python ssl openssl ftplib ftps

您好我正在使用pyftpsync来上传新图像(每天下载),跳过现有的图像。

从作者网站我正在使用此代码(当然还有我的个人数据):

from ftpsync.targets import FsTarget
from ftpsync.ftp_target import   FtpTarget
from ftpsync.synchronizers import UploadSynchronizer

local = FsTarget("~/temp")
user ="joe" 
passwd = "secret" 
remote = FtpTarget("/temp", "example.com", username=user, password=passwd) 
opts= {"force": False, "delete_unmatched": True, "verbose": 3, "dry_run" : False} 
s = UploadSynchronizer(local, remote, opts,tls=True)
s.run()

只有在我删除tls选项时才能正确地为我工作,否则在连接到我的服务器时会出现此错误:

Traceback (most recent call last):
File "sync.py", line 25, in <module>
s.run()
File "/media/luca/1E9C3E629C3E349D/luca/Documenti/attività/Cataloghi2/ftpsync/synchronizers.py", line 139, in run
res = self._sync_dir()
File "/media/luca/1E9C3E629C3E349D/luca/Documenti/attività/Cataloghi2/ftpsync/synchronizers.py", line 416, in _sync_dir
remote_entries = self.remote.get_dir()
File "/media/luca/1E9C3E629C3E349D/luca/Documenti/attività/Cataloghi2/ftpsync/ftp_target.py", line 310, in get_dir
self.ftp.retrlines("MLSD", _addline)
File "/usr/lib/python3.4/ftplib.py", line 466, in retrlines
resp = self.sendcmd('TYPE A')
File "/usr/lib/python3.4/ftplib.py", line 272, in sendcmd
return self.getresp()
File "/usr/lib/python3.4/ftplib.py", line 235, in getresp
resp = self.getmultiline()
File "/usr/lib/python3.4/ftplib.py", line 221, in getmultiline
line = self.getline()
File "/usr/lib/python3.4/ftplib.py", line 209, in getline
raise EOFError
EOFError
Could not remove lock file: Underlying socket connection gone (_ssl.c:1570)
Exception ignored in: <bound method FtpTarget.__del__ of <ftpsync.ftp_target.FtpTarget object at 0x7fe397ae7710>>
Traceback (most recent call last):
File "/media/luca/1E9C3E629C3E349D/luca/Documenti/attività/Cataloghi2/ftpsync/targets.py", line 70, in __del__
File "/media/luca/1E9C3E629C3E349D/luca/Documenti/attività/Cataloghi2/ftpsync/ftp_target.py", line 153, in close
File "/media/luca/1E9C3E629C3E349D/luca/Documenti/attività/Cataloghi2/ftpsync/ftp_target.py", line 187, in _unlock
File "/usr/lib/python3.4/ftplib.py", line 613, in delete
File "/usr/lib/python3.4/ftplib.py", line 271, in sendcmd
File "/usr/lib/python3.4/ftplib.py", line 198, in putcmd
File "/usr/lib/python3.4/ftplib.py", line 193, in putline
File "/usr/lib/python3.4/ssl.py", line 720, in sendall
File "/usr/lib/python3.4/ssl.py", line 681, in send
ssl.SSLError: Underlying socket connection gone (_ssl.c:1570)

这显然是与加密有关的问题,但我不知道如何修复它。

0 个答案:

没有答案