summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/ExtractArchive.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-11-14 19:53:55 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-11-14 19:53:55 +0100
commit9d8d8db40662aeeb8ebbc5e6934d39f84574dd80 (patch)
treecff8ab2e9c20cd8a4b27b42b704c75377d343fd6 /module/plugins/hooks/ExtractArchive.py
parentrehost,to timeout fix (diff)
downloadpyload-9d8d8db40662aeeb8ebbc5e6934d39f84574dd80.tar.xz
improved plugin loader, import hook to always use newest plugin versions
Diffstat (limited to 'module/plugins/hooks/ExtractArchive.py')
-rw-r--r--module/plugins/hooks/ExtractArchive.py113
1 files changed, 4 insertions, 109 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 0a70da417..359bfca76 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -8,7 +8,6 @@ from os.path import exists, basename, isfile, isdir, join
from traceback import print_exc
from copy import copy
-
# monkey patch bug in python 2.6 and lower
# see http://bugs.python.org/issue6122
# http://bugs.python.org/issue1236
@@ -49,21 +48,9 @@ if os.name != "nt":
from pwd import getpwnam
from grp import getgrnam
-from module.plugins.Hook import Hook, threaded, Expose
from module.utils import save_join, fs_encode
-
-
-class ArchiveError(Exception):
- pass
-
-
-class CRCError(Exception):
- pass
-
-
-class WrongPassword(Exception):
- pass
-
+from module.plugins.Hook import Hook, threaded, Expose
+from module.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword
class ExtractArchive(Hook):
"""
@@ -93,7 +80,7 @@ class ExtractArchive(Hook):
for p in ("UnRar", "UnZip"):
try:
- module = self.core.pluginManager.getInternalModule(p)
+ module = self.core.pluginManager.loadModule("internal", p)
klass = getattr(module, p)
if klass.checkDeps():
names.append(p)
@@ -317,96 +304,4 @@ class ExtractArchive(Hook):
gid = getgrnam(self.config["permission"]["group"])[2]
chown(f, uid, gid)
except Exception, e:
- self.log.warning(_("Setting User and Group failed"), e)
-
- def archiveError(self, msg):
- raise ArchiveError(msg)
-
- def wrongPassword(self):
- raise WrongPassword()
-
- def crcError(self):
- raise CRCError()
-
-
-class AbtractExtractor:
- @staticmethod
- def checkDeps():
- """ Check if system statisfy dependencies
- :return: boolean
- """
- return True
-
- @staticmethod
- def getTargets(files_ids):
- """ Filter suited targets from list of filename id tuple list
- :param files_ids: List of filepathes
- :return: List of targets, id tuple list
- """
- raise NotImplementedError
-
-
- def __init__(self, m, file, out, fullpath, overwrite, renice):
- """Initialize extractor for specific file
-
- :param m: ExtractArchive Hook plugin
- :param file: Absolute filepath
- :param out: Absolute path to destination directory
- :param fullpath: extract to fullpath
- :param overwrite: Overwrite existing archives
- :param renice: Renice value
- """
- self.m = m
- self.file = file
- self.out = out
- self.fullpath = fullpath
- self.overwrite = overwrite
- self.renice = renice
- self.files = [] # Store extracted files here
-
-
- def init(self):
- """ Initialize additional data structures """
- pass
-
-
- def checkArchive(self):
- """Check if password if needed. Raise ArchiveError if integrity is
- questionable.
-
- :return: boolean
- :raises ArchiveError
- """
- return False
-
- def checkPassword(self, password):
- """ Check if the given password is/might be correct.
- If it can not be decided at this point return true.
-
- :param password:
- :return: boolean
- """
- return True
-
- def extract(self, progress, password=None):
- """Extract the archive. Raise specific errors in case of failure.
-
- :param progress: Progress function, call this to update status
- :param password password to use
- :raises WrongPassword
- :raises CRCError
- :raises ArchiveError
- :return:
- """
- raise NotImplementedError
-
- def getDeleteFiles(self):
- """Return list of files to delete, do *not* delete them here.
-
- :return: List with paths of files to delete
- """
- raise NotImplementedError
-
- def getExtractedFiles(self):
- """Populate self.files at some point while extracting"""
- return self.files \ No newline at end of file
+ self.log.warning(_("Setting User and Group failed"), e) \ No newline at end of file