[Tutor] Successfully trapping the [505 file not found] error

Tim Johnson tim at johnsons-web.com
Thu May 27 00:32:22 CEST 2010


Using Python 2.6.2 on Slackware 13.0 32-bit.
I'm using Python as a command-line application to do an FTP download
which processes a file of jpg filenames, downloading each. Not all
of the file names can be found.

I'm having a problem trapping *all* of the file not found errors.
As an example my application (which is heavily logged) will
successfully handle the 'not found' exeception multiples of time,
continuing with the download process, and then inexplicably (to me)
fails.

What follows is the exception handling snippet:
## ------------------------------------------------------------------
except ftplib.error_perm, e:
    msg = "Couldn't get %s ---- %s" % (fname,str(sys.exc_info()[1]))
        log.add(msg)
        more-code-follows
## ------------------------------------------------------------------
When the code above is successful, the application simply
logs the exception and continues.
When the code above fails the traceback is as follows:

## ------------------------------------------------------------------
Traceback (most recent call last):                                         
<... traceback stack of program locations removed ...>
error_perm: 550 file not found.
ERROR MESSAGE: 550 file not found.
ERROR TYPE: <class 'ftplib.error_perm'>
## ------------------------------------------------------------------

Is there something that can improve my error handling process here
so that my application safely and consistantly continues downloading
so that the entire download process is completed?

-- 
Tim 
tim at johnsons-web.com or akwebsoft.com
http://www.akwebsoft.com


More information about the Tutor mailing list