I want to use ftputil instead of ftplib in python.
On a public ftp server everything works fine with both libraries:
host = 'ftp.avm.de'
user = 'anonymous'
passwd = ''
import ftputil
with ftputil.FTPHost(host, user, passwd) as ftp:
print(ftp.getcwd(), ftp.listdir('.'))
import ftplib
with ftplib.FTP(host, user, passwd) as ftp:
print(ftp.pwd(), ftp.nlst('.'))
output:
/ ['archive', 'fritzbox', 'fritzpowerline', 'fritzwlan']
/ ['archive', 'fritzbox', 'fritzpowerline', 'fritzwlan']
If I do it on a ftp server (Windows CE6) in my local network, the output of ftputil is empty while ftplib correctly lists all files:
/ []
/ ['1', '2', '3']
What am i missing?
The observation above could be because of https://ftputil.sschwarzer.net/trac/ticket/110. Directories and files will be missing from the
FTPHost.listdirresult if the FTP server doesn't understand the-aoption for listing hidden directories and files and interprets the option as a directory or file to list.Try setting
use_list_a_optiontoFalseafter creating theFTPHostinstance:In a future ftputil version 4.x,
use_list_a_optionwill default toFalseto avoid this problem (see the linked ticket). I didn't want to make this change earlier in a bugfix release because this is a backward-incompatible change and may break currently working code.