core, plugins: host.getClient now raise an exception instead of returning None when no profile is found, plugins have been adapted consequently and a bit cleaned
This commit is contained in:
parent
ed9df2984d
commit
a6897c76e0
1 changed files with 25 additions and 140 deletions
|
|
@ -26,7 +26,6 @@ from twisted.words.xish import domish
|
|||
|
||||
from twisted.internet import reactor
|
||||
|
||||
from wokkel import compat
|
||||
from wokkel.xmppim import RosterItem
|
||||
|
||||
from sat.bridge.DBus import DBusBridge
|
||||
|
|
@ -40,7 +39,6 @@ from sat.core import xmpp
|
|||
from sat.core import exceptions
|
||||
from sat.core.constants import Const as C
|
||||
from sat.memory.memory import Memory
|
||||
from sat.tools.xml_tools import tupleList2dataForm
|
||||
from sat.tools.misc import TriggerManager
|
||||
from glob import glob
|
||||
from uuid import uuid4
|
||||
|
|
@ -295,8 +293,6 @@ class SAT(service.Service):
|
|||
|
||||
def getContacts(self, profile_key):
|
||||
client = self.getClient(profile_key)
|
||||
if not client:
|
||||
raise exceptions.ProfileUnknownError(_('Asking contacts for a non-existant profile'))
|
||||
ret = []
|
||||
for item in client.roster.getItems(): # we get all items for client's roster
|
||||
# and convert them to expected format
|
||||
|
|
@ -306,9 +302,7 @@ class SAT(service.Service):
|
|||
|
||||
def getContactsFromGroup(self, group, profile_key):
|
||||
client = self.getClient(profile_key)
|
||||
if not client:
|
||||
raise exceptions.ProfileUnknownError(_("Asking group's contacts for a non-existant profile"))
|
||||
return [jid.full() for jid in client.roster.getJidsFromGroup(group)]
|
||||
return [jid_.full() for jid_ in client.roster.getJidsFromGroup(group)]
|
||||
|
||||
def purgeClient(self, profile):
|
||||
"""Remove reference to a profile client and purge cache
|
||||
|
|
@ -350,7 +344,7 @@ class SAT(service.Service):
|
|||
@return: client or None if it doesn't exist"""
|
||||
profile = self.memory.getProfileName(profile_key)
|
||||
if not profile:
|
||||
return None
|
||||
raise exceptions.ProfileKeyUnknownError
|
||||
return self.profiles[profile]
|
||||
|
||||
def getClients(self, profile_key):
|
||||
|
|
@ -443,8 +437,6 @@ class SAT(service.Service):
|
|||
def getWaitingConf(self, profile_key=None):
|
||||
assert(profile_key)
|
||||
client = self.getClient(profile_key)
|
||||
if not client:
|
||||
raise exceptions.ProfileNotInCacheError
|
||||
ret = []
|
||||
for conf_id in client._waiting_conf:
|
||||
conf_type, data = client._waiting_conf[conf_id][:2]
|
||||
|
|
@ -769,8 +761,6 @@ class SAT(service.Service):
|
|||
"""
|
||||
# FIXME: use XMLUI and *callback methods for dialog
|
||||
client = self.getClient(profile)
|
||||
if not client:
|
||||
raise exceptions.ProfileUnknownError(_("Asking confirmation a non-existant profile"))
|
||||
if conf_id in client._waiting_conf:
|
||||
error(_("Attempt to register two callbacks for the same confirmation"))
|
||||
else:
|
||||
|
|
@ -780,8 +770,6 @@ class SAT(service.Service):
|
|||
def confirmationAnswer(self, conf_id, accepted, data, profile):
|
||||
"""Called by frontends to answer confirmation requests"""
|
||||
client = self.getClient(profile)
|
||||
if not client:
|
||||
raise exceptions.ProfileUnknownError(_("Confirmation answer from a non-existant profile"))
|
||||
debug(_("Received confirmation answer for conf_id [%(conf_id)s]: %(success)s") % {'conf_id': conf_id, 'success': _("accepted") if accepted else _("refused")})
|
||||
if conf_id not in client._waiting_conf:
|
||||
error(_("Received an unknown confirmation (%(id)s for %(profile)s)") % {'id': conf_id, 'profile': profile})
|
||||
|
|
@ -793,15 +781,11 @@ class SAT(service.Service):
|
|||
def registerProgressCB(self, progress_id, CB, profile):
|
||||
"""Register a callback called when progress is requested for id"""
|
||||
client = self.getClient(profile)
|
||||
if not client:
|
||||
raise exceptions.ProfileUnknownError
|
||||
client._progress_cb_map[progress_id] = CB
|
||||
|
||||
def removeProgressCB(self, progress_id, profile):
|
||||
"""Remove a progress callback"""
|
||||
client = self.getClient(profile)
|
||||
if not client:
|
||||
raise exceptions.ProfileUnknownError
|
||||
if progress_id not in client._progress_cb_map:
|
||||
error(_("Trying to remove an unknow progress callback"))
|
||||
else:
|
||||
|
|
@ -813,8 +797,6 @@ class SAT(service.Service):
|
|||
data['size'] : end_position
|
||||
"""
|
||||
client = self.getClient(profile)
|
||||
if not profile:
|
||||
raise exceptions.ProfileNotInCacheError
|
||||
data = {}
|
||||
try:
|
||||
client._progress_cb_map[progress_id](progress_id, data, profile)
|
||||
|
|
|
|||
Loading…
Reference in a new issue