core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
This commit is contained in:
parent
dc5c042fe7
commit
501bc92528
1 changed files with 707 additions and 941 deletions
|
|
@ -18,17 +18,14 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sat.core.i18n import _
|
||||
from sat.core import exceptions
|
||||
from sat.core.constants import Const as C
|
||||
from logging import debug, info, error
|
||||
from twisted.internet import protocol
|
||||
from twisted.words.protocols.jabber import client, jid
|
||||
from twisted.words.protocols.jabber import error as jab_error
|
||||
import twisted.internet.error
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
from twisted.words.xish import domish
|
||||
|
||||
from wokkel import disco, pubsub
|
||||
from wokkel.formats import Mood
|
||||
from sat.core import exceptions
|
||||
|
||||
NS_USER_MOOD = 'http://jabber.org/protocol/mood'
|
||||
|
||||
|
|
@ -47,7 +44,7 @@ PLUGIN_INFO = {
|
|||
class XEP_0163(object):
|
||||
|
||||
def __init__(self, host):
|
||||
info(_("PEP plugin initialization"))
|
||||
log.info(_("PEP plugin initialization"))
|
||||
self.host = host
|
||||
self.pep_events = set()
|
||||
self.pep_out_cb = {}
|
||||
|
|
@ -95,25 +92,25 @@ class XEP_0163(object):
|
|||
"""
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
if not profile:
|
||||
error(_('Trying to send personal event with an unknown profile key [%s]') % profile_key)
|
||||
log.error(_('Trying to send personal event with an unknown profile key [%s]') % profile_key)
|
||||
raise exceptions.ProfileUnknownError
|
||||
if not event_type in self.pep_out_cb.keys():
|
||||
error(_('Trying to send personal event for an unknown type'))
|
||||
raise DataError('Type unknown')
|
||||
log.error(_('Trying to send personal event for an unknown type'))
|
||||
raise exceptions.DataError('Type unknown')
|
||||
return self.pep_out_cb[event_type](data, profile)
|
||||
|
||||
def userMoodCB(self, itemsEvent, profile):
|
||||
if not itemsEvent.items:
|
||||
debug(_("No item found"))
|
||||
log.debug(_("No item found"))
|
||||
return
|
||||
try:
|
||||
mood_elt = [child for child in itemsEvent.items[0].elements() if child.name == "mood"][0]
|
||||
except IndexError:
|
||||
error(_("Can't find mood element in mood event"))
|
||||
log.error(_("Can't find mood element in mood event"))
|
||||
return
|
||||
mood = Mood.fromXml(mood_elt)
|
||||
if not mood:
|
||||
debug(_("No mood found"))
|
||||
log.debug(_("No mood found"))
|
||||
return
|
||||
self.host.bridge.personalEvent(itemsEvent.sender.full(), "MOOD", {"mood": mood.value or "", "text": mood.text or ""}, profile)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue