简体   繁体   中英

Is there a rich ftp client library for Python?

I'm familiar with ftplib and it works great for simple interface but I need file properties and basically a rich ftp client. does anyone know of a good ftp client library?

Use the MLSD command. You have to parse it yourself but it's fairly easy.

# Note that portions of MLSD data are case insensitive...
def parseinfo(info):
    for fact in info.split(';'):
        if not fact:
            continue
        name, value = fact.split('=', 1)
        yield name.lower(), value

ftp = ftplib.FTP(host, user, passwd)
dirinfo = {}
def callback(line):
    info, fname = line.split(' ', 1)
    dirinfo[fname] = dict(parseinfo(info))
ftp.retrlines('MLSD {}'.format(path), callback)
print(dirinfo)

That's about as rich as FTP gets.

The ftputil could be what you are looking for:

The FTPHost objects generated with ftputil allow many operations similar to those of os and os.path.

The API supports well file information gathering .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM