From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hooks/XMPPInterface.py | 9 +++++---- 1 file changed, 5 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 5ecf4e153..7b179d41a 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -13,9 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN - @interface-version: 0.2 """ from pyxmpp import streamtls @@ -30,7 +27,8 @@ from module.plugins.hooks.IRCInterface import IRCInterface class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" __version__ = "0.11" - __description__ = """Connect to jabber and let owner perform different tasks""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), ("pw", "str", "Password", ""), @@ -39,9 +37,12 @@ class XMPPInterface(IRCInterface, JabberClient): ("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""" __author_name__ = "RaNaN" __author_mail__ = "RaNaN@pyload.org" + implements(IMessageHandlersProvider) def __init__(self, core, manager): -- cgit v1.2.3 From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- 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 7b179d41a..57a997a4b 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -130,7 +130,7 @@ class XMPPInterface(IRCInterface, JabberClient): subject = stanza.get_subject() body = stanza.get_body() t = stanza.get_type() - self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(), ))) + self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(),))) self.logDebug(u'pyLoad XMPP: Body: %s Subject: %s Type: %s' % (body, subject, t)) if t == "headline": -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hooks/XMPPInterface.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 57a997a4b..a60d31b89 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -121,9 +121,7 @@ class XMPPInterface(IRCInterface, JabberClient): The handlers returned will be called when matching message is received in a client session.""" - return [ - ("normal", self.message), - ] + return [("normal", self.message)] def message(self, stanza): """Message handler for the component.""" @@ -231,9 +229,7 @@ class VersionHandler(object): def get_iq_get_handlers(self): """Return list of tuples (element_name, namespace, handler) describing handlers of stanzas""" - return [ - ("query", "jabber:iq:version", self.get_version), - ] + return [("query", "jabber:iq:version", self.get_version)] def get_iq_set_handlers(self): """Return empty list, as this class provides no stanza handler.""" -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hooks/XMPPInterface.py | 19 ++----------------- 1 file changed, 2 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 a60d31b89..c4a94a8bc 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -1,33 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - from pyxmpp import streamtls from pyxmpp.all import JID, Message -from pyxmpp.jabber.client import JabberClient from pyxmpp.interface import implements from pyxmpp.interfaces import * +from pyxmpp.jabber.client import JabberClient from module.plugins.hooks.IRCInterface import IRCInterface class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), ("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), -- cgit v1.2.3 From 0d220d634e512d89bda540f91c643b361c82ea8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Sep 2014 01:38:32 +0200 Subject: Logging string cosmetics --- module/plugins/hooks/XMPPInterface.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index c4a94a8bc..47d4d9fe4 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -84,22 +84,22 @@ class XMPPInterface(IRCInterface, JabberClient): try: self.loop() except Exception, ex: - self.logError("pyLoad XMPP: %s" % str(ex)) + self.logError(ex) def stream_state_changed(self, state, arg): """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.""" - self.logDebug("pyLoad XMPP: *** State changed: %s %r ***" % (state, arg)) + self.logDebug("*** State changed: %s %r ***" % (state, arg)) def disconnected(self): - self.logDebug("pyLoad XMPP: Client was disconnected") + self.logDebug("Client was disconnected") def stream_closed(self, stream): - self.logDebug("pyLoad XMPP: Stream was closed | %s" % stream) + self.logDebug("Stream was closed", stream) def stream_error(self, err): - self.logDebug("pyLoad XMPP: Stream Error: %s" % err) + self.logDebug("Stream Error", err) def get_message_handlers(self): """Return list of (message_type, message_handler) tuples. @@ -113,8 +113,8 @@ class XMPPInterface(IRCInterface, JabberClient): subject = stanza.get_subject() body = stanza.get_body() t = stanza.get_type() - self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(),))) - self.logDebug(u'pyLoad XMPP: Body: %s Subject: %s Type: %s' % (body, subject, t)) + self.logDebug("Message from %s received." % unicode(stanza.get_from())) + self.logDebug("Body: %s Subject: %s Type: %s" % (body, subject, t)) if t == "headline": # 'headline' messages should never be replied to @@ -158,7 +158,7 @@ class XMPPInterface(IRCInterface, JabberClient): messages.append(m) except Exception, e: - self.logError("pyLoad XMPP: " + repr(e)) + self.logError(repr(e)) return messages @@ -171,7 +171,7 @@ class XMPPInterface(IRCInterface, JabberClient): def announce(self, message): """ send message to all owners""" for user in self.getConfig("owners").split(";"): - self.logDebug("pyLoad XMPP: Send message to %s" % user) + self.logDebug("Send message to", user) to_jid = JID(user) -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/hooks/XMPPInterface.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 47d4d9fe4..d6334d8d0 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -24,8 +24,7 @@ class XMPPInterface(IRCInterface, JabberClient): ("captcha", "bool", "Send captcha requests", True)] __description__ = """Connect to jabber and let owner perform different tasks""" - __author_name__ = "RaNaN" - __author_mail__ = "RaNaN@pyload.org" + __authors__ = [("RaNaN", "RaNaN@pyload.org")] implements(IMessageHandlersProvider) -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- 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 d6334d8d0..b32eeb40b 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -24,6 +24,7 @@ class XMPPInterface(IRCInterface, JabberClient): ("captcha", "bool", "Send captcha requests", True)] __description__ = """Connect to jabber and let owner perform different tasks""" + __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.org")] -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/hooks/XMPPInterface.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index b32eeb40b..c4d6e1b66 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -30,6 +30,7 @@ class XMPPInterface(IRCInterface, JabberClient): implements(IMessageHandlersProvider) + def __init__(self, core, manager): IRCInterface.__init__(self, core, manager) @@ -58,11 +59,13 @@ class XMPPInterface(IRCInterface, JabberClient): self, ] + def coreReady(self): self.new_package = {} self.start() + def packageFinished(self, pypack): try: if self.getConfig("info_pack"): @@ -70,6 +73,7 @@ class XMPPInterface(IRCInterface, JabberClient): except: pass + def downloadFinished(self, pyfile): try: if self.getConfig("info_file"): @@ -78,6 +82,7 @@ class XMPPInterface(IRCInterface, JabberClient): except: pass + def run(self): # connect to IRC etc. self.connect() @@ -86,21 +91,26 @@ class XMPPInterface(IRCInterface, JabberClient): except Exception, ex: self.logError(ex) + def stream_state_changed(self, state, arg): """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.""" self.logDebug("*** State changed: %s %r ***" % (state, arg)) + def disconnected(self): self.logDebug("Client was disconnected") + def stream_closed(self, stream): self.logDebug("Stream was closed", stream) + def stream_error(self, err): self.logDebug("Stream Error", err) + def get_message_handlers(self): """Return list of (message_type, message_handler) tuples. @@ -108,6 +118,7 @@ class XMPPInterface(IRCInterface, JabberClient): in a client session.""" return [("normal", self.message)] + def message(self, stanza): """Message handler for the component.""" subject = stanza.get_subject() @@ -165,9 +176,11 @@ class XMPPInterface(IRCInterface, JabberClient): else: return True + def response(self, msg, origin=""): return self.announce(msg) + def announce(self, message): """ send message to all owners""" for user in self.getConfig("owners").split(";"): @@ -187,9 +200,11 @@ class XMPPInterface(IRCInterface, JabberClient): stream.send(m) + def beforeReconnecting(self, ip): self.disconnect() + def afterReconnecting(self, ip): self.connect() @@ -202,24 +217,29 @@ class VersionHandler(object): implements(IIqHandlersProvider, IFeaturesProvider) + def __init__(self, client): """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 ["jabber:iq:version"] + def get_iq_get_handlers(self): """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 [] + def get_version(self, iq): """Handler for jabber:iq:version queries. -- cgit v1.2.3 From 146fe1e309c33ab149bfaf58ad86c0dd4fb9b156 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 01:18:45 +0100 Subject: Spare code cosmetics --- 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 c4d6e1b66..8a4e0e9d9 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -169,7 +169,7 @@ class XMPPInterface(IRCInterface, JabberClient): messages.append(m) except Exception, e: - self.logError(repr(e)) + self.logError(str(e)) return messages -- cgit v1.2.3 From 885f8ed782e64d9e73367905e642a84d0a8999f1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:01:38 +0100 Subject: Update __config__ --- module/plugins/hooks/XMPPInterface.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks/XMPPInterface.py') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 8a4e0e9d9..252aa820c 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -14,8 +14,7 @@ class XMPPInterface(IRCInterface, JabberClient): __type__ = "hook" __version__ = "0.11" - __config__ = [("activated", "bool", "Activated", False), - ("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), + __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"), -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- 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 252aa820c..e23398023 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -10,8 +10,8 @@ from module.plugins.hooks.IRCInterface import IRCInterface class XMPPInterface(IRCInterface, JabberClient): - __name__ = "XMPPInterface" - __type__ = "hook" + __name__ = "XMPPInterface" + __type__ = "hook" __version__ = "0.11" __config__ = [("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), @@ -23,8 +23,8 @@ class XMPPInterface(IRCInterface, JabberClient): ("captcha", "bool", "Send captcha requests", True)] __description__ = """Connect to jabber and let owner perform different tasks""" - __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org")] implements(IMessageHandlersProvider) -- cgit v1.2.3 From c9e31d875d32de31e54959b82bc35eff2b3e0f3f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 10 Nov 2014 00:19:51 +0100 Subject: Code cosmetics --- 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 e23398023..bbeab4341 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -168,7 +168,7 @@ class XMPPInterface(IRCInterface, JabberClient): messages.append(m) except Exception, e: - self.logError(str(e)) + self.logError(e) return messages -- cgit v1.2.3