-1

Simply trying to list files from a remote FTP folder which contains only one file (/public_html/Data/ ['TestFile.txt']). os.walk simply returns the same filename over and over in a endless loop until I don't manually interrupt. Code is:

import ftptool as f
a_host = f.FTPHost.connect("SomeFTPSite", user="User", password="Pass")
for (dirname, subdirs, files) in a_host.walk("/public_html/Data"):
    print (dirname, files)

Output looks like this:

/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']

/// Manually interrupted at this point///

Vivek
  • 19
  • 2
  • Could it be a bug in the library? It's difficult for anyone to reproduce as they would have to set up an ftp site with the same directory structure. – Paul Rooney Aug 18 '17 at 05:11

1 Answers1

0

I don't know for sure, but have a look at subdirs. The FTP server may be returning '.' on the listing, and looking at ftptool code, it may recur over it again and again.

Alexcomps
  • 43
  • 1
  • 4