خرید بک لینک

Vote count: 0

Download not working in python?

I've written a simple python program, to get files from FTP location but when executing it's give [Ero 13] Permission denied message.

My code is as follows. Any idea why is this ?

import ftplib from ftplib import FTP, error_perm

def getFTPDir(dirpath):

f = ftplib.FTP(ip, useame, password)

try:
    f.cwd(dirpath)
    nameList = f.nlst()
    oldest = nameList[0]
    newest = nameList[-1]

    newest = oldest

    newDirPath = dirpath +'/'+ newest

    print f.cwd(newDirPath)
    subNameList = f.nlst()

    for i in range (len(subNameList)):
        f.cwd( newDirPath + '/' + str(subNameList[i]) )
        nameList1 = f.nlst()

        filename = nameList1[i]
        print "downloading..............", filename


        f.retrbinary('RETR '+ filename, open(os.path.join(destination,localPath),"wb").write)
        print filename + " downloaded"

        try:
            fhandle = open(filename, 'wb')
            f.retrbinary('RETR ' + filename, fhandle.write)

        except Exception, e:
            print str(e)

        finally:
            fhandle.close()

except error_perm:
    retu

except Exception, e:
    print str(e)

finally: 
    f.close()

asked 35 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 15 تير 1395 ساعت: 16:01

صفحه بندی