I just installed your lib and tried to run your sample code:
with ftputil.FTPHost(FtpCred['host'],FtpCred['userid'],FtpCred['password']) as ftpHost:
print(ftpHost.listdir(ftp_host.curdir))
Got the following error:
Traceback (most recent call last):
File "C:\Program Files\Python33\lib\site-packages\ftputil\host.py", line 129, in _make_session
return factory(*args, **kwargs)
File "C:\Program Files\Python33\lib\ftplib.py", line 114, in __init__
self.connect(host)
File "C:\Program Files\Python33\lib\ftplib.py", line 148, in connect
source_address=self.source_address)
File "C:\Program Files\Python33\lib\socket.py", line 406, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 420, in run_nodebug
File "C:\Users\npochez\Documents\GitHub\RunKS-1\SendFiles.py", line 21, in <module>
with ftputil.FTPHost(FtpCred['host'],FtpCred['userid'],FtpCred['password']) as ftpHost:
File "C:\Program Files\Python33\lib\site-packages\ftputil\host.py", line 69, in __init__
self._session = self._make_session()
File "C:\Program Files\Python33\lib\site-packages\ftputil\host.py", line 129, in _make_session
return factory(*args, **kwargs)
File "C:\Program Files\Python33\lib\site-packages\ftputil\error.py", line 146, in __exit__
raise FTPOSError(*exc_value.args, original_exception=exc_value)
ftputil.error.FTPOSError: [Errno 11001] getaddrinfo failed
Debugging info: ftputil 3.2, Python 3.3.0 (win32)
Thanks for the report!
If I remember correctly, I've seen this problem where someone had included an
ftp://
prefix in the host address. Python's socket library, and thus ftputil, will only accept a mere host name without a URL protocol prefix.Another possibility is that the nameserver you're using isn't reachable or doesn't work properly. Can you "ping" the FTP host from the command line (from the same machine where your ftputil client code runs)? Can you connect to the server with a command line FTP client?
If these hints don't help, please provide the value of
FtpCred['host']
. (For Python 3, this must be a unicode string (the built-instr
type), not a byte string.)If the hints do help, please let me know as well, so that I can close the ticket. :-)
Since I didn't get any feedback since my last comment and can't reproduce the problem, I close the ticket for now. Please reopen the ticket and provide further details if the problem is still present for you.
The error may also come from a name server problem.
By the way, there's a similar issue in ticket #76. The error number there is different, but this could be because of the different platforms. Ticket #76 was for Linux whereas this ticket is for Windows, as you can see in the last lines of the tracebacks.
In a Wine environment, I get
>>> socket.getaddrinfo("localhost:22", 22) Traceback (most recent call last): File "<stdin>", line 1, in <module> socket.gaierror: [Errno 11001] getaddrinfo failed >>> socket.getaddrinfo("ftp://localhost", 22) Traceback (most recent call last): File "<stdin>", line 1, in <module> socket.gaierror: [Errno 11001] getaddrinfo failed
Therefore, I'll change the resolution to "duplicate".
Duplicate of ticket #76.