From c9144f451b74e4d3cc67935b9e73c662ac870c6e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 07:18:39 +0200 Subject: Hook plugin code cosmetics (2) --- module/plugins/hooks/XMPPInterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index b61428392..e93da98bf 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -59,7 +59,7 @@ class XMPPInterface(IRCInterface, JabberClient): ] - def coreReady(self): + def activate(self): self.new_package = {} self.start() -- cgit v1.2.3 From 5a139055ae658d3a05cbb658cbd66aeae0d01db5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 21:06:10 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/XMPPInterface.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index e93da98bf..053817bef 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -65,7 +65,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.start() - def packageFinished(self, pypack): + def package_finished(self, pypack): try: if self.getConfig('info_pack'): self.announce(_("Package finished: %s") % pypack.name) @@ -73,7 +73,7 @@ class XMPPInterface(IRCInterface, JabberClient): pass - def downloadFinished(self, pyfile): + def download_finished(self, pyfile): try: if self.getConfig('info_file'): self.announce( @@ -200,11 +200,11 @@ class XMPPInterface(IRCInterface, JabberClient): stream.send(m) - def beforeReconnecting(self, ip): + def before_reconnect(self, ip): self.disconnect() - def afterReconnecting(self, ip): + def after_reconnect(self, ip): self.connect() -- cgit v1.2.3 From c1764e2fea0bb05164c83a876e8cd58b97f58f25 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Jun 2015 17:31:38 +0200 Subject: Update all --- module/plugins/hooks/XMPPInterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 053817bef..f93273df4 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -123,7 +123,7 @@ class XMPPInterface(IRCInterface, JabberClient): subject = stanza.get_subject() body = stanza.get_body() t = stanza.get_type() - self.logDebug("Message from %s received." % unicode(stanza.get_from())) + self.logDebug("Message from %s received." % stanza.get_from()) self.logDebug("Body: %s Subject: %s Type: %s" % (body, subject, t)) if t == "headline": -- cgit v1.2.3 From 164512b6a74c94a731fcee7435dce1ccfa2f71e7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:29:50 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/XMPPInterface.py | 53 ++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index f93273df4..847fb26c3 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -92,9 +92,11 @@ class XMPPInterface(IRCInterface, JabberClient): def stream_state_changed(self, state, arg): - """This one is called when the state of stream connecting the component + """ + This one is called when the state of stream connecting the component to a server changes. This will usually be used to let the user - know what is going on.""" + know what is going on. + """ self.logDebug("*** State changed: %s %r ***" % (state, arg)) @@ -111,15 +113,19 @@ class XMPPInterface(IRCInterface, JabberClient): def get_message_handlers(self): - """Return list of (message_type, message_handler) tuples. + """ + Return list of (message_type, message_handler) tuples. The handlers returned will be called when matching message is received - in a client session.""" + in a client session. + """ return [("normal", self.message)] def message(self, stanza): - """Message handler for the component.""" + """ + Message handler for the component. + """ subject = stanza.get_subject() body = stanza.get_body() t = stanza.get_type() @@ -181,7 +187,9 @@ class XMPPInterface(IRCInterface, JabberClient): def announce(self, message): - """ send message to all owners""" + """ + Send message to all owners + """ for user in self.getConfig('owners').split(";"): self.logDebug("Send message to", user) @@ -209,42 +217,53 @@ class XMPPInterface(IRCInterface, JabberClient): class VersionHandler(object): - """Provides handler for a version query. + """ + Provides handler for a version query. This class will answer version query and announce 'jabber:iq:version' namespace - in the client's disco#info results.""" - + in the client's disco#info results. + """ implements(IIqHandlersProvider, IFeaturesProvider) def __init__(self, client): - """Just remember who created this.""" + """ + Just remember who created this. + """ self.client = client def get_features(self): - """Return namespace which should the client include in its reply to a - disco#info query.""" + """ + Return namespace which should the client include in its reply to a + disco#info query. + """ return ["jabber:iq:version"] def get_iq_get_handlers(self): - """Return list of tuples (element_name, namespace, handler) describing - handlers of stanzas""" + """ + Return list of tuples (element_name, namespace, handler) describing + handlers of stanzas + """ return [("query", "jabber:iq:version", self.get_version)] def get_iq_set_handlers(self): - """Return empty list, as this class provides no stanza handler.""" + """ + Return empty list, as this class provides no stanza handler. + """ return [] def get_version(self, iq): - """Handler for jabber:iq:version queries. + """ + Handler for jabber:iq:version queries. jabber:iq:version queries are not supported directly by PyXMPP, so the XML node is accessed directly through the libxml2 API. This should be - used very carefully!""" + used very carefully! + """ iq = iq.make_result_response() q = iq.new_query("jabber:iq:version") q.newTextChild(q.ns(), "name", "Echo component") -- cgit v1.2.3 From 20b6a2ec022202b0efb6cb69415239fb8f4d1445 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:59:20 +0200 Subject: Spare code cosmetics (2) --- module/plugins/hooks/XMPPInterface.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 847fb26c3..10a03603e 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -36,7 +36,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.jid = JID(self.getConfig('jid')) password = self.getConfig('pw') - # if bare JID is provided add a resource -- it is required + #: if bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") @@ -47,8 +47,8 @@ class XMPPInterface(IRCInterface, JabberClient): tls_settings = None auth = ("sasl:DIGEST-MD5", "digest") - # setup client with provided connection information - # and identity data + #: setup client with provided connection information + #: and identity data JabberClient.__init__(self, self.jid, password, disco_name="pyLoad XMPP Client", disco_type="bot", tls_settings=tls_settings, auth_methods=auth) @@ -83,7 +83,7 @@ class XMPPInterface(IRCInterface, JabberClient): def run(self): - # connect to IRC etc. + #: connect to IRC etc. self.connect() try: self.loop() @@ -133,7 +133,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.logDebug("Body: %s Subject: %s Type: %s" % (body, subject, t)) if t == "headline": - # 'headline' messages should never be replied to + #: 'headline' messages should never be replied to return True if subject: subject = u"Re: " + subject -- cgit v1.2.3 From e4fb45b22d36595839e8f638a3f0a4669dba3e8d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 21 Jun 2015 08:50:26 +0200 Subject: Spare code cosmetics (4) --- module/plugins/hooks/XMPPInterface.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 10a03603e..8a76257ad 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -14,13 +14,13 @@ class XMPPInterface(IRCInterface, JabberClient): __type__ = "hook" __version__ = "0.11" - __config__ = [("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), - ("pw", "str", "Password", ""), - ("tls", "bool", "Use TLS", False), - ("owners", "str", "List of JIDs accepting commands from", "me@icq-gateway.org;some@msn-gateway.org"), - ("info_file", "bool", "Inform about every file finished", False), - ("info_pack", "bool", "Inform about every package finished", True), - ("captcha", "bool", "Send captcha requests", True)] + __config__ = [("jid" , "str" , "Jabber ID" , "user@exmaple-jabber-server.org" ), + ("pw" , "str" , "Password" , "" ), + ("tls" , "bool", "Use TLS" , False ), + ("owners" , "str" , "List of JIDs accepting commands from", "me@icq-gateway.org;some@msn-gateway.org"), + ("info_file", "bool", "Inform about every file finished" , False ), + ("info_pack", "bool", "Inform about every package finished" , True ), + ("captcha" , "bool", "Send captcha requests" , True )] __description__ = """Connect to jabber and let owner perform different tasks""" __license__ = "GPLv3" -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/hooks/XMPPInterface.py | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 8a76257ad..a2c32166f 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -12,7 +12,7 @@ from module.plugins.hooks.IRCInterface import IRCInterface class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" __type__ = "hook" - __version__ = "0.11" + __version__ = "0.12" __config__ = [("jid" , "str" , "Jabber ID" , "user@exmaple-jabber-server.org" ), ("pw" , "str" , "Password" , "" ), @@ -33,14 +33,14 @@ class XMPPInterface(IRCInterface, JabberClient): def __init__(self, core, manager): IRCInterface.__init__(self, core, manager) - self.jid = JID(self.getConfig('jid')) - password = self.getConfig('pw') + self.jid = JID(self.get_config('jid')) + password = self.get_config('pw') #: if bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") - if self.getConfig('tls'): + if self.get_config('tls'): tls_settings = streamtls.TLSSettings(require=True, verify_peer=False) auth = ("sasl:PLAIN", "sasl:DIGEST-MD5") else: @@ -67,7 +67,7 @@ class XMPPInterface(IRCInterface, JabberClient): def package_finished(self, pypack): try: - if self.getConfig('info_pack'): + if self.get_config('info_pack'): self.announce(_("Package finished: %s") % pypack.name) except Exception: pass @@ -75,7 +75,7 @@ class XMPPInterface(IRCInterface, JabberClient): def download_finished(self, pyfile): try: - if self.getConfig('info_file'): + if self.get_config('info_file'): self.announce( _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) except Exception: @@ -88,7 +88,7 @@ class XMPPInterface(IRCInterface, JabberClient): try: self.loop() except Exception, ex: - self.logError(ex) + self.log_error(ex) def stream_state_changed(self, state, arg): @@ -97,19 +97,19 @@ class XMPPInterface(IRCInterface, JabberClient): to a server changes. This will usually be used to let the user know what is going on. """ - self.logDebug("*** State changed: %s %r ***" % (state, arg)) + self.log_debug("*** State changed: %s %r ***" % (state, arg)) def disconnected(self): - self.logDebug("Client was disconnected") + self.log_debug("Client was disconnected") def stream_closed(self, stream): - self.logDebug("Stream was closed", stream) + self.log_debug("Stream was closed", stream) def stream_error(self, err): - self.logDebug("Stream Error", err) + self.log_debug("Stream Error", err) def get_message_handlers(self): @@ -129,8 +129,8 @@ class XMPPInterface(IRCInterface, JabberClient): subject = stanza.get_subject() body = stanza.get_body() t = stanza.get_type() - self.logDebug("Message from %s received." % stanza.get_from()) - self.logDebug("Body: %s Subject: %s Type: %s" % (body, subject, t)) + self.log_debug("Message from %s received." % stanza.get_from()) + self.log_debug("Body: %s Subject: %s Type: %s" % (body, subject, t)) if t == "headline": #: 'headline' messages should never be replied to @@ -141,11 +141,11 @@ class XMPPInterface(IRCInterface, JabberClient): to_jid = stanza.get_from() from_jid = stanza.get_to() - #j = JID() + # j = JID() to_name = to_jid.as_utf8() from_name = from_jid.as_utf8() - names = self.getConfig('owners').split(";") + names = self.get_config('owners').split(";") if to_name in names or to_jid.node + "@" + to_jid.domain in names: messages = [] @@ -174,7 +174,7 @@ class XMPPInterface(IRCInterface, JabberClient): messages.append(m) except Exception, e: - self.logError(e) + self.log_error(e) return messages @@ -190,8 +190,8 @@ class XMPPInterface(IRCInterface, JabberClient): """ Send message to all owners """ - for user in self.getConfig('owners').split(";"): - self.logDebug("Send message to", user) + for user in self.get_config('owners').split(";"): + self.log_debug("Send message to", user) to_jid = JID(user) -- cgit v1.2.3 From dad722ac7255640e7e0541c4094a4d2e4de79cd3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 00:05:58 +0200 Subject: Code cosmetics (2) --- module/plugins/hooks/XMPPInterface.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index a2c32166f..4262d3034 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -36,7 +36,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.jid = JID(self.get_config('jid')) password = self.get_config('pw') - #: if bare JID is provided add a resource -- it is required + #: If bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") @@ -47,8 +47,8 @@ class XMPPInterface(IRCInterface, JabberClient): tls_settings = None auth = ("sasl:DIGEST-MD5", "digest") - #: setup client with provided connection information - #: and identity data + #: Setup client with provided connection information + #: And identity data JabberClient.__init__(self, self.jid, password, disco_name="pyLoad XMPP Client", disco_type="bot", tls_settings=tls_settings, auth_methods=auth) @@ -83,7 +83,7 @@ class XMPPInterface(IRCInterface, JabberClient): def run(self): - #: connect to IRC etc. + #: Connect to IRC etc. self.connect() try: self.loop() -- cgit v1.2.3 From ff9383bfe06d14d23bc0ed6af79aa8967965d078 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 10:59:52 +0200 Subject: Code cosmetics (3) --- module/plugins/hooks/XMPPInterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 4262d3034..5eee3b872 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -77,7 +77,7 @@ class XMPPInterface(IRCInterface, JabberClient): try: if self.get_config('info_file'): self.announce( - _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) + _("Download finished: %(name)s @ %(plugin)s") % {'name': pyfile.name, 'plugin': pyfile.pluginname}) except Exception: pass -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/hooks/XMPPInterface.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 5eee3b872..2e4261286 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -13,6 +13,7 @@ class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" __type__ = "hook" __version__ = "0.12" + __status__ = "stable" __config__ = [("jid" , "str" , "Jabber ID" , "user@exmaple-jabber-server.org" ), ("pw" , "str" , "Password" , "" ), -- cgit v1.2.3 From 94d017cd2a5c1f194960827a8c7e46afc3682008 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 06:55:49 +0200 Subject: Hotfixes (2) --- module/plugins/hooks/XMPPInterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 2e4261286..50dd40774 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -13,7 +13,7 @@ class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" __type__ = "hook" __version__ = "0.12" - __status__ = "stable" + __status__ = "testing" __config__ = [("jid" , "str" , "Jabber ID" , "user@exmaple-jabber-server.org" ), ("pw" , "str" , "Password" , "" ), -- cgit v1.2.3