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
|
|
@ -22,7 +22,8 @@ from sat.core import exceptions
|
|||
from sat.core.constants import Const as C
|
||||
from sat.memory.persistent import PersistentBinaryDict
|
||||
from sat.tools import xml_tools
|
||||
from logging import debug, info, warning, error
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
from twisted.words.xish import domish
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.words.protocols.jabber.error import StanzaError
|
||||
|
|
@ -53,7 +54,7 @@ class XEP_0048(object):
|
|||
URL_ATTRS = ('name',)
|
||||
|
||||
def __init__(self, host):
|
||||
info(_("Bookmarks plugin initialization"))
|
||||
log.info(_("Bookmarks plugin initialization"))
|
||||
self.host = host
|
||||
# self.__menu_id = host.registerCallback(self._bookmarksMenu, with_data=True)
|
||||
self.__bm_save_id = host.registerCallback(self._bookmarksSaveCb, with_data=True)
|
||||
|
|
@ -69,7 +70,7 @@ class XEP_0048(object):
|
|||
try:
|
||||
self.host.plugins[C.TEXT_CMDS].registerTextCommands(self)
|
||||
except KeyError:
|
||||
info(_("Text commands not available"))
|
||||
log.info(_("Text commands not available"))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def profileConnected(self, profile):
|
||||
|
|
@ -106,7 +107,7 @@ class XEP_0048(object):
|
|||
bookmarks_private_xml = yield self.private_plg.privateXMLGet('storage', NS_BOOKMARKS, profile)
|
||||
data = client.bookmarks_private = self._bookmarkElt2Dict(bookmarks_private_xml)
|
||||
except (StanzaError, AttributeError):
|
||||
info(_("Private XML storage not available"))
|
||||
log.info(_("Private XML storage not available"))
|
||||
data = client.bookmarks_private = None
|
||||
elif storage_type == 'pubsub':
|
||||
raise NotImplementedError
|
||||
|
|
@ -147,7 +148,7 @@ class XEP_0048(object):
|
|||
try:
|
||||
room_jid = jid.JID(conference_elt[XEP_0048.MUC_KEY])
|
||||
except KeyError:
|
||||
warning ("invalid bookmark found, igoring it:\n%s" % conference_elt.toXml())
|
||||
log.warning ("invalid bookmark found, igoring it:\n%s" % conference_elt.toXml())
|
||||
continue
|
||||
|
||||
data = conf_data[room_jid] = {}
|
||||
|
|
@ -166,7 +167,7 @@ class XEP_0048(object):
|
|||
try:
|
||||
url = url_elt[XEP_0048.URL_KEY]
|
||||
except KeyError:
|
||||
warning ("invalid bookmark found, igoring it:\n%s" % url_elt.toXml())
|
||||
log.warning ("invalid bookmark found, igoring it:\n%s" % url_elt.toXml())
|
||||
continue
|
||||
data = url_data[url] = {}
|
||||
for attr in XEP_0048.URL_ATTRS:
|
||||
|
|
@ -215,12 +216,12 @@ class XEP_0048(object):
|
|||
room_jid_s, nick = data['index'].split(' ', 1)
|
||||
room_jid = jid.JID(room_jid_s)
|
||||
except (KeyError, RuntimeError):
|
||||
warning(_("No room jid selected"))
|
||||
log.warning(_("No room jid selected"))
|
||||
return {}
|
||||
|
||||
d = self.host.plugins['XEP-0045'].join(room_jid, nick, {}, profile_key=profile)
|
||||
def join_eb(failure):
|
||||
warning("Error while trying to join room: %s" % failure)
|
||||
log.warning("Error while trying to join room: %s" % failure)
|
||||
# FIXME: failure are badly managed in plugin XEP-0045. Plugin XEP-0045 need to be fixed before managing errors correctly here
|
||||
return {}
|
||||
d.addCallbacks(lambda dummy: {}, join_eb)
|
||||
|
|
@ -303,8 +304,8 @@ class XEP_0048(object):
|
|||
storage_type = 'private'
|
||||
else:
|
||||
storage_type = 'local'
|
||||
warning(_("Bookmarks will be local only"))
|
||||
info(_('Type selected for "auto" storage: %s') % storage_type)
|
||||
log.warning(_("Bookmarks will be local only"))
|
||||
log.info(_('Type selected for "auto" storage: %s') % storage_type)
|
||||
|
||||
if storage_type == 'local':
|
||||
client.bookmarks_local[type_][location] = data
|
||||
|
|
@ -338,7 +339,7 @@ class XEP_0048(object):
|
|||
del client.bookmarks_local[type_][location]
|
||||
yield client.bookmarks_local.force(type_)
|
||||
except KeyError:
|
||||
debug("Bookmark is not present in local storage")
|
||||
log.debug("Bookmark is not present in local storage")
|
||||
|
||||
if storage_type in ('all', 'private'):
|
||||
bookmarks = yield self._getServerBookmarks('private', client.profile)
|
||||
|
|
@ -347,7 +348,7 @@ class XEP_0048(object):
|
|||
bookmark_elt = self._dict2BookmarkElt(type_, bookmarks)
|
||||
yield self._setServerBookmarks('private', bookmark_elt, client.profile)
|
||||
except KeyError:
|
||||
debug("Bookmark is not present in private storage")
|
||||
log.debug("Bookmark is not present in private storage")
|
||||
|
||||
if storage_type == 'pubsub':
|
||||
raise NotImplementedError
|
||||
|
|
@ -422,13 +423,13 @@ class XEP_0048(object):
|
|||
@command (group): [autojoin | remove]
|
||||
- autojoin: join room automatically on connection
|
||||
"""
|
||||
debug("Catched bookmark command")
|
||||
log.debug("Catched bookmark command")
|
||||
client = self.host.getClient(profile)
|
||||
txt_cmd = self.host.plugins[C.TEXT_CMDS]
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
#/bookmark command does nothing if we are not on a group chat
|
||||
info("Ignoring /bookmark command on a non groupchat message")
|
||||
log.info("Ignoring /bookmark command on a non groupchat message")
|
||||
return True
|
||||
|
||||
options = mess_data["unparsed"].strip().split()
|
||||
|
|
|
|||
Loading…
Reference in a new issue