Jon Martin
Jon Martin

Reputation: 3392

Python ftplib error

I have a python program which basically just moves files around between remote FTP server and local machine. I have a bit of code to delete a file on the FTP site, similar to

try:
    ftplib_obj.delete(some_file)
except ftplib.error_perm, e:
    print str(e)
    raise

I'm getting a "550: Delete operation failed", and I have no idea why. The most baffling thing is that I can log in manually, with the same credentials, and delete the file no problem. Any idea what the issue could be, or at least, is there a way I can get a more descriptive error message?

NOTE: I've gone through some possible causes of this error, such as file not existing or permission denied, but none of these apply.

Upvotes: 1

Views: 1800

Answers (1)

Rg Glpj
Rg Glpj

Reputation: 443

You can do couple of things:

  1. Set debug level (using ftplib_obj.set_debuglevel(9)), this might give some insights into the issue.
  2. Run the FTP command you run in interactive mode using the function

    ftplib_obj.voidcmd('DEL *filename*')  
    

Upvotes: 1

Related Questions