imapserver.py: Make severity var available where it is needed

We we using the variable 'severity' in a few places to throw
OfflineImapErrorrs of severity REPO. Somehow, that variable is now not
accessible in all places that refer to it, so we move where it is
defined to before all the 'if' checks which might make use of it.

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-06-27 11:08:54 +02:00 committed by Nicolas Sebrecht
parent 9d95d7bc62
commit 928c363044

View File

@ -292,9 +292,9 @@ class IMAPServer:
if(self.connectionlock.locked()): if(self.connectionlock.locked()):
self.connectionlock.release() self.connectionlock.release()
severity = OfflineImapError.ERROR.REPO
if type(e) == gaierror: if type(e) == gaierror:
#DNS related errors. Abort Repo sync #DNS related errors. Abort Repo sync
severity = OfflineImapError.ERROR.REPO
#TODO: special error msg for e.errno == 2 "Name or service not known"? #TODO: special error msg for e.errno == 2 "Name or service not known"?
reason = "Could not resolve name '%s' for repository "\ reason = "Could not resolve name '%s' for repository "\
"'%s'. Make sure you have configured the ser"\ "'%s'. Make sure you have configured the ser"\
@ -328,8 +328,7 @@ class IMAPServer:
if str(e)[:24] == "can't open socket; error": if str(e)[:24] == "can't open socket; error":
raise OfflineImapError("Could not connect to remote server '%s' "\ raise OfflineImapError("Could not connect to remote server '%s' "\
"for repository '%s'. Remote does not answer." "for repository '%s'. Remote does not answer."
% (self.hostname, self.reposname), % (self.hostname, self.reposname), severity)
OfflineImapError.ERROR.REPO)
else: else:
# re-raise all other errors # re-raise all other errors
raise raise