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:
Goffi 2014-04-19 19:19:19 +02:00
commit 501bc92528

View file

@ -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 @@ PLUGIN_INFO = {
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 @@ class XEP_0055(object):
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 @@ class XEP_0055(object):
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