Mercurial > libervia-backend
diff src/plugins/plugin_xep_0055.py @ 993:301b342c697a
core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Apr 2014 19:19:19 +0200 |
parents | 40ad5a344332 |
children | 16484ebb695b |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0055.py Sat Apr 19 16:48:26 2014 +0200 +++ b/src/plugins/plugin_xep_0055.py Sat Apr 19 19:19:19 2014 +0200 @@ -18,9 +18,11 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from sat.core.i18n import _, D_ -from logging import debug, info, warning, error +from sat.core.log import getLogger +log = getLogger(__name__) from twisted.words.protocols.jabber.xmlstream import IQ from twisted.words.protocols.jabber import jid +from twisted.internet import defer from wokkel import data_form from sat.core.exceptions import DataError from sat.memory.memory import Sessions @@ -42,7 +44,7 @@ class XEP_0055(object): def __init__(self, host): - info(_("Jabber search plugin initialization")) + log.info(_("Jabber search plugin initialization")) self.host = host host.bridge.addMethod("getSearchUI", ".plugin", in_sign='ss', out_sign='s', method=self._getSearchUI, @@ -105,26 +107,26 @@ try: query_elts = answer.elements('jabber:iq:search', 'query').next() except StopIteration: - info(_("No query element found")) + log.info(_("No query element found")) raise DataError # FIXME: StanzaError is probably more appropriate, check the RFC try: form_elt = query_elts.elements(data_form.NS_X_DATA, 'x').next() except StopIteration: - info(_("No data form found")) + log.info(_("No data form found")) raise NotImplementedError("Only search through data form is implemented so far") parsed_form = data_form.Form.fromElement(form_elt) return xml_tools.dataForm2XMLUI(parsed_form, "") def _fieldsErr(self, failure, profile): """ Called when something is wrong with fields request """ - info(_("Fields request failure: %s") % str(failure.value)) + log.info(_("Fields request failure: %s") % str(failure.value)) return failure def _xmluiSearchRequest(self, raw_data, profile): try: session_data = self._sessions.profileGet(raw_data["session_id"], profile) except KeyError: - warning ("session id doesn't exist, session has probably expired") + log.warning ("session id doesn't exist, session has probably expired") # TODO: send error dialog return defer.succeed({}) @@ -163,16 +165,16 @@ try: query_elts = answer.elements('jabber:iq:search', 'query').next() except StopIteration: - info(_("No query element found")) + log.info(_("No query element found")) raise DataError # FIXME: StanzaError is probably more appropriate, check the RFC try: form_elt = query_elts.elements(data_form.NS_X_DATA, 'x').next() except StopIteration: - info(_("No data form found")) + log.info(_("No data form found")) raise NotImplementedError("Only search through data form is implemented so far") return xml_tools.dataFormResult2XMLUI(form_elt) def _searchErr(self, failure, profile): """ Called when something is wrong with search request """ - info(_("Search request failure: %s") % str(failure.value)) + log.info(_("Search request failure: %s") % str(failure.value)) return failure