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/hoster/Xdcc.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 53f61836b..cc9f4719c 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: jeix """ from os.path import join -- 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/hoster/Xdcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index cc9f4719c..d6083e4f7 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -62,7 +62,7 @@ class Xdcc(Hoster): else: errno = e.args[0] - if errno in (10054,): + if errno == 10054: self.logDebug("XDCC: Server blocked our ip, retry in 5 min") self.setWait(300) self.wait() -- 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/hoster/Xdcc.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index d6083e4f7..8f3fb284f 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -166,31 +166,31 @@ class Xdcc(Hoster): "text": msg[3][1:] } - if nick == msg["target"][0:len(nick)] and "PRIVMSG" == msg["action"]: - if msg["text"] == "\x01VERSION\x01": + if nick == msg['target'][0:len(nick)] and "PRIVMSG" == msg['action']: + if msg['text'] == "\x01VERSION\x01": self.logDebug("XDCC: Sending CTCP VERSION.") sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) - elif msg["text"] == "\x01TIME\x01": + elif msg['text'] == "\x01TIME\x01": self.logDebug("Sending CTCP TIME.") sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) - elif msg["text"] == "\x01LAG\x01": + elif msg['text'] == "\x01LAG\x01": pass # don't know how to answer - if not (bot == msg["origin"][0:len(bot)] - and nick == msg["target"][0:len(nick)] - and msg["action"] in ("PRIVMSG", "NOTICE")): + if not (bot == msg['origin'][0:len(bot)] + and nick == msg['target'][0:len(nick)] + and msg['action'] in ("PRIVMSG", "NOTICE")): continue if self.debug is 1: - print "%s: %s" % (msg["origin"], msg["text"]) + print "%s: %s" % (msg['origin'], msg['text']) - if "You already requested that pack" in msg["text"]: + if "You already requested that pack" in msg['text']: retry = time.time() + 300 - if "you must be on a known channel to request a pack" in msg["text"]: + if "you must be on a known channel to request a pack" in msg['text']: self.fail("Wrong channel") - m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg["text"]) + m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg['text']) if m: done = True -- 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/hoster/Xdcc.py | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 8f3fb284f..a26e239ad 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -1,46 +1,33 @@ # -*- 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 os.path import join -from os.path import exists -from os import makedirs import re -import sys -import time import socket import struct +import sys +import time + +from os import makedirs +from os.path import exists, join from select import select -from module.utils import save_join from module.plugins.Hoster import Hoster +from module.utils import save_join class Xdcc(Hoster): __name__ = "Xdcc" - __version__ = "0.32" - __pattern__ = r'xdcc://([^/]*?)(/#?.*?)?/.*?/#?\d+/?' # xdcc://irc.Abjects.net/#channel/[XDCC]|Shit/#0004/ __type__ = "hoster" + __version__ = "0.32" + __config__ = [("nick", "str", "Nickname", "pyload"), ("ident", "str", "Ident", "pyloadident"), ("realname", "str", "Realname", "pyloadreal")] + __description__ = """Download from IRC XDCC bot""" __author_name__ = "jeix" __author_mail__ = "jeix@hasnomail.com" + def setup(self): self.debug = 0 # 0,1,2 self.timeout = 30 @@ -75,11 +62,6 @@ class Xdcc(Hoster): def doDownload(self, url): self.pyfile.setStatus("waiting") # real link - download_folder = self.config['general']['download_folder'] - location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding())) - if not exists(location): - makedirs(location) - m = re.match(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url) server = m.group(1) chan = m.group(2) @@ -203,7 +185,10 @@ class Xdcc(Hoster): self.req.filesize = int(m.group(4)) self.pyfile.name = packname - filename = save_join(location, packname) + + download_folder = self.config['general']['download_folder'] + filename = save_join(download_folder, packname) + self.logInfo("XDCC: Downloading %s from %s:%d" % (packname, ip, port)) self.pyfile.setStatus("downloading") -- 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/hoster/Xdcc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index a26e239ad..a4a630ad9 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -24,8 +24,7 @@ class Xdcc(Hoster): ("realname", "str", "Realname", "pyloadreal")] __description__ = """Download from IRC XDCC bot""" - __author_name__ = "jeix" - __author_mail__ = "jeix@hasnomail.com" + __authors__ = [("jeix", "jeix@hasnomail.com")] def setup(self): -- 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/hoster/Xdcc.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index a4a630ad9..db9c5edf9 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -24,6 +24,7 @@ class Xdcc(Hoster): ("realname", "str", "Realname", "pyloadreal")] __description__ = """Download from IRC XDCC bot""" + __license__ = "GPLv3" __authors__ = [("jeix", "jeix@hasnomail.com")] -- 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/hoster/Xdcc.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index db9c5edf9..244c3d7e2 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -33,6 +33,7 @@ class Xdcc(Hoster): self.timeout = 30 self.multiDL = False + def process(self, pyfile): # change request type self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="XDCC") @@ -59,6 +60,7 @@ class Xdcc(Hoster): self.fail("Server blocked our ip, retry again later manually") + def doDownload(self, url): self.pyfile.setStatus("waiting") # real link -- cgit v1.2.3 From 1c4bf83881d2a22da3773666a580d51f6b57bfd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Oct 2014 03:07:21 +0200 Subject: Avoid gettext conflict due variable `_` --- module/plugins/hoster/Xdcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 244c3d7e2..35725ce32 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -39,7 +39,7 @@ class Xdcc(Hoster): self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="XDCC") self.pyfile = pyfile - for _ in xrange(0, 3): + for _i in xrange(0, 3): try: nmn = self.doDownload(pyfile.url) self.logDebug("%s: Download of %s finished." % (self.__name__, nmn)) -- cgit v1.2.3 From 9f2ebe486a3e155fb6a60e07cccb77ab6a772eb2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 02:31:54 +0200 Subject: Extend translation support in plugins + a lot of code cosmetics and typo fixes --- module/plugins/hoster/Xdcc.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 35725ce32..c3fae80f1 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -42,7 +42,7 @@ class Xdcc(Hoster): for _i in xrange(0, 3): try: nmn = self.doDownload(pyfile.url) - self.logDebug("%s: Download of %s finished." % (self.__name__, nmn)) + self.logDebug("Download of %s finished." % nmn) return except socket.error, e: if hasattr(e, "errno"): @@ -51,14 +51,14 @@ class Xdcc(Hoster): errno = e.args[0] if errno == 10054: - self.logDebug("XDCC: Server blocked our ip, retry in 5 min") + self.logDebug("Server blocked our ip, retry in 5 min") self.setWait(300) self.wait() continue - self.fail("Failed due to socket errors. Code: %d" % errno) + self.fail(_("Failed due to socket errors. Code: %d") % errno) - self.fail("Server blocked our ip, retry again later manually") + self.fail(_("Server blocked our ip, retry again later manually")) def doDownload(self, url): @@ -80,7 +80,7 @@ class Xdcc(Hoster): elif ln == 1: host, port = temp[0], 6667 else: - self.fail("Invalid hostname for IRC Server (%s)" % server) + self.fail(_("Invalid hostname for IRC Server: %s") % server) ####################### # CONNECT TO IRC AND IDLE FOR REAL LINK @@ -117,7 +117,7 @@ class Xdcc(Hoster): if (dl_time + self.timeout) < time.time(): # todo: add in config sock.send("QUIT :byebye\r\n") sock.close() - self.fail("XDCC Bot did not answer") + self.fail(_("XDCC Bot did not answer")) fdset = select([sock], [], [], 0) if sock not in fdset[0]: @@ -137,7 +137,7 @@ class Xdcc(Hoster): sock.send("PONG %s\r\n" % first[1]) if first[0] == "ERROR": - self.fail("IRC-Error: %s" % line) + self.fail(_("IRC-Error: %s") % line) msg = line.split(None, 3) if len(msg) != 4: @@ -152,10 +152,10 @@ class Xdcc(Hoster): if nick == msg['target'][0:len(nick)] and "PRIVMSG" == msg['action']: if msg['text'] == "\x01VERSION\x01": - self.logDebug("XDCC: Sending CTCP VERSION.") + self.logDebug("Sending CTCP VERSION") sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) elif msg['text'] == "\x01TIME\x01": - self.logDebug("Sending CTCP TIME.") + self.logDebug("Sending CTCP TIME") sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) elif msg['text'] == "\x01LAG\x01": pass # don't know how to answer @@ -172,7 +172,7 @@ class Xdcc(Hoster): retry = time.time() + 300 if "you must be on a known channel to request a pack" in msg['text']: - self.fail("Wrong channel") + self.fail(_("Wrong channel")) m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg['text']) if m: @@ -191,12 +191,12 @@ class Xdcc(Hoster): download_folder = self.config['general']['download_folder'] filename = save_join(download_folder, packname) - self.logInfo("XDCC: Downloading %s from %s:%d" % (packname, ip, port)) + self.logInfo(_("Downloading %s from %s:%d") % (packname, ip, port)) self.pyfile.setStatus("downloading") newname = self.req.download(ip, port, filename, sock, self.pyfile.setProgress) if newname and newname != filename: - self.logInfo("%(name)s saved as %(newname)s" % {"name": self.pyfile.name, "newname": newname}) + self.logInfo(_("%(name)s saved as %(newname)s") % {"name": self.pyfile.name, "newname": newname}) filename = newname # kill IRC socket -- 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/hoster/Xdcc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/Xdcc.py') diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index c3fae80f1..ef6da4a71 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -15,8 +15,8 @@ from module.utils import save_join class Xdcc(Hoster): - __name__ = "Xdcc" - __type__ = "hoster" + __name__ = "Xdcc" + __type__ = "hoster" __version__ = "0.32" __config__ = [("nick", "str", "Nickname", "pyload"), @@ -24,8 +24,8 @@ class Xdcc(Hoster): ("realname", "str", "Realname", "pyloadreal")] __description__ = """Download from IRC XDCC bot""" - __license__ = "GPLv3" - __authors__ = [("jeix", "jeix@hasnomail.com")] + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.com")] def setup(self): -- cgit v1.2.3