From a4e66c41ac377029ca284eb2b6772c8c269d712c Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Apr 2015 07:03:23 +0200 Subject: hotfix --- pyload/network/HTTPRequest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py index 92ce6ec4b..74b83cf12 100644 --- a/pyload/network/HTTPRequest.py +++ b/pyload/network/HTTPRequest.py @@ -24,7 +24,7 @@ def myurlencode(data): data = dict(data) return urlencode(dict((encode(x), encode(y)) for x, y in data.iteritems())) -bad_headers = xrange(400, 404) + xrange(405, 418) + xrange(500, 506) +bad_headers = range(400, 404) + range(405, 418) + range(500, 506) class BadHeader(Exception): -- cgit v1.2.3 From 3c7eb723000f9e1577a8e1df7d14595d6af6b90c Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Apr 2015 08:39:29 +0200 Subject: hotfix 2 --- pyload/database/Backend.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pyload/database/Backend.py b/pyload/database/Backend.py index b6540b2be..2f112bea4 100644 --- a/pyload/database/Backend.py +++ b/pyload/database/Backend.py @@ -175,18 +175,20 @@ class DatabaseBackend(Thread): f.write(str(DB_VERSION)) return - with open("files.version", "wb+") as f: + v = 0 + with open("files.version", "rb") as f: v = int(f.read().strip()) - if v < DB_VERSION: - if v < 2: - try: - self.manager.core.log.warning(_("Filedatabase was deleted due to incompatible version.")) - except Exception: - print "Filedatabase was deleted due to incompatible version." - remove("files.version") - move("files.db", "files.backup.db") + if v < DB_VERSION: + if v < 2: + try: + self.manager.core.log.warning(_("Filedatabase was deleted due to incompatible version.")) + except Exception: + print "Filedatabase was deleted due to incompatible version." + remove("files.version") + move("files.db", "files.backup.db") + with open("files.version", "wb") as f: f.write(str(DB_VERSION)) - return v + return v def _convertDB(self, v): -- cgit v1.2.3 From ce9e0c03e131162523ec949fc66b6802920fcd3b Mon Sep 17 00:00:00 2001 From: Armin Date: Tue, 21 Apr 2015 20:50:05 +0200 Subject: revert for merge --- pyload/database/Backend.py | 22 ++++++++++------------ pyload/network/HTTPRequest.py | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pyload/database/Backend.py b/pyload/database/Backend.py index 2f112bea4..b6540b2be 100644 --- a/pyload/database/Backend.py +++ b/pyload/database/Backend.py @@ -175,20 +175,18 @@ class DatabaseBackend(Thread): f.write(str(DB_VERSION)) return - v = 0 - with open("files.version", "rb") as f: + with open("files.version", "wb+") as f: v = int(f.read().strip()) - if v < DB_VERSION: - if v < 2: - try: - self.manager.core.log.warning(_("Filedatabase was deleted due to incompatible version.")) - except Exception: - print "Filedatabase was deleted due to incompatible version." - remove("files.version") - move("files.db", "files.backup.db") - with open("files.version", "wb") as f: + if v < DB_VERSION: + if v < 2: + try: + self.manager.core.log.warning(_("Filedatabase was deleted due to incompatible version.")) + except Exception: + print "Filedatabase was deleted due to incompatible version." + remove("files.version") + move("files.db", "files.backup.db") f.write(str(DB_VERSION)) - return v + return v def _convertDB(self, v): diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py index 74b83cf12..92ce6ec4b 100644 --- a/pyload/network/HTTPRequest.py +++ b/pyload/network/HTTPRequest.py @@ -24,7 +24,7 @@ def myurlencode(data): data = dict(data) return urlencode(dict((encode(x), encode(y)) for x, y in data.iteritems())) -bad_headers = range(400, 404) + range(405, 418) + range(500, 506) +bad_headers = xrange(400, 404) + xrange(405, 418) + xrange(500, 506) class BadHeader(Exception): -- cgit v1.2.3 From 26559343235fce1419b4d7cc33a02ceadf265836 Mon Sep 17 00:00:00 2001 From: Armin Date: Tue, 21 Apr 2015 21:02:37 +0200 Subject: convert DB only if needed --- pyload/database/Backend.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyload/database/Backend.py b/pyload/database/Backend.py index e851885c0..1fa7a654c 100644 --- a/pyload/database/Backend.py +++ b/pyload/database/Backend.py @@ -186,11 +186,11 @@ class DatabaseBackend(Thread): print "Filedatabase was deleted due to incompatible version." remove("files.version") move("files.db", "files.backup.db") - + with open("files.version", "wb") as f: f.write(str(DB_VERSION)) - return v + return v def _convertDB(self, v): -- cgit v1.2.3 From 3a7da5aed9d57ecbc404d4ebebf20013d1a38cf4 Mon Sep 17 00:00:00 2001 From: Armin Date: Tue, 21 Apr 2015 23:42:20 +0200 Subject: some fixes --- pyload/config/Setup.py | 11 ++++++++--- pyload/database/User.py | 2 +- pyload/utils/printer.py | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py index f078d54d0..e2f96c802 100644 --- a/pyload/config/Setup.py +++ b/pyload/config/Setup.py @@ -24,6 +24,11 @@ class SetupAssistant(object): self.lang = "en" self.stdin_encoding = get_console_encoding(sys.stdin.encoding) + # Input shorthand for yes + self.yes = "y" + # Input shorthand for no + self.no = "n" + def start(self): print @@ -383,7 +388,7 @@ class SetupAssistant(object): print _("2 - List users") print _("3 - Remove user") print _("4 - Quit") - action = raw_input("[1]/2/3/4: ") + action = raw_input("1/2/3/4: ") if not action in ("1", "2", "3", "4"): continue elif action == "1": @@ -463,8 +468,8 @@ class SetupAssistant(object): info = "" print "%(dep)-12s %(bool)s (%(info)s)" % {'dep': name + ':', - 'bool': _(true if value else false).upper(), - 'info': info} + 'bool': _(true if value else false).upper(), + 'info': info} def check_module(self, module): diff --git a/pyload/database/User.py b/pyload/database/User.py index 2aedc3bba..b5b44c50a 100644 --- a/pyload/database/User.py +++ b/pyload/database/User.py @@ -82,7 +82,7 @@ class UserMethods(object): @style.queue def getAllUserData(db): db.c.execute("SELECT name, permission, role, template, email FROM users") - return {{"permission": r[1], "role": r[2], "template": r[3], "email": r[4]} for r in db.c} + return {r[0]: {"permission": r[1], "role": r[2], "template": r[3], "email": r[4]} for r in db.c} @style.queue diff --git a/pyload/utils/printer.py b/pyload/utils/printer.py index 1122c7f4c..e4f6a360a 100644 --- a/pyload/utils/printer.py +++ b/pyload/utils/printer.py @@ -7,10 +7,10 @@ colorama.init(autoreset=True) def color(color, text): - return colorama.Fore.(c.upper())(text) + return colorama.Fore[c.upper()](text) for c in colorama.Fore: - eval("%(color) = lambda msg: color(%(color), msg)" % {'color': c.lower()} + eval("%(color)s = lambda msg: color(%(color)s, msg)" % {'color': c.lower()}) def overline(line, msg): -- cgit v1.2.3 From 22d531c192d4b2b3159788d514377c43f8fdde6b Mon Sep 17 00:00:00 2001 From: Armin Date: Wed, 22 Apr 2015 00:00:13 +0200 Subject: now the plugin attribute '__name' is no more used it is reduntant and obsolete --- pyload/plugin/Extractor.py | 6 +----- pyload/plugin/addon/ExtractArchive.py | 2 +- pyload/plugin/extractor/SevenZip.py | 5 +++-- pyload/plugin/extractor/UnRar.py | 21 +++++++++++---------- pyload/plugin/extractor/UnZip.py | 3 ++- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pyload/plugin/Extractor.py b/pyload/plugin/Extractor.py index e50ab8818..539ab624d 100644 --- a/pyload/plugin/Extractor.py +++ b/pyload/plugin/Extractor.py @@ -31,15 +31,11 @@ class Extractor: EXTENSIONS = [] + NAME = __name__ VERSION = "" REPAIR = False - @classmethod - def NAME(self): - return getattr(self, "_" + self.__name__ + "__name") - - @classmethod def isArchive(cls, filename): name = os.path.basename(filename).lower() diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index b0a24446a..616334af2 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -186,7 +186,7 @@ class ExtractArchive(Addon): traceback.print_exc() if self.extractors: - self.logDebug(*["Found %s %s" % (Extractor.NAME(), Extractor.VERSION) for Extractor in self.extractors]) + self.logDebug(*["Found %s %s" % (Extractor.NAME, Extractor.VERSION) for Extractor in self.extractors]) self.extractQueued() #: Resume unfinished extractions else: self.logInfo(_("No Extract plugins activated")) diff --git a/pyload/plugin/extractor/SevenZip.py b/pyload/plugin/extractor/SevenZip.py index 3c5e86602..587db5563 100644 --- a/pyload/plugin/extractor/SevenZip.py +++ b/pyload/plugin/extractor/SevenZip.py @@ -15,11 +15,12 @@ class SevenZip(UnRar): __description = """7-Zip extractor plugin""" __license = "GPLv3" - __authors = [("Michael Nowak" , "" ), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors = [("Michael Nowak" , ""), + ("Walter Purcaro", "vuolter@gmail.com")] CMD = "7z" + NAME = __name__ VERSION = "" EXTENSIONS = [".7z", ".xz", ".zip", ".gz", ".gzip", ".tgz", ".bz2", ".bzip2", diff --git a/pyload/plugin/extractor/UnRar.py b/pyload/plugin/extractor/UnRar.py index 38ae4e8f2..d1fc3728e 100644 --- a/pyload/plugin/extractor/UnRar.py +++ b/pyload/plugin/extractor/UnRar.py @@ -27,20 +27,21 @@ class UnRar(Extractor): __description = """Rar extractor plugin""" __license = "GPLv3" - __authors = [("RaNaN" , "RaNaN@pyload.org" ), - ("Walter Purcaro", "vuolter@gmail.com"), - ("Immenz" , "immenz@gmx.net" )] + __authors = [("RaNaN", "RaNaN@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com"), + ("Immenz", "immenz@gmx.net")] - CMD = "unrar" - VERSION = "" + CMD = "unrar" + NAME = __name__ + VERSION = "" EXTENSIONS = [".rar"] - re_multipart = re.compile(r'\.(part|r)(\d+)(?:\.rar)?(\.rev|\.bad)?',re.I) + re_multipart = re.compile(r'\.(part|r)(\d+)(?:\.rar)?(\.rev|\.bad)?', re.I) re_filefixed = re.compile(r'Building (.+)') - re_filelist = re.compile(r'^(.)(\s*[\w\.\-]+)\s+(\d+\s+)+(?:\d+\%\s+)?[\d\-]{8}\s+[\d\:]{5}', re.M|re.I) + re_filelist = re.compile(r'^(.)(\s*[\w\.\-]+)\s+(\d+\s+)+(?:\d+\%\s+)?[\d\-]{8}\s+[\d\:]{5}', re.M | re.I) re_wrongpwd = re.compile(r'password', re.I) re_wrongcrc = re.compile(r'encrypted|damaged|CRC failed|checksum error|corrupt', re.I) @@ -55,7 +56,7 @@ class UnRar(Extractor): cls.CMD = os.path.join(pypath, "RAR.exe") p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() - cls.__name = "RAR" + cls.NAME = "RAR" cls.REPAIR = True except OSError: @@ -66,7 +67,7 @@ class UnRar(Extractor): try: p = subprocess.Popen(["rar"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() - cls.__name = "RAR" + cls.NAME = "RAR" cls.REPAIR = True except OSError: #: fallback to unrar @@ -177,7 +178,7 @@ class UnRar(Extractor): # eventually Multipart Files files.extend(fs_join(dir, os.path.basename(file)) for file in filter(self.isMultipart, os.listdir(dir)) - if re.sub(self.re_multipart,".rar",name) == re.sub(self.re_multipart,".rar",file)) + if re.sub(self.re_multipart, ".rar", name) == re.sub(self.re_multipart, ".rar", file)) return files diff --git a/pyload/plugin/extractor/UnZip.py b/pyload/plugin/extractor/UnZip.py index b4fa637f0..f5cbe9402 100644 --- a/pyload/plugin/extractor/UnZip.py +++ b/pyload/plugin/extractor/UnZip.py @@ -21,7 +21,8 @@ class UnZip(Extractor): EXTENSIONS = [".zip", ".zip64"] - VERSION ="(python %s.%s.%s)" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]) + NAME = __name__ + VERSION = "(python %s.%s.%s)" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]) @classmethod -- cgit v1.2.3 From 32bd87243e0a4ac900098abda02cae0bbf7db72d Mon Sep 17 00:00:00 2001 From: Armin Date: Wed, 22 Apr 2015 00:07:16 +0200 Subject: little fix --- pyload/plugin/extractor/SevenZip.py | 2 +- pyload/plugin/extractor/UnRar.py | 2 +- pyload/plugin/extractor/UnZip.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyload/plugin/extractor/SevenZip.py b/pyload/plugin/extractor/SevenZip.py index 587db5563..cf5f7bfb8 100644 --- a/pyload/plugin/extractor/SevenZip.py +++ b/pyload/plugin/extractor/SevenZip.py @@ -20,7 +20,7 @@ class SevenZip(UnRar): CMD = "7z" - NAME = __name__ + NAME = __name__.rsplit('.', 1)[1] VERSION = "" EXTENSIONS = [".7z", ".xz", ".zip", ".gz", ".gzip", ".tgz", ".bz2", ".bzip2", diff --git a/pyload/plugin/extractor/UnRar.py b/pyload/plugin/extractor/UnRar.py index d1fc3728e..83821cdc1 100644 --- a/pyload/plugin/extractor/UnRar.py +++ b/pyload/plugin/extractor/UnRar.py @@ -33,7 +33,7 @@ class UnRar(Extractor): CMD = "unrar" - NAME = __name__ + NAME = __name__.rsplit('.', 1)[1] VERSION = "" EXTENSIONS = [".rar"] diff --git a/pyload/plugin/extractor/UnZip.py b/pyload/plugin/extractor/UnZip.py index f5cbe9402..8bfd63480 100644 --- a/pyload/plugin/extractor/UnZip.py +++ b/pyload/plugin/extractor/UnZip.py @@ -21,7 +21,7 @@ class UnZip(Extractor): EXTENSIONS = [".zip", ".zip64"] - NAME = __name__ + NAME = __name__.rsplit('.', 1)[1] VERSION = "(python %s.%s.%s)" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]) -- cgit v1.2.3