Handle OfflineImapError of severity REPO and CRIT

By aborting the account syncing, the looping and logging an error
message. We will introduce a ui.error() rather than a ui.warn() function
which saves all Exceptions in a Queue and outputs them at the end of the
program.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-05-04 16:45:27 +02:00 committed by Nicolas Sebrecht
parent 0f45d89e34
commit 4608d14836

View File

@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from offlineimap import threadutil, mbnames, CustomConfig
from offlineimap import threadutil, mbnames, CustomConfig, OfflineImapError
from offlineimap.repository import Repository
from offlineimap.ui import getglobalui
from offlineimap.threadutil import InstanceLimitedThread
@ -202,21 +202,28 @@ class SyncableAccount(Account):
self.localrepos = Repository(self, 'local')
self.statusrepos = Repository(self, 'status')
# Might need changes here to ensure that one account sync does
# not crash others...
# Loop account synchronization if needed
looping = 1
looping = True
while looping:
try:
try:
self.sync(siglistener)
except (KeyboardInterrupt, SystemExit):
raise
except OfflineImapError, e:
self.ui.warn(e.reason)
#stop looping and bubble up Exception if needed
if e.severity >= OfflineImapError.ERROR.REPO:
looping = 0
if e.severity > OfflineImapError.ERROR.REPO:
raise
except:
self.ui.warn("Error occured attempting to sync account " + self.name \
+ ": " + traceback.format_exc())
self.ui.warn("Error occured attempting to sync "\
"account '%s':\n"% (self, traceback.format_exc()))
finally:
looping = self.refreshperiod and self.sleeper(siglistener) != 2
looping = looping and \
self.refreshperiod and \
self.sleeper(siglistener) != 2
self.ui.acctdone(self.name)