Tôi có mã sau đây với initalization của các thông tin loại bỏ. In các danh sách thư mục hoạt động, tuy nhiên "bị" không thành công với ngoại lệ sauparamiko sftp gặp lỗi
Dường như tôi không tìm nạp trước khi tôi trích xuất mã trong getfo và nhận nó hoạt động như một hàm trong mã của tôi với prefetch đã nhận xét ngoài.
Có giải pháp nào tốt hơn không?
*** Caught exception: <type 'exceptions.IOError'>: [Errno 2] The message [/Inbox/CD.BAIINT.D130802.T200541.M856559] is not extractable!
Traceback (most recent call last):
File "C:\Projects\Python\SFTP\SFTPHSC.py", line 71, in <module>
sftp.get(files, localpath + "/" + files)
File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 676, in get
size = self.getfo(remotepath, fl, callback)
File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 640, in getfo
file_size = self.stat(remotepath).st_size
File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 337, in stat
t, msg = self._request(CMD_STAT, path)
File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 689, in _request
return self._read_response(num)
File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 736, in _read_response
self._convert_status(msg)
File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 762, in _convert_status
raise IOError(errno.ENOENT, text)
IOError: [Errno 2] The message [/Inbox/CD.BAIINT.D130802.T200541.M856559] is not extractable!
username = ''
password=''
hostname =''
port=22
localpath ="c:/BkFiles/"
t = paramiko.Transport((hostname, port))
try:
t.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(t)
dirlist = sftp.listdir('.')
print "Dirlist:", dirlist
sftp.chdir('Inbox')
dirlist = sftp.listdir('.')
print "Dirlist:", dirlist
for files in dirlist:
sftp.get(files, localpath + files)
print files
except Exception, e:
print '*** Caught exception: %s: %s' % (e.__class__, e)
traceback.print_exc()
finally:
try:
t.close()
except:
pass
Bạn đã kiểm tra để xem nếu điều này là một lỗi thông tin? Bạn đang sử dụng hệ điều hành nào? Các tệp bạn đang cố gắng trích xuất được tạo bởi một chương trình có sử dụng UID khác từ tập lệnh này không? – AlexLordThorsen
Thông tin xác thực là chính xác. Như tôi đã nói trong bài đăng của mình, tôi có thể in các tệp trong thư mục. Ngoài ra, tôi đã có thể hack xung quanh vấn đề này bằng cách sao chép mã cho chức năng getfo từ sftp_client.py và gọi nó trực tiếp sau khi nhận xét ra lời gọi để tìm nạp trước. –