pythonpython-3.xftp

Connecting to an FTP resource using FTPwalker fails with "Name or service not known"


I'm trying to traverse an ftp directory using FTPwalker, however I cannot connect.

The current call is being used:

walker = ftpwalker(server_name="hostname", url="ftp://username:password@hostname")

However walker.check_state() gives:

>> walker.check_state()
Find leading...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/site-packages/FTPwalker/runwalker.py", line 100, in check_state
    self.path_not_exit(False)
  File "/usr/lib/python3.4/site-packages/FTPwalker/runwalker.py", line 157, in path_not_exit
    self.m_walker.Process_dispatcher(False)
  File "/usr/lib/python3.4/site-packages/FTPwalker/main_walker.py", line 82, in Process_dispatcher
    leadings = self.find_leading_dirs(self.root)
  File "/usr/lib/python3.4/site-packages/FTPwalker/main_walker.py", line 37, in find_leading_dirs
    files, dirs = self.run_object.find_leading(top)
  File "/usr/lib/python3.4/site-packages/FTPwalker/traverse.py", line 75, in find_leading
    conn = ftplib.FTP(self.server_url)
  File "/usr/lib64/python3.4/ftplib.py", line 118, in __init__
    self.connect(host)
  File "/usr/lib64/python3.4/ftplib.py", line 153, in connect
    source_address=self.source_address)
  File "/usr/lib64/python3.4/socket.py", line 498, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib64/python3.4/socket.py", line 537, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Is the url parameter entered here in the correct format? Pinging the hostname works.


Solution

  • FTPwalker is dead, use FTPflow:
    https://pypi.org/project/FTPflow/


    Old answer: While the parameter is misleadingly named url, the official FTPwalker example showed pretty clearly, that the value should actually be a plain hostname:

    from FTPwalker.runwalker import ftpwalker
    
    walker = ftpwalker("Uniprot", "ftp.uniprot.org")
    walker.check_state()
    

    In the the end, the value goes to ftplib.FTP.connect, which takes "hostname".