Use the exceptions from `deluge.errors`.

This commit is contained in:
Pedro Algarvio 2010-12-21 02:54:53 +00:00
parent b2a16a0240
commit 67ff83360f
1 changed files with 2 additions and 8 deletions

View File

@ -40,7 +40,7 @@ import logging
import deluge.component as component import deluge.component as component
import deluge.configmanager as configmanager import deluge.configmanager as configmanager
import deluge.error from deluge.error import BadLoginError, AuthenticationRequired
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -51,12 +51,6 @@ AUTH_LEVEL_ADMIN = 10
AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL
class BadLoginError(deluge.error.DelugeError):
pass
class PasswordRequired(BadLoginError):
pass
class AuthManager(component.Component): class AuthManager(component.Component):
def __init__(self): def __init__(self):
component.Component.__init__(self, "AuthManager") component.Component.__init__(self, "AuthManager")
@ -108,7 +102,7 @@ class AuthManager(component.Component):
# Return the users auth level # Return the users auth level
return auth_level return auth_level
elif not password and self.__auth[username][0]: elif not password and self.__auth[username][0]:
raise PasswordRequired("Password is required") raise AuthenticationRequired("Password is required", username)
else: else:
raise BadLoginError("Password does not match") raise BadLoginError("Password does not match")