diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-10-13 15:42:44 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-10-13 15:42:44 +0200 |
commit | efdd172e823cfc59d33c7acf30510cf05c2791fb (patch) | |
tree | b977a715a9562e2288bf933921c28c20c94df347 | |
parent | improvement for hook plugins, new internal plugin type (diff) | |
download | pyload-efdd172e823cfc59d33c7acf30510cf05c2791fb.tar.xz |
fixes syntax error on old python versions
-rw-r--r-- | module/PluginThread.py | 4 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 16 | ||||
-rw-r--r-- | module/plugins/PluginManager.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 85 | ||||
-rw-r--r-- | module/plugins/internal/__init__.py | 0 |
5 files changed, 15 insertions, 92 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py index d29d609c7..aeb2ac2aa 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -454,8 +454,10 @@ class HookThread(PluginThread): def run(self): try: try: - self.f(*self.args, thread=self, **self.kwargs) + self.kwargs["thread"] = self + self.f(*self.args, **self.kwargs) except TypeError: + del self.kwargs["thread"] self.f(*self.args, **self.kwargs) finally: local = copy(self.active) diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 9417a4bfd..7c9e7c15c 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -81,17 +81,17 @@ class Base(object): self.config = core.config #log functions - def logInfo(self, msg): - self.log.info("%s: %s" % (self.__name__, msg)) + def logInfo(self, *args): + self.log.info("%s: %s" % (self.__name__, " | ".join(args))) - def logWarning(self, msg): - self.log.warning("%s: %s" % (self.__name__, msg)) + def logWarning(self, *args): + self.log.warning("%s: %s" % (self.__name__, " | ".join(args))) - def logError(self, msg): - self.log.error("%s: %s" % (self.__name__, msg)) + def logError(self, *args): + self.log.error("%s: %s" % (self.__name__, " | ".join(args))) - def logDebug(self, msg): - self.log.debug("%s: %s" % (self.__name__, msg)) + def logDebug(self, *args): + self.log.debug("%s: %s" % (self.__name__, "| ".join(args))) def setConf(self, option, value): diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py index 4ddb1b1b9..e5a1c06cc 100644 --- a/module/plugins/PluginManager.py +++ b/module/plugins/PluginManager.py @@ -346,7 +346,7 @@ class PluginManager(): return pluginClass - def getInternalModul(self, name): + def getInternalModule(self, name): if name not in self.internalPlugins: return None diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 8ff99b5e8..d22e54b61 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -24,95 +24,16 @@ from os.path import exists, join, isabs, isdir from os import remove, makedirs, rmdir, listdir, chmod from traceback import print_exc -from module.plugins.Hook import Hook +from module.plugins.hooks.ExtractArchive import AbtractExtractor from module.lib.pyunrar import Unrar, WrongPasswordError, CommandError, UnknownError, LowRamError from module.utils import save_join -if os.name != "nt": - from pwd import getpwnam - from os import chown -import re - -class UnRar(Hook): - __name__ = "UnRar" - __version__ = "0.1" - __description__ = """Unrar plugin for archive extractor""" - __config__ = [("activated", "bool", "Activated", False), - ("fullpath", "bool", "extract full path", True), - ("overwrite", "bool", "overwrite files", True), - ("passwordfile", "str", "unrar password file", "unrar_passwords.txt"), - ("deletearchive", "bool", "delete archives when done", False), - ("ramwarning", "bool", "warn about low ram", True), - ("renice", "int", "Cpu Priority", 10), - ("unrar_destination", "str", "Unpack files to", "")] - __threaded__ = ["packageFinished"] - __author_name__ = ("mkaay") - __author_mail__ = ("mkaay@mkaay.de") - - def setup(self): - self.comments = ["# one password each line"] - self.passwords = [] - if exists(self.getConfig("passwordfile")): - with open(self.getConfig("passwordfile"), "r") as f: - for l in f.readlines(): - l = l.strip("\n\r") - if l and not l.startswith("#"): - self.passwords.append(l) - else: - with open(self.getConfig("passwordfile"), "w") as f: - f.writelines(self.comments) - self.re_splitfile = re.compile("(.*)\.part(\d+)\.rar$") - - self.ram = 0 #ram in kb for unix osses - try: - f = open("/proc/meminfo") - line = True - while line: - line = f.readline() - if line.startswith("MemTotal:"): - self.ram = int(re.search(r"([0-9]+)", line).group(1)) - except: - self.ram = 0 - - self.ram /= 1024 - - def setOwner(self, d, uid, gid, mode): - if not exists(d): - self.core.log.debug(_("Directory %s does not exist!") % d) - return - for fileEntry in listdir(d): - fullEntryName = join(d, fileEntry) - if isdir(fullEntryName): - self.setOwner(fullEntryName, uid, gid, mode) - try: - chown(fullEntryName, uid, gid) - chmod(fullEntryName, mode) - except: - self.core.log.debug(_("Chown/Chmod for %s failed") % fullEntryName) - self.core.log.debug(_("Exception: %s") % sys.exc_info()[0]) - continue - try: - chown(d, uid, gid) - chmod(d, mode) - except: - self.core.log.debug(_("Chown/Chmod for %s failed") % d) - self.core.log.debug(_("Exception: %s") % sys.exc_info()[0]) - return +import re - def addPassword(self, pws): - if not type(pws) == list: pws = [pws] - pws.reverse() - for pw in pws: - pw = pw.strip() - if not pw or pw == "None" or pw in self.passwords: continue - self.passwords.insert(0, pw) - - with open(self.getConfig("passwordfile"), "w") as f: - f.writelines([c + "\n" for c in self.comments]) - f.writelines([p + "\n" for p in self.passwords]) +class UnRar(AbtractExtractor): def removeFiles(self, pack, fname): if not self.getConfig("deletearchive"): diff --git a/module/plugins/internal/__init__.py b/module/plugins/internal/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/module/plugins/internal/__init__.py |