(self)
Execute the main isbg process.

        It should be called to process the IMAP account. It returns a
        exitcode if its called from the command line and have the --exitcodes
        param.
Execute the main isbg process.
Execute the main isbg process .
def do_isbg(self):
        """Execute the main isbg process.

        It should be called to process the IMAP account. It returns a
        exitcode if its called from the command line and have the --exitcodes
        param.
        """
        if self.delete and not self.gmail and \
                "\\Deleted" not in self.spamflags:
            self.spamflags.append("\\Deleted")

        if self.trackfile is None:
            self.trackfile = ISBG.set_filename(self.imapsets, "track")

        if self.passwdfilename is None:
            self.passwdfilename = ISBG.set_filename(self.imapsets, "password")

        self.logger.debug(__("Lock file is {}".format(self.lockfilename)))
        self.logger.debug(__("Trackfile starts with {}".format(self.trackfile))
                          )
        self.logger.debug(__(
            "Password file is {}".format(self.passwdfilename)))
        self.logger.debug(__("SpamFlags are {}".format(self.spamflags)))

        # Acquire lockfilename or exit
        if self.ignorelockfile:
            self.logger.debug("Lock file is ignored. Continue.")
        else:
            self._do_lockfile_or_raise()

        # Figure out the password
        if self.imapsets.passwd is None:
            self._do_get_password()

        # ***** Main code starts here *****

        # Connection with the imaplib server
        self.do_imap_login()

        # Should we save it?
        if self.savepw:
            self._do_save_password()

        if self.imaplist:
            # List imap directories
            self.do_list_imap()
        else:
            # Spamassasin training and processing:
            proc = self.do_spamassassin()

        # sign off
        self.do_imap_logout()

        if self.exitcodes and __name__ == '__main__':
            if not self.teachonly:
                if proc.numspam == 0:
                    return __exitcodes__['newmsgs']
                if proc.numspam == proc.nummsg:
                    return __exitcodes__['newspam']
                return __exitcodes__['newmsgspam']

            return __exitcodes__['ok']
def do_isbg ( self ) : if self . delete and not self . gmail and "\\Deleted" not in self . spamflags : self . spamflags . append ( "\\Deleted" ) if self . trackfile is None : self . trackfile = ISBG . set_filename ( self . imapsets , "track" ) if self . passwdfilename is None : self . passwdfilename = ISBG . set_filename ( self . imapsets , "password" ) self . logger . debug ( __ ( "Lock file is {}" . format ( self . lockfilename ) ) ) self . logger . debug ( __ ( "Trackfile starts with {}" . format ( self . trackfile ) ) ) self . logger . debug ( __ ( "Password file is {}" . format ( self . passwdfilename ) ) ) self . logger . debug ( __ ( "SpamFlags are {}" . format ( self . spamflags ) ) ) # Acquire lockfilename or exit if self . ignorelockfile : self . logger . debug ( "Lock file is ignored. Continue." ) else : self . _do_lockfile_or_raise ( ) # Figure out the password if self . imapsets . passwd is None : self . _do_get_password ( ) # ***** Main code starts here ***** # Connection with the imaplib server self . do_imap_login ( ) # Should we save it? if self . savepw : self . _do_save_password ( ) if self . imaplist : # List imap directories self . do_list_imap ( ) else : # Spamassasin training and processing: proc = self . do_spamassassin ( ) # sign off self . do_imap_logout ( ) if self . exitcodes and __name__ == '__main__' : if not self . teachonly : if proc . numspam == 0 : return __exitcodes__ [ 'newmsgs' ] if proc . numspam == proc . nummsg : return __exitcodes__ [ 'newspam' ] return __exitcodes__ [ 'newmsgspam' ] return __exitcodes__ [ 'ok' ]