From 0e1ef9bc01579328e17e79416fa3c1c7b77adcc8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 8 Jun 2015 06:08:01 +0200 Subject: Update everything --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 3e371ec2b..67ebfc49c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -53,7 +53,7 @@ if os.name != "nt": from grp import getgrnam from pwd import getpwnam -from module.plugins.Hook import Hook, Expose, threaded +from module.plugins.internal.Hook import Hook, Expose, threaded from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError from module.plugins.internal.SimpleHoster import replace_patterns from module.utils import fs_encode, save_join, uniqify @@ -110,7 +110,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.44" + __version__ = "1.45" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), -- cgit v1.2.3 From da1180bc2d428ad52fbbecda8473fc1fb7267438 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 9 Jun 2015 01:52:24 +0200 Subject: [SimpleHoster] Improve checkFile --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 67ebfc49c..f311d5b49 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -482,7 +482,7 @@ class ExtractArchive(Hook): self.logWarning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message)) else: - self.logDebug(_("Successfully moved %s to trash") % os.path.basename(f)) + self.logDebug("Successfully moved %s to trash" % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From c9144f451b74e4d3cc67935b9e73c662ac870c6e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 07:18:39 +0200 Subject: Hook plugin code cosmetics (2) --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index f311d5b49..dae04c811 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -154,7 +154,7 @@ class ExtractArchive(Hook): self.repair = False - def coreReady(self): + def activate(self): for p in ("UnRar", "SevenZip", "UnZip"): try: module = self.core.pluginManager.loadModule("internal", p) -- cgit v1.2.3 From 5a139055ae658d3a05cbb658cbd66aeae0d01db5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 21:06:10 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/ExtractArchive.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index dae04c811..2c0d68f3e 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -56,7 +56,7 @@ if os.name != "nt": from module.plugins.internal.Hook import Hook, Expose, threaded from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError from module.plugins.internal.SimpleHoster import replace_patterns -from module.utils import fs_encode, save_join, uniqify +from module.utils import fs_encode, save_join as fs_join, uniqify class ArchiveQueue(object): @@ -220,7 +220,7 @@ class ExtractArchive(Hook): self.queue.remove(pid) - def packageFinished(self, pypack): + def package_finished(self, pypack): self.queue.add(pypack.id) if not self.getConfig('waitall') and not self.extracting: self.extractQueued() @@ -261,7 +261,7 @@ class ExtractArchive(Hook): # reload from txt file self.reloadPasswords() - download_folder = self.config['general']['download_folder'] + download_folder = self.core.config['general']['download_folder'] # iterate packages -> extractors -> targets for pid in ids: @@ -274,17 +274,17 @@ class ExtractArchive(Hook): self.logInfo(_("Check package: %s") % pypack.name) # determine output folder - out = save_join(download_folder, pypack.folder, destination, "") #: force trailing slash + out = fs_join(download_folder, pypack.folder, destination, "") #: force trailing slash if subfolder: - out = save_join(out, pypack.folder) + out = fs_join(out, pypack.folder) if not os.path.exists(out): os.makedirs(out) matched = False success = True - files_ids = dict((pylink['name'],((save_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ + files_ids = dict((pylink['name'],((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates # check as long there are unseen files @@ -344,7 +344,7 @@ class ExtractArchive(Hook): self.setPermissions(new_files) for filename in new_files: - file = fs_encode(save_join(os.path.dirname(archive.filename), filename)) + file = fs_encode(fs_join(os.path.dirname(archive.filename), filename)) if not os.path.exists(file): self.logDebug("New file %s does not exists" % filename) continue @@ -554,16 +554,16 @@ class ExtractArchive(Hook): continue try: - if self.config['permission']['change_file']: + if self.core.config['permission']['change_file']: if os.path.isfile(f): - os.chmod(f, int(self.config['permission']['file'], 8)) + os.chmod(f, int(self.core.config['permission']['file'], 8)) elif os.path.isdir(f): - os.chmod(f, int(self.config['permission']['folder'], 8)) + os.chmod(f, int(self.core.config['permission']['folder'], 8)) - if self.config['permission']['change_dl'] and os.name != "nt": - uid = getpwnam(self.config['permission']['user'])[2] - gid = getgrnam(self.config['permission']['group'])[2] + if self.core.config['permission']['change_dl'] and os.name != "nt": + uid = getpwnam(self.core.config['permission']['user'])[2] + gid = getgrnam(self.core.config['permission']['group'])[2] os.chown(f, uid, gid) except Exception, e: -- cgit v1.2.3 From c1764e2fea0bb05164c83a876e8cd58b97f58f25 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Jun 2015 17:31:38 +0200 Subject: Update all --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 2c0d68f3e..c9f368e9f 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -54,8 +54,8 @@ if os.name != "nt": from pwd import getpwnam from module.plugins.internal.Hook import Hook, Expose, threaded +from module.plugins.internal.Plugin import replace_patterns from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError -from module.plugins.internal.SimpleHoster import replace_patterns from module.utils import fs_encode, save_join as fs_join, uniqify -- cgit v1.2.3 From 164512b6a74c94a731fcee7435dce1ccfa2f71e7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:29:50 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/ExtractArchive.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c9f368e9f..ee41068eb 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -25,8 +25,10 @@ if sys.version_info < (2, 7) and os.name != "nt": # unsued timeout option for older python version def wait(self, timeout=0): - """Wait for child process to terminate. Returns returncode - attribute.""" + """ + Wait for child process to terminate. Returns returncode + attribute. + """ if self.returncode is None: try: pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0) @@ -209,7 +211,9 @@ class ExtractArchive(Hook): @Expose def extractPackage(self, *ids): - """ Extract packages with given id""" + """ + Extract packages with given id + """ for id in ids: self.queue.add(id) if not self.getConfig('waitall') and not self.extracting: @@ -261,7 +265,7 @@ class ExtractArchive(Hook): # reload from txt file self.reloadPasswords() - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") # iterate packages -> extractors -> targets for pid in ids: @@ -510,7 +514,9 @@ class ExtractArchive(Hook): @Expose def getPasswords(self, reload=True): - """ List of saved passwords """ + """ + List of saved passwords + """ if reload: self.reloadPasswords() @@ -535,7 +541,9 @@ class ExtractArchive(Hook): @Expose def addPassword(self, password): - """ Adds a password to saved list""" + """ + Adds a password to saved list + """ try: self.passwords = uniqify([password] + self.passwords) @@ -554,16 +562,16 @@ class ExtractArchive(Hook): continue try: - if self.core.config['permission']['change_file']: + if self.core.config.get("permission", "change_file"): if os.path.isfile(f): - os.chmod(f, int(self.core.config['permission']['file'], 8)) + os.chmod(f, int(self.core.config.get("permission", "file"), 8)) elif os.path.isdir(f): - os.chmod(f, int(self.core.config['permission']['folder'], 8)) + os.chmod(f, int(self.core.config.get("permission", "folder"), 8)) - if self.core.config['permission']['change_dl'] and os.name != "nt": - uid = getpwnam(self.core.config['permission']['user'])[2] - gid = getgrnam(self.core.config['permission']['group'])[2] + if self.core.config.get("permission", "change_dl") and os.name != "nt": + uid = getpwnam(self.core.config.get("permission", "user"))[2] + gid = getgrnam(self.core.config.get("permission", "group"))[2] os.chown(f, uid, gid) except Exception, e: -- cgit v1.2.3 From 20b6a2ec022202b0efb6cb69415239fb8f4d1445 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:59:20 +0200 Subject: Spare code cosmetics (2) --- module/plugins/hooks/ExtractArchive.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index ee41068eb..925976bc6 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -23,7 +23,7 @@ if sys.version_info < (2, 7) and os.name != "nt": raise - # unsued timeout option for older python version + #: unsued timeout option for older python version def wait(self, timeout=0): """ Wait for child process to terminate. Returns returncode @@ -36,9 +36,9 @@ if sys.version_info < (2, 7) and os.name != "nt": except OSError, e: if e.errno != errno.ECHILD: raise - # This happens if SIGCLD is set to be ignored or waiting - # for child processes has otherwise been disabled for our - # process. This child is dead, we can't get the status. + #: This happens if SIGCLD is set to be ignored or waiting + #: for child processes has otherwise been disabled for our + #: process. This child is dead, we can't get the status. sts = 0 self._handle_exitstatus(sts) return self.returncode @@ -262,12 +262,12 @@ class ExtractArchive(Hook): if extensions: self.logDebug("Use for extensions: %s" % "|.".join(extensions)) - # reload from txt file + #: reload from txt file self.reloadPasswords() download_folder = self.core.config.get("general", "download_folder") - # iterate packages -> extractors -> targets + #: iterate packages -> extractors -> targets for pid in ids: pypack = self.core.files.getPackage(pid) @@ -277,7 +277,7 @@ class ExtractArchive(Hook): self.logInfo(_("Check package: %s") % pypack.name) - # determine output folder + #: determine output folder out = fs_join(download_folder, pypack.folder, destination, "") #: force trailing slash if subfolder: @@ -291,7 +291,7 @@ class ExtractArchive(Hook): files_ids = dict((pylink['name'],((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates - # check as long there are unseen files + #: check as long there are unseen files while files_ids: new_files_ids = [] @@ -341,7 +341,7 @@ class ExtractArchive(Hook): success = False continue - # remove processed file and related multiparts from list + #: remove processed file and related multiparts from list files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if fname not in archive.getDeleteFiles()] self.logDebug("Extracted files: %s" % new_files) -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/hooks/ExtractArchive.py | 173 +++++++++++++++++---------------- 1 file changed, 87 insertions(+), 86 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 925976bc6..73782ed95 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -70,7 +70,7 @@ class ArchiveQueue(object): def get(self): try: - return [int(pid) for pid in self.plugin.getStorage("ExtractArchive:%s" % self.storage, "").decode('base64').split()] + return [int(pid) for pid in self.plugin.retrieve("ExtractArchive:%s" % self.storage, "").decode('base64').split()] except Exception: return [] @@ -80,11 +80,11 @@ class ArchiveQueue(object): item = str(value)[1:-1].replace(' ', '').replace(',', ' ') else: item = str(value).strip() - return self.plugin.setStorage("ExtractArchive:%s" % self.storage, item.encode('base64')[:-1]) + return self.plugin.store("ExtractArchive:%s" % self.storage, item.encode('base64')[:-1]) def delete(self): - return self.plugin.delStorage("ExtractArchive:%s" % self.storage) + return self.plugin.delete("ExtractArchive:%s" % self.storage) def add(self, item): @@ -112,7 +112,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.45" + __version__ = "1.46" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -143,14 +143,15 @@ class ExtractArchive(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - self.event_list = ["allDownloadsProcessed","packageDeleted"] + self.event_map = {'allDownloadsProcessed': "all_downloads_processed", + 'packageDeleted' : "package_deleted" } self.queue = ArchiveQueue(self, "Queue") self.failed = ArchiveQueue(self, "Failed") self.interval = 60 self.extracting = False - self.lastPackage = False + self.last_package = False self.extractors = [] self.passwords = [] self.repair = False @@ -164,30 +165,30 @@ class ExtractArchive(Hook): if klass.isUsable(): self.extractors.append(klass) if klass.REPAIR: - self.repair = self.getConfig('repair') + self.repair = self.get_config('repair') except OSError, e: if e.errno == 2: - self.logWarning(_("No %s installed") % p) + self.log_warning(_("No %s installed") % p) else: - self.logWarning(_("Could not activate: %s") % p, e) + self.log_warning(_("Could not activate: %s") % p, e) if self.core.debug: traceback.print_exc() except Exception, e: - self.logWarning(_("Could not activate: %s") % p, e) + self.log_warning(_("Could not activate: %s") % p, e) if self.core.debug: traceback.print_exc() if self.extractors: - self.logDebug(*["Found %s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors]) - self.extractQueued() #: Resume unfinished extractions + self.log_debug(*["Found %s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors]) + self.extract_queued() #: Resume unfinished extractions else: - self.logInfo(_("No Extract plugins activated")) + self.log_info(_("No Extract plugins activated")) @threaded - def extractQueued(self, thread): + def extract_queued(self, thread): if self.extracting: #@NOTE: doing the check here for safty (called by coreReady) return @@ -195,8 +196,8 @@ class ExtractArchive(Hook): packages = self.queue.get() while packages: - if self.lastPackage: #: called from allDownloadsProcessed - self.lastPackage = False + if self.last_package: #: called from allDownloadsProcessed + self.last_package = False if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") self.manager.dispatchEvent("all_archives_processed") @@ -210,30 +211,30 @@ class ExtractArchive(Hook): @Expose - def extractPackage(self, *ids): + def extract_package(self, *ids): """ Extract packages with given id """ for id in ids: self.queue.add(id) - if not self.getConfig('waitall') and not self.extracting: - self.extractQueued() + if not self.get_config('waitall') and not self.extracting: + self.extract_queued() - def packageDeleted(self, pid): + def package_deleted(self, pid): self.queue.remove(pid) def package_finished(self, pypack): self.queue.add(pypack.id) - if not self.getConfig('waitall') and not self.extracting: - self.extractQueued() + if not self.get_config('waitall') and not self.extracting: + self.extract_queued() - def allDownloadsProcessed(self): - self.lastPackage = True - if self.getConfig('waitall') and not self.extracting: - self.extractQueued() + def all_downloads_processed(self): + self.last_package = True + if self.get_config('waitall') and not self.extracting: + self.extract_queued() @Expose @@ -247,23 +248,23 @@ class ExtractArchive(Hook): toList = lambda string: string.replace(' ', '').replace(',', '|').replace(';', '|').split('|') - destination = self.getConfig('destination') - subfolder = self.getConfig('subfolder') - fullpath = self.getConfig('fullpath') - overwrite = self.getConfig('overwrite') - renice = self.getConfig('renice') - recursive = self.getConfig('recursive') - delete = self.getConfig('delete') - keepbroken = self.getConfig('keepbroken') + destination = self.get_config('destination') + subfolder = self.get_config('subfolder') + fullpath = self.get_config('fullpath') + overwrite = self.get_config('overwrite') + renice = self.get_config('renice') + recursive = self.get_config('recursive') + delete = self.get_config('delete') + keepbroken = self.get_config('keepbroken') - extensions = [x.lstrip('.').lower() for x in toList(self.getConfig('extensions'))] - excludefiles = toList(self.getConfig('excludefiles')) + extensions = [x.lstrip('.').lower() for x in toList(self.get_config('extensions'))] + excludefiles = toList(self.get_config('excludefiles')) if extensions: - self.logDebug("Use for extensions: %s" % "|.".join(extensions)) + self.log_debug("Use for extensions: %s" % "|.".join(extensions)) #: reload from txt file - self.reloadPasswords() + self.reload_passwords() download_folder = self.core.config.get("general", "download_folder") @@ -275,7 +276,7 @@ class ExtractArchive(Hook): self.queue.remove(pid) continue - self.logInfo(_("Check package: %s") % pypack.name) + self.log_info(_("Check package: %s") % pypack.name) #: determine output folder out = fs_join(download_folder, pypack.folder, destination, "") #: force trailing slash @@ -302,17 +303,17 @@ class ExtractArchive(Hook): for Extractor in self.extractors: targets = Extractor.getTargets(files_ids) if targets: - self.logDebug("Targets for %s: %s" % (Extractor.__name__, targets)) + self.log_debug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True for fname, fid, fout in targets: name = os.path.basename(fname) if not os.path.exists(fname): - self.logDebug(name, "File not found") + self.log_debug(name, "File not found") continue - self.logInfo(name, _("Extract to: %s") % fout) + self.log_info(name, _("Extract to: %s") % fout) try: pyfile = self.core.files.getFile(fid) archive = Extractor(self, @@ -337,20 +338,20 @@ class ExtractArchive(Hook): thread.finishFile(pyfile) except Exception, e: - self.logError(name, e) + self.log_error(name, e) success = False continue #: remove processed file and related multiparts from list files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if fname not in archive.getDeleteFiles()] - self.logDebug("Extracted files: %s" % new_files) - self.setPermissions(new_files) + self.log_debug("Extracted files: %s" % new_files) + self.set_permissions(new_files) for filename in new_files: file = fs_encode(fs_join(os.path.dirname(archive.filename), filename)) if not os.path.exists(file): - self.logDebug("New file %s does not exists" % filename) + self.log_debug("New file %s does not exists" % filename) continue if recursive and os.path.isfile(file): @@ -371,7 +372,7 @@ class ExtractArchive(Hook): self.failed.add(pid) else: - self.logInfo(_("No files found to extract")) + self.log_info(_("No files found to extract")) if not matched or not success and subfolder: try: @@ -392,44 +393,44 @@ class ExtractArchive(Hook): encrypted = False try: - self.logDebug("Password: %s" % (password or "None provided")) - passwords = uniqify([password] + self.getPasswords(False)) if self.getConfig('usepasswordfile') else [password] + self.log_debug("Password: %s" % (password or "None provided")) + passwords = uniqify([password] + self.get_passwords(False)) if self.get_config('usepasswordfile') else [password] for pw in passwords: try: - if self.getConfig('test') or self.repair: + if self.get_config('test') or self.repair: pyfile.setCustomStatus(_("archive testing")) if pw: - self.logDebug("Testing with password: %s" % pw) + self.log_debug("Testing with password: %s" % pw) pyfile.setProgress(0) archive.verify(pw) pyfile.setProgress(100) else: archive.check(pw) - self.addPassword(pw) + self.add_password(pw) break except PasswordError: if not encrypted: - self.logInfo(name, _("Password protected")) + self.log_info(name, _("Password protected")) encrypted = True except CRCError, e: - self.logDebug(name, e) - self.logInfo(name, _("CRC Error")) + self.log_debug(name, e) + self.log_info(name, _("CRC Error")) if self.repair: - self.logWarning(name, _("Repairing...")) + self.log_warning(name, _("Repairing...")) pyfile.setCustomStatus(_("archive repairing")) pyfile.setProgress(0) repaired = archive.repair() pyfile.setProgress(100) - if not repaired and not self.getConfig('keepbroken'): + if not repaired and not self.get_config('keepbroken'): raise CRCError("Archive damaged") - self.addPassword(pw) + self.add_password(pw) break raise CRCError("Archive damaged") @@ -440,20 +441,20 @@ class ExtractArchive(Hook): pyfile.setCustomStatus(_("extracting")) pyfile.setProgress(0) - if not encrypted or not self.getConfig('usepasswordfile'): - self.logDebug("Extracting using password: %s" % (password or "None")) + if not encrypted or not self.get_config('usepasswordfile'): + self.log_debug("Extracting using password: %s" % (password or "None")) archive.extract(password) else: - for pw in filter(None, uniqify([password] + self.getPasswords(False))): + for pw in filter(None, uniqify([password] + self.get_passwords(False))): try: - self.logDebug("Extracting using password: %s" % pw) + self.log_debug("Extracting using password: %s" % pw) archive.extract(pw) - self.addPassword(pw) + self.add_password(pw) break except PasswordError: - self.logDebug("Password was wrong") + self.log_debug("Password was wrong") else: raise PasswordError @@ -461,12 +462,12 @@ class ExtractArchive(Hook): pyfile.setStatus("processing") delfiles = archive.getDeleteFiles() - self.logDebug("Would delete: " + ", ".join(delfiles)) + self.log_debug("Would delete: " + ", ".join(delfiles)) - if self.getConfig('delete'): - self.logInfo(_("Deleting %s files") % len(delfiles)) + if self.get_config('delete'): + self.log_info(_("Deleting %s files") % len(delfiles)) - deltotrash = self.getConfig('deltotrash') + deltotrash = self.get_config('deltotrash') for f in delfiles: file = fs_encode(f) if not os.path.exists(file): @@ -480,30 +481,30 @@ class ExtractArchive(Hook): send2trash.send2trash(file) except NameError: - self.logWarning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f)) + self.log_warning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f)) except Exception, e: - self.logWarning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message)) + self.log_warning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message)) else: - self.logDebug("Successfully moved %s to trash" % os.path.basename(f)) + self.log_debug("Successfully moved %s to trash" % os.path.basename(f)) - self.logInfo(name, _("Extracting finished")) + self.log_info(name, _("Extracting finished")) extracted_files = archive.files or archive.list() return extracted_files except PasswordError: - self.logError(name, _("Wrong password" if password else "No password found")) + self.log_error(name, _("Wrong password" if password else "No password found")) except CRCError, e: - self.logError(name, _("CRC mismatch"), e) + self.log_error(name, _("CRC mismatch"), e) except ArchiveError, e: - self.logError(name, _("Archive error"), e) + self.log_error(name, _("Archive error"), e) except Exception, e: - self.logError(name, _("Unknown error"), e) + self.log_error(name, _("Unknown error"), e) if self.core.debug: traceback.print_exc() @@ -513,50 +514,50 @@ class ExtractArchive(Hook): @Expose - def getPasswords(self, reload=True): + def get_passwords(self, reload=True): """ List of saved passwords """ if reload: - self.reloadPasswords() + self.reload_passwords() return self.passwords - def reloadPasswords(self): + def reload_passwords(self): try: passwords = [] - file = fs_encode(self.getConfig('passwordfile')) + file = fs_encode(self.get_config('passwordfile')) with open(file) as f: for pw in f.read().splitlines(): passwords.append(pw) except IOError, e: - self.logError(e) + self.log_error(e) else: self.passwords = passwords @Expose - def addPassword(self, password): + def add_password(self, password): """ Adds a password to saved list """ try: self.passwords = uniqify([password] + self.passwords) - file = fs_encode(self.getConfig('passwordfile')) + file = fs_encode(self.get_config('passwordfile')) with open(file, "wb") as f: for pw in self.passwords: f.write(pw + '\n') except IOError, e: - self.logError(e) + self.log_error(e) - def setPermissions(self, files): + def set_permissions(self, files): for f in files: if not os.path.exists(f): continue @@ -575,4 +576,4 @@ class ExtractArchive(Hook): os.chown(f, uid, gid) except Exception, e: - self.logWarning(_("Setting User and Group failed"), e) + self.log_warning(_("Setting User and Group failed"), e) -- cgit v1.2.3 From d2e2b127651a5a44b56337eb6d9ca246c97a208a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Jul 2015 03:03:26 +0200 Subject: Spare fixes and code cosmetics --- module/plugins/hooks/ExtractArchive.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 73782ed95..9ca7bf854 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -162,7 +162,7 @@ class ExtractArchive(Hook): try: module = self.core.pluginManager.loadModule("internal", p) klass = getattr(module, p) - if klass.isUsable(): + if klass.is_usable(): self.extractors.append(klass) if klass.REPAIR: self.repair = self.get_config('repair') @@ -210,6 +210,15 @@ class ExtractArchive(Hook): self.extracting = False + #: Deprecated method, use `extract_package` instead + @Expose + def extractPackage(self, *args, **kwargs): + """ + See `extract_package` + """ + return self.extract_package(*args, **kwargs) + + @Expose def extract_package(self, *ids): """ @@ -301,7 +310,7 @@ class ExtractArchive(Hook): if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: - targets = Extractor.getTargets(files_ids) + targets = Extractor.get_targets(files_ids) if targets: self.log_debug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True @@ -513,6 +522,15 @@ class ExtractArchive(Hook): raise Exception(_("Extract failed")) + #: Deprecated method, use `get_passwords` instead + @Expose + def getPasswords(self, *args, **kwargs): + """ + See `get_passwords` + """ + return self.get_passwords(*args, **kwargs) + + @Expose def get_passwords(self, reload=True): """ @@ -540,6 +558,15 @@ class ExtractArchive(Hook): self.passwords = passwords + #: Deprecated method, use `add_password` instead + @Expose + def addPassword(self, *args, **kwargs): + """ + See `add_password` + """ + return self.add_password(*args, **kwargs) + + @Expose def add_password(self, password): """ -- cgit v1.2.3 From dad722ac7255640e7e0541c4094a4d2e4de79cd3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 00:05:58 +0200 Subject: Code cosmetics (2) --- module/plugins/hooks/ExtractArchive.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 9ca7bf854..ad9f67a1a 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -23,7 +23,7 @@ if sys.version_info < (2, 7) and os.name != "nt": raise - #: unsued timeout option for older python version + #: Unsued timeout option for older python version def wait(self, timeout=0): """ Wait for child process to terminate. Returns returncode @@ -36,8 +36,8 @@ if sys.version_info < (2, 7) and os.name != "nt": except OSError, e: if e.errno != errno.ECHILD: raise - #: This happens if SIGCLD is set to be ignored or waiting - #: for child processes has otherwise been disabled for our + #: This happens if SIGCLD is set to be ignored or waiting + #: For child processes has otherwise been disabled for our #: process. This child is dead, we can't get the status. sts = 0 self._handle_exitstatus(sts) @@ -196,7 +196,7 @@ class ExtractArchive(Hook): packages = self.queue.get() while packages: - if self.last_package: #: called from allDownloadsProcessed + if self.last_package: #: Called from allDownloadsProcessed self.last_package = False if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") @@ -205,7 +205,7 @@ class ExtractArchive(Hook): if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now pass - packages = self.queue.get() #: check for packages added during extraction + packages = self.queue.get() #: Check for packages added during extraction self.extracting = False @@ -272,12 +272,12 @@ class ExtractArchive(Hook): if extensions: self.log_debug("Use for extensions: %s" % "|.".join(extensions)) - #: reload from txt file + #: Reload from txt file self.reload_passwords() download_folder = self.core.config.get("general", "download_folder") - #: iterate packages -> extractors -> targets + #: Iterate packages -> extractors -> targets for pid in ids: pypack = self.core.files.getPackage(pid) @@ -287,8 +287,8 @@ class ExtractArchive(Hook): self.log_info(_("Check package: %s") % pypack.name) - #: determine output folder - out = fs_join(download_folder, pypack.folder, destination, "") #: force trailing slash + #: Determine output folder + out = fs_join(download_folder, pypack.folder, destination, "") #: Force trailing slash if subfolder: out = fs_join(out, pypack.folder) @@ -299,9 +299,9 @@ class ExtractArchive(Hook): matched = False success = True files_ids = dict((pylink['name'],((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ - in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates + in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: Remove duplicates - #: check as long there are unseen files + #: Check as long there are unseen files while files_ids: new_files_ids = [] @@ -351,7 +351,7 @@ class ExtractArchive(Hook): success = False continue - #: remove processed file and related multiparts from list + #: Remove processed file and related multiparts from list files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if fname not in archive.getDeleteFiles()] self.log_debug("Extracted files: %s" % new_files) @@ -364,11 +364,11 @@ class ExtractArchive(Hook): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid, os.path.dirname(filename))) #: append as new target + new_files_ids.append((filename, fid, os.path.dirname(filename))) #: Append as new target self.manager.dispatchEvent("archive_extracted", pyfile, archive) - files_ids = new_files_ids #: also check extracted files + files_ids = new_files_ids #: Also check extracted files if matched: if success: -- cgit v1.2.3 From 502517f37c7540b0bddb092e69386d9d6f08800c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 09:42:34 +0200 Subject: Fix addons --- module/plugins/hooks/ExtractArchive.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index ad9f67a1a..cead3595c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -55,7 +55,7 @@ if os.name != "nt": from grp import getgrnam from pwd import getpwnam -from module.plugins.internal.Hook import Hook, Expose, threaded +from module.plugins.internal.Addon import Addon, Expose, threaded from module.plugins.internal.Plugin import replace_patterns from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError from module.utils import fs_encode, save_join as fs_join, uniqify @@ -109,7 +109,7 @@ class ArchiveQueue(object): return self.set(queue) -class ExtractArchive(Hook): +class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" __version__ = "1.46" @@ -141,8 +141,7 @@ class ExtractArchive(Hook): NAME_REPLACEMENTS = [(r'\.part\d+\.rar$', ".part.rar")] - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): self.event_map = {'allDownloadsProcessed': "all_downloads_processed", 'packageDeleted' : "package_deleted" } -- cgit v1.2.3 From 56389e28ba5d2f5658278bc7f486d73be747f135 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 11:44:49 +0200 Subject: Rename self.core to self.pyload (plugins only) --- module/plugins/hooks/ExtractArchive.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index cead3595c..92774b423 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -159,7 +159,7 @@ class ExtractArchive(Addon): def activate(self): for p in ("UnRar", "SevenZip", "UnZip"): try: - module = self.core.pluginManager.loadModule("internal", p) + module = self.pyload.pluginManager.loadModule("internal", p) klass = getattr(module, p) if klass.is_usable(): self.extractors.append(klass) @@ -171,12 +171,12 @@ class ExtractArchive(Addon): self.log_warning(_("No %s installed") % p) else: self.log_warning(_("Could not activate: %s") % p, e) - if self.core.debug: + if self.pyload.debug: traceback.print_exc() except Exception, e: self.log_warning(_("Could not activate: %s") % p, e) - if self.core.debug: + if self.pyload.debug: traceback.print_exc() if self.extractors: @@ -274,11 +274,11 @@ class ExtractArchive(Addon): #: Reload from txt file self.reload_passwords() - download_folder = self.core.config.get("general", "download_folder") + download_folder = self.pyload.config.get("general", "download_folder") #: Iterate packages -> extractors -> targets for pid in ids: - pypack = self.core.files.getPackage(pid) + pypack = self.pyload.files.getPackage(pid) if not pypack: self.queue.remove(pid) @@ -323,7 +323,7 @@ class ExtractArchive(Addon): self.log_info(name, _("Extract to: %s") % fout) try: - pyfile = self.core.files.getFile(fid) + pyfile = self.pyload.files.getFile(fid) archive = Extractor(self, fname, fout, @@ -513,7 +513,7 @@ class ExtractArchive(Addon): except Exception, e: self.log_error(name, _("Unknown error"), e) - if self.core.debug: + if self.pyload.debug: traceback.print_exc() self.manager.dispatchEvent("archive_extract_failed", pyfile, archive) @@ -589,16 +589,16 @@ class ExtractArchive(Addon): continue try: - if self.core.config.get("permission", "change_file"): + if self.pyload.config.get("permission", "change_file"): if os.path.isfile(f): - os.chmod(f, int(self.core.config.get("permission", "file"), 8)) + os.chmod(f, int(self.pyload.config.get("permission", "file"), 8)) elif os.path.isdir(f): - os.chmod(f, int(self.core.config.get("permission", "folder"), 8)) + os.chmod(f, int(self.pyload.config.get("permission", "folder"), 8)) - if self.core.config.get("permission", "change_dl") and os.name != "nt": - uid = getpwnam(self.core.config.get("permission", "user"))[2] - gid = getgrnam(self.core.config.get("permission", "group"))[2] + if self.pyload.config.get("permission", "change_dl") and os.name != "nt": + uid = getpwnam(self.pyload.config.get("permission", "user"))[2] + gid = getgrnam(self.pyload.config.get("permission", "group"))[2] os.chown(f, uid, gid) except Exception, e: -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/hooks/ExtractArchive.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 92774b423..8a52fed55 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -113,6 +113,7 @@ class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" __version__ = "1.46" + __status__ = "stable" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), -- cgit v1.2.3 From c2091ebec0ce394ec847f82db9bbaddc150d5fca Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 21 Jul 2015 22:55:54 +0200 Subject: [Extractor] is_usable -> find --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8a52fed55..6f353f538 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -112,7 +112,7 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.46" + __version__ = "1.47" __status__ = "stable" __config__ = [("activated" , "bool" , "Activated" , True ), @@ -162,7 +162,7 @@ class ExtractArchive(Addon): try: module = self.pyload.pluginManager.loadModule("internal", p) klass = getattr(module, p) - if klass.is_usable(): + if klass.find(): self.extractors.append(klass) if klass.REPAIR: self.repair = self.get_config('repair') -- cgit v1.2.3 From 4fc28dc09f9632eb4a15a1ef48778427f9dcae33 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 23 Jul 2015 18:53:06 +0200 Subject: Code cosmetics --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6f353f538..0f757f258 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -298,7 +298,7 @@ class ExtractArchive(Addon): matched = False success = True - files_ids = dict((pylink['name'],((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ + files_ids = dict((pylink['name'], ((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: Remove duplicates #: Check as long there are unseen files -- cgit v1.2.3 From 94d017cd2a5c1f194960827a8c7e46afc3682008 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 06:55:49 +0200 Subject: Hotfixes (2) --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 0f757f258..03a3d00bf 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -113,7 +113,7 @@ class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" __version__ = "1.47" - __status__ = "stable" + __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), -- cgit v1.2.3 From 761ca5c66e07559925ebbdbc6531f9ca658b12ce Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 16:11:58 +0200 Subject: Code cosmetics --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 03a3d00bf..5a51319ad 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -103,7 +103,7 @@ class ArchiveQueue(object): except ValueError: pass - if queue == []: + if queue is []: return self.delete() return self.set(queue) -- cgit v1.2.3 From 952001324e1faf584b1adcb01c4a0406a3722932 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Jul 2015 09:42:49 +0200 Subject: =?UTF-8?q?Don't=20user=20dictionary=E2=80=99s=20iterator=20method?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 5a51319ad..2e45f4a38 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -299,7 +299,7 @@ class ExtractArchive(Addon): matched = False success = True files_ids = dict((pylink['name'], ((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ - in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: Remove duplicates + in sorted(pypack.getChildren().values(), key=lambda k: k['name'])).values() #: Remove duplicates #: Check as long there are unseen files while files_ids: -- cgit v1.2.3 From 3e350f1da4f760a02a65928175f24fd38e689b6b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Jul 2015 20:38:21 +0200 Subject: [ExtractArchive] Rename archive_password.txt -> passwords.txt --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 2e45f4a38..ffcb6e738 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -122,7 +122,7 @@ class ExtractArchive(Addon): ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), ("test" , "bool" , "Test archive before extracting" , False ), ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("passwordfile" , "file" , "Password file" , "passwords.txt" ), ("delete" , "bool" , "Delete archive after extraction" , True ), ("deltotrash" , "bool" , "Move to trash (recycle bin) instead delete", True ), ("subfolder" , "bool" , "Create subfolder for each package" , False ), -- cgit v1.2.3 From 5a2781c923ecd13f3e671366fa6fa311d92d8547 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 29 Jul 2015 08:21:04 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1586 --- module/plugins/hooks/ExtractArchive.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index ffcb6e738..98dea58ca 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -112,7 +112,7 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.47" + __version__ = "1.48" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , True ), @@ -490,13 +490,15 @@ class ExtractArchive(Addon): send2trash.send2trash(file) except NameError: - self.log_warning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f)) + self.log_warning(_("Unable to move %s to trash") % os.path.basename(f), + _("Send2Trash lib not found")) except Exception, e: - self.log_warning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message)) + self.log_warning(_("Unable to move %s to trash") % os.path.basename(f), + e.message) else: - self.log_debug("Successfully moved %s to trash" % os.path.basename(f)) + self.log_info(_("Moved %s to trash") % os.path.basename(f)) self.log_info(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From 6a38ae35495d39f5c2649434810a9d507abcbf20 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 29 Jul 2015 13:05:30 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1594 (2) --- module/plugins/hooks/ExtractArchive.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 98dea58ca..62139ccc5 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -112,7 +112,7 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.48" + __version__ = "1.49" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , True ), @@ -353,7 +353,7 @@ class ExtractArchive(Addon): #: Remove processed file and related multiparts from list files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ - if fname not in archive.getDeleteFiles()] + if fname not in archive.get_delete_files()] self.log_debug("Extracted files: %s" % new_files) self.set_permissions(new_files) @@ -470,7 +470,7 @@ class ExtractArchive(Addon): pyfile.setProgress(100) pyfile.setStatus("processing") - delfiles = archive.getDeleteFiles() + delfiles = archive.get_delete_files() self.log_debug("Would delete: " + ", ".join(delfiles)) if self.get_config('delete'): -- cgit v1.2.3 From 092112b44af84c7a59b1fa2cfff5c5875e778a8f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 31 Jul 2015 02:21:35 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1625 --- module/plugins/hooks/ExtractArchive.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 62139ccc5..a71ec0e98 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -355,7 +355,9 @@ class ExtractArchive(Addon): files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if fname not in archive.get_delete_files()] self.log_debug("Extracted files: %s" % new_files) - self.set_permissions(new_files) + + for file in new_files: + self.set_permissions(file) for filename in new_files: file = fs_encode(fs_join(os.path.dirname(archive.filename), filename)) @@ -584,25 +586,3 @@ class ExtractArchive(Addon): except IOError, e: self.log_error(e) - - - def set_permissions(self, files): - for f in files: - if not os.path.exists(f): - continue - - try: - if self.pyload.config.get("permission", "change_file"): - if os.path.isfile(f): - os.chmod(f, int(self.pyload.config.get("permission", "file"), 8)) - - elif os.path.isdir(f): - os.chmod(f, int(self.pyload.config.get("permission", "folder"), 8)) - - if self.pyload.config.get("permission", "change_dl") and os.name != "nt": - uid = getpwnam(self.pyload.config.get("permission", "user"))[2] - gid = getgrnam(self.pyload.config.get("permission", "group"))[2] - os.chown(f, uid, gid) - - except Exception, e: - self.log_warning(_("Setting User and Group failed"), e) -- cgit v1.2.3 From 8a8323f3fd86985a5ca876e8d54f1699e75b24a8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 31 Jul 2015 07:37:10 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1628 --- module/plugins/hooks/ExtractArchive.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'module/plugins/hooks/ExtractArchive.py') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index a71ec0e98..eab196160 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -50,11 +50,6 @@ try: except ImportError: pass -from copy import copy -if os.name != "nt": - from grp import getgrnam - from pwd import getpwnam - from module.plugins.internal.Addon import Addon, Expose, threaded from module.plugins.internal.Plugin import replace_patterns from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError -- cgit v1.2.3