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/IRCInterface.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/IRCInterface.py') diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 760c1a4df..41ca352a4 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -13,10 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN - @author: jeix - @interface-version: 0.2 """ from select import select @@ -37,7 +33,8 @@ from module.Api import PackageDoesNotExists, FileDoesNotExists class IRCInterface(Thread, Hook): __name__ = "IRCInterface" __version__ = "0.11" - __description__ = """Connect to irc and let owner perform different tasks""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("host", "str", "IRC-Server Address", "Enter your server here!"), ("port", "int", "IRC-Server Port", 6667), @@ -48,9 +45,12 @@ class IRCInterface(Thread, Hook): ("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 irc and let owner perform different tasks""" __author_name__ = "Jeix" __author_mail__ = "Jeix@hasnomail.com" + def __init__(self, core, manager): Thread.__init__(self) Hook.__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/IRCInterface.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks/IRCInterface.py') diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 41ca352a4..7dbe835c7 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -311,12 +311,10 @@ class IRCInterface(Thread, Hook): return lines def event_start(self, args): - self.api.unpauseServer() return ["INFO: Starting downloads."] def event_stop(self, args): - self.api.pauseServer() return ["INFO: No new downloads will be started."] @@ -415,6 +413,7 @@ class IRCInterface(Thread, Hook): class IRCError(Exception): + def __init__(self, value): self.value = value -- 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/IRCInterface.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'module/plugins/hooks/IRCInterface.py') diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 7dbe835c7..9a9bab9b4 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -155,25 +155,25 @@ class IRCInterface(Thread, Hook): self.handle_events(msg) def handle_events(self, msg): - if not msg["origin"].split("!", 1)[0] in self.getConfig("owner").split(): + if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split(): return - if msg["target"].split("!", 1)[0] != self.getConfig("nick"): + if msg['target'].split("!", 1)[0] != self.getConfig("nick"): return - if msg["action"] != "PRIVMSG": + if msg['action'] != "PRIVMSG": return # HANDLE CTCP ANTI FLOOD/BOT PROTECTION - if msg["text"] == "\x01VERSION\x01": + if msg['text'] == "\x01VERSION\x01": self.logDebug("Sending CTCP VERSION.") self.sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) return - elif msg["text"] == "\x01TIME\x01": + elif msg['text'] == "\x01TIME\x01": self.logDebug("Sending CTCP TIME.") self.sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) return - elif msg["text"] == "\x01LAG\x01": + elif msg['text'] == "\x01LAG\x01": self.logDebug("Received CTCP LAG.") # don't know how to answer return @@ -181,7 +181,7 @@ class IRCInterface(Thread, Hook): args = None try: - temp = msg["text"].split() + temp = msg['text'].split() trigger = temp[0] if len(temp) > 1: args = temp[1:] @@ -192,7 +192,7 @@ class IRCInterface(Thread, Hook): try: res = handler(args) for line in res: - self.response(line, msg["origin"]) + self.response(line, msg['origin']) except Exception, e: self.logError("pyLoad IRC: " + repr(e)) @@ -258,7 +258,7 @@ class IRCInterface(Thread, Hook): def event_info(self, args): if not args: - return ['ERROR: Use info like this: info '] + return ["ERROR: Use info like this: info "] info = None try: @@ -271,7 +271,7 @@ class IRCInterface(Thread, Hook): def event_packinfo(self, args): if not args: - return ['ERROR: Use packinfo like this: packinfo '] + return ["ERROR: Use packinfo like this: packinfo "] lines = [] pack = None @@ -321,7 +321,7 @@ class IRCInterface(Thread, Hook): def event_add(self, args): if len(args) < 2: return ['ERROR: Add links like this: "add links". ', - 'This will add the link to to the package / the package with id !'] + "This will add the link to to the package / the package with id !"] pack = args[0].strip() links = [x.strip() for x in args[1:]] @@ -336,7 +336,7 @@ class IRCInterface(Thread, Hook): #TODO add links - return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack["name"], id)] + return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] except: # create new package -- cgit v1.2.3 From 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:25:14 +0200 Subject: Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 --- module/plugins/hooks/IRCInterface.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'module/plugins/hooks/IRCInterface.py') diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 9a9bab9b4..a29874469 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -59,12 +59,9 @@ class IRCInterface(Thread, Hook): self.api = core.api # todo, only use api def coreReady(self): - self.new_package = {} - self.abort = False - - self.links_added = 0 self.more = [] + self.new_package = {} self.start() -- 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/IRCInterface.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'module/plugins/hooks/IRCInterface.py') diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index a29874469..7ebc0275f 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -1,39 +1,25 @@ # -*- 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 . -""" +import re +import socket +import time +from pycurl import FORM_FILE from select import select -import socket from threading import Thread -import time from time import sleep from traceback import print_exc -import re -from pycurl import FORM_FILE -from module.plugins.Hook import Hook +from module.Api import PackageDoesNotExists, FileDoesNotExists from module.network.RequestFactory import getURL +from module.plugins.Hook import Hook from module.utils import formatSize -from module.Api import PackageDoesNotExists, FileDoesNotExists class IRCInterface(Thread, Hook): __name__ = "IRCInterface" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), ("host", "str", "IRC-Server Address", "Enter your server here!"), -- cgit v1.2.3