Possible fix for UNAVAILABLE handling

Dario Corti <[email protected]>
Newsgroups gmane.mail.getmail.user
Message-ID <[email protected]>
Hi, I've been having issues with IDLE not working properly and getmail
randomly closing every x hours. I traced it back to an occasional
negative answer to AUTHENTICATE, but it seems getmail is treating the
case as a permanent error, like an unsupported authentication scheme,
while in my case I think it's something related to server routine
maintenance.

The errors are usually something like:

credential/login error ([UNAVAILABLE] Account is temporarily unavailable.)
credential/login error ([UNAVAILABLE] Internal error occurred. Refer to
server log for more information.)

Now, RFC 5530 says UNAVAILABLE is a "Temporary failure because a
subsystem is down", so I propose the following change:

In _retrieverbases.py:

def initialize(self, options):
[...]
            except imaplib.IMAP4.error, o:
+               if o.startswith('[UNAVAILABLE]'):
+                   raise getmailLoginRefusedError(o)
                raise getmailCredentialError(o)

In getmail:

def go(configs, idle):
[...]
        except getmailCredentialError, o:
            errorexit = True
            retriever.abort()
            log.error('%s: credential/login error (%s)\n' % (configfile, o))
            if options['logfile']:
                options['logfile'].write('credential/login error (%s)' % o)

+       except getmailLoginRefusedError, o:
+           retriever.abort()
+           log.error('%s: login refused error (%s)\n' % (configfile, o))
+           if options['logfile']:
+               options['logfile'].write('login refused error (%s)' % o)

So, we use getmailLoginRefusedError ("Error raised when the server is
just refusing logins due to reasons other than credential problems (when
that is possible to detect):  server too busy, service shutting down,
etc.") to avoid exiting from the idle loop.

My two cents, btw (I opened getmail source code today for the first time).

-- 
[email protected]
[email protected]
OpenPGP Key: 752A92A1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.