Mercurial > libervia-backend
comparison src/plugins/plugin_misc_xmllog.py @ 594:e629371a28d3
Fix pep8 support in src/plugins.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:35 +0100 |
parents | beaf6bec2fcd |
children | 84a6e83157c2 |
comparison
equal
deleted
inserted
replaced
593:70bae685d05c | 594:e629371a28d3 |
---|---|
22 from logging import debug, info, error | 22 from logging import debug, info, error |
23 from twisted.words.protocols.jabber.xmlstream import XmlStream | 23 from twisted.words.protocols.jabber.xmlstream import XmlStream |
24 from twisted.words.xish import domish | 24 from twisted.words.xish import domish |
25 | 25 |
26 PLUGIN_INFO = { | 26 PLUGIN_INFO = { |
27 "name": "Raw XML log Plugin", | 27 "name": "Raw XML log Plugin", |
28 "import_name": "XmlLog", | 28 "import_name": "XmlLog", |
29 "type": "Misc", | 29 "type": "Misc", |
30 "protocols": [], | 30 "protocols": [], |
31 "dependencies": [], | 31 "dependencies": [], |
32 "main": "XmlLog", | 32 "main": "XmlLog", |
33 "handler": "no", | 33 "handler": "no", |
34 "description": _("""Send raw XML logs to bridge""") | 34 "description": _("""Send raw XML logs to bridge""") |
35 } | 35 } |
36 | |
36 | 37 |
37 class LoggingXmlStream(XmlStream): | 38 class LoggingXmlStream(XmlStream): |
38 """This class send the raw XML to the Bridge, for logging purpose""" | 39 """This class send the raw XML to the Bridge, for logging purpose""" |
39 | 40 |
40 def send(self, obj): | 41 def send(self, obj): |
41 if isinstance(obj,basestring): | 42 if isinstance(obj, basestring): |
42 log=unicode(obj) | 43 log = unicode(obj) |
43 elif isinstance(obj, domish.Element): | 44 elif isinstance(obj, domish.Element): |
44 log=obj.toXml() | 45 log = obj.toXml() |
45 else: | 46 else: |
46 error(_('INTERNAL ERROR: Unmanaged XML type')) | 47 error(_('INTERNAL ERROR: Unmanaged XML type')) |
47 self._host.bridge.xmlLog("OUT", log, self._profile) | 48 self._host.bridge.xmlLog("OUT", log, self._profile) |
48 return XmlStream.send(self, obj) | 49 return XmlStream.send(self, obj) |
49 | 50 |
70 | 71 |
71 #parameters | 72 #parameters |
72 host.memory.importParams(self.params) | 73 host.memory.importParams(self.params) |
73 | 74 |
74 #bridge | 75 #bridge |
75 host.bridge.addSignal("xmlLog", ".plugin", signature='sss') #args: direction("IN" or "OUT"), xml_data, profile | 76 host.bridge.addSignal("xmlLog", ".plugin", signature='sss') # args: direction("IN" or "OUT"), xml_data, profile |
76 | 77 |
77 do_log = self.host.memory.getParamA("Xml log", "Debug") | 78 do_log = self.host.memory.getParamA("Xml log", "Debug") |
78 if do_log: | 79 if do_log: |
79 info(_("XML log activated")) | 80 info(_("XML log activated")) |
80 host.trigger.add("XML Initialized", self.logXml) | 81 host.trigger.add("XML Initialized", self.logXml) |