diff src/plugins/plugin_adhoc_dbus.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 1a759096ccbd
children 069ad98b360d
line wrap: on
line diff
--- a/src/plugins/plugin_adhoc_dbus.py	Sat Apr 19 16:48:26 2014 +0200
+++ b/src/plugins/plugin_adhoc_dbus.py	Sat Apr 19 19:19:19 2014 +0200
@@ -19,7 +19,8 @@
 
 from sat.core.i18n import _, D_
 from sat.core.constants import Const as C
-from logging import debug, info, warning, error
+from sat.core.log import getLogger
+log = getLogger(__name__)
 from twisted.words.protocols.jabber import jid
 from twisted.internet import defer, reactor
 from wokkel import data_form
@@ -53,7 +54,7 @@
 class AdHocDBus(object):
 
     def __init__(self, host):
-        info(_("plugin Ad-Hoc D-Bus initialization"))
+        log.info(_("plugin Ad-Hoc D-Bus initialization"))
         self.host = host
         host.bridge.addMethod("adHocDBusAddAuto", ".plugin", in_sign='sasasasasasass', out_sign='(sa(sss))',
                               method=self._adHocDBusAddAuto,
@@ -97,7 +98,7 @@
 
     @defer.inlineCallbacks
     def _introspect(self, methods, bus_name, proxy):
-        debug("introspecting path [%s]" % proxy.object_path)
+        log.debug("introspecting path [%s]" % proxy.object_path)
         introspect_xml = yield self._DBusIntrospect(proxy)
         el = etree.fromstring(introspect_xml)
         for node in el.iterchildren('node', 'interface'):
@@ -108,13 +109,13 @@
             elif node.tag == 'interface':
                 name = node.get('name')
                 if any(name.startswith(ignored) for ignored in IGNORED_IFACES_START):
-                    debug('interface [%s] is ignored' % name)
+                    log.debug('interface [%s] is ignored' % name)
                     continue
-                debug("introspecting interface [%s]" % name)
+                log.debug("introspecting interface [%s]" % name)
                 for method in node.iterchildren('method'):
                     if self._acceptMethod(method):
                         method_name = method.get('name')
-                        debug("method accepted: [%s]" % method_name)
+                        log.debug("method accepted: [%s]" % method_name)
                         methods.add((proxy.object_path, name, method_name))
 
     def _adHocDBusAddAuto(self, prog_name, allowed_jids, allowed_groups, allowed_magics, forbidden_jids, forbidden_groups, flags, profile_key):
@@ -125,13 +126,13 @@
         bus_names = yield self._DBusListNames()
         bus_names = [bus_name for bus_name in bus_names if '.' + prog_name in bus_name]
         if not bus_names:
-            info("Can't find any bus for [%s]" % prog_name)
+            log.info("Can't find any bus for [%s]" % prog_name)
             return
         bus_names.sort()
         for bus_name in bus_names:
             if bus_name.endswith(prog_name):
                 break
-        info("bus name found: [%s]" % bus_name)
+        log.info("bus name found: [%s]" % bus_name)
         proxy = self.session_bus.get_object(bus_name, '/', introspect=False)
         methods = set()