diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-13 09:22:01 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-13 09:22:01 +0200 |
commit | 2432ade6c9bd7284a5bf0d760796638eef634be9 (patch) | |
tree | 877cfd29c6e5117a974377ead73cbbc150f6544d /pyload/plugin/addon | |
parent | Prepare hook plugins to merging from stable (diff) | |
parent | [LolabitsEs] Cleanup (diff) | |
download | pyload-2432ade6c9bd7284a5bf0d760796638eef634be9.tar.xz |
Merge branch 'stable' into 0.4.10
Conflicts:
module/plugins/hooks/MultihostersComHook.py
module/plugins/hooks/PutdriveComHook.py
module/plugins/internal/CaptchaService.py
pyload/plugin/account/OboomCom.py
pyload/plugin/account/SmoozedCom.py
pyload/plugin/addon/AntiVirus.py
pyload/plugin/addon/ExternalScripts.py
pyload/plugin/addon/ExtractArchive.py
pyload/plugin/addon/RestartSlow.py
pyload/plugin/crypter/CrockoCom.py
pyload/plugin/crypter/DepositfilesCom.py
pyload/plugin/crypter/FshareVn.py
pyload/plugin/crypter/LinkdecrypterCom.py
pyload/plugin/crypter/MegaRapidCz.py
pyload/plugin/crypter/PastebinCom.py
pyload/plugin/hoster/CatShareNet.py
pyload/plugin/hoster/EdiskCz.py
pyload/plugin/hoster/ExtabitCom.py
pyload/plugin/hoster/GigapetaCom.py
pyload/plugin/hoster/GooIm.py
pyload/plugin/hoster/IfolderRu.py
pyload/plugin/hoster/LuckyShareNet.py
pyload/plugin/hoster/MegasharesCom.py
pyload/plugin/hoster/MovReelCom.py
pyload/plugin/hoster/NarodRu.py
pyload/plugin/hoster/NowDownloadSx.py
pyload/plugin/hoster/NowVideoSx.py
pyload/plugin/hoster/QuickshareCz.py
pyload/plugin/hoster/RemixshareCom.py
pyload/plugin/hoster/RgHostNet.py
pyload/plugin/hoster/SendspaceCom.py
pyload/plugin/hoster/UlozTo.py
pyload/plugin/hoster/UnibytesCom.py
pyload/plugin/hoster/UploadingCom.py
pyload/plugin/hoster/WrzucTo.py
pyload/plugin/internal/MultiHook.py
pyload/plugin/internal/SimpleHoster.py
Diffstat (limited to 'pyload/plugin/addon')
-rw-r--r-- | pyload/plugin/addon/AntiVirus.py | 45 | ||||
-rw-r--r-- | pyload/plugin/addon/DeleteFinished.py | 5 | ||||
-rw-r--r-- | pyload/plugin/addon/ExternalScripts.py | 18 | ||||
-rw-r--r-- | pyload/plugin/addon/ExtractArchive.py | 93 | ||||
-rw-r--r-- | pyload/plugin/addon/IRCInterface.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/MergeFiles.py | 5 | ||||
-rw-r--r-- | pyload/plugin/addon/RestartSlow.py | 57 | ||||
-rw-r--r-- | pyload/plugin/addon/UpdateManager.py | 4 |
8 files changed, 102 insertions, 129 deletions
diff --git a/pyload/plugin/addon/AntiVirus.py b/pyload/plugin/addon/AntiVirus.py index 619893735..2213cddc1 100644 --- a/pyload/plugin/addon/AntiVirus.py +++ b/pyload/plugin/addon/AntiVirus.py @@ -11,21 +11,39 @@ from pyload.utils import fs_encode, fs_join class AntiVirus(Addon): __name__ = "AntiVirus" __type__ = "addon" - __version__ = "0.05" + __version__ = "0.07" #@TODO: add trash option (use Send2Trash lib) - __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), - ("quardir" , "folder" , "Quarantine folder" , "" ), - ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), - ("cmdfile" , "file" , "Antivirus executable" , "" ), - ("cmdargs" , "str" , "Scan options" , "" ), - ("ignore-err", "bool" , "Ignore scan errors" , False )] + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + ("quardir" , "folder" , "Quarantine folder" , "" ), + ("deltotrash", "bool" , "Move to trash (recycle bin) instead delete", True ), + ("scanfailed", "bool" , "Scan incompleted files (failed downloads)" , False ), + ("cmdfile" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" ), + ("ignore-err", "bool" , "Ignore scan errors" , False )] __description__ = """Scan downloaded files with antivirus program""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + interval = 0 #@TODO: Remove in 0.4.10 + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + try: + import send2trash + + except ImportError: + self.logDebug("Send2Trash lib not found") + self.trashable = False + + else: + self.trashable = True + + @Expose @threaded def scan(self, pyfile, thread): @@ -39,6 +57,7 @@ class AntiVirus(Addon): thread.addActive(pyfile) pyfile.setCustomStatus(_("virus scanning")) + pyfile.setProgress(0) try: p = subprocess.Popen([cmdfile, cmdargs, file], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -59,11 +78,19 @@ class AntiVirus(Addon): action = self.getConfig('action') try: if action == "Delete": - os.remove(file) + if not self.getConfig('deltotrash'): + os.remove(file) + + elif self.trashable: + send2trash.send2trash(file) + + else: + self.logWarning(_("Unable to move file to trash, move to quarantine instead")) + pyfile.setCustomStatus(_("file moving")) + shutil.move(file, self.getConfig('quardir')) elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) - pyfile.setProgress(0) shutil.move(file, self.getConfig('quardir')) except (IOError, shutil.Error), e: diff --git a/pyload/plugin/addon/DeleteFinished.py b/pyload/plugin/addon/DeleteFinished.py index 8bb681cca..801e48ed6 100644 --- a/pyload/plugin/addon/DeleteFinished.py +++ b/pyload/plugin/addon/DeleteFinished.py @@ -9,9 +9,8 @@ class DeleteFinished(Addon): __type__ = "addon" __version__ = "1.12" - __config__ = [("activated" , "bool", "Activated" , "False"), - ("interval" , "int" , "Delete every (hours)" , "72" ), - ("deloffline", "bool", "Delete packages with offline links", "False")] + __config__ = [("interval" , "int" , "Check interval in hours" , 72 ), + ("deloffline", "bool", "Delete package with offline links", False)] __description__ = """Automatically delete all finished packages from queue""" __license__ = "GPLv3" diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py index 502a6dc7b..05b1d7b65 100644 --- a/pyload/plugin/addon/ExternalScripts.py +++ b/pyload/plugin/addon/ExternalScripts.py @@ -10,7 +10,7 @@ from pyload.utils import fs_encode, fs_join class ExternalScripts(Addon): __name__ = "ExternalScripts" __type__ = "addon" - __version__ = "0.37" + __version__ = "0.39" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -119,7 +119,7 @@ class ExternalScripts(Addon): def downloadPreparing(self, pyfile): for script in self.scripts['download_preparing']: - self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, None) + self.callScript(script, pyfile.id, pyfile.name, None, pyfile.pluginname, pyfile.url) def downloadFailed(self, pyfile): @@ -130,7 +130,7 @@ class ExternalScripts(Addon): for script in self.scripts['download_failed']: file = fs_join(download_folder, pyfile.name) - self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) + self.callScript(script, pyfile.id, pyfile.name, file, pyfile.pluginname, pyfile.url) def downloadFinished(self, pyfile): @@ -141,17 +141,17 @@ class ExternalScripts(Addon): for script in self.scripts['download_finished']: file = fs_join(download_folder, pyfile.name) - self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) + self.callScript(script, pyfile.id, pyfile.name, file, pyfile.pluginname, pyfile.url) def archive_extract_failed(self, pyfile, archive): for script in self.scripts['archive_extract_failed']: - self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) + self.callScript(script, pyfile.id, pyfile.name, archive.filename, archive.out, archive.files) def archive_extracted(self, pyfile, archive): for script in self.scripts['archive_extracted']: - self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) + self.callScript(script, pyfile.id, pyfile.name, archive.filename, archive.out, archive.files) def packageFinished(self, pypack): @@ -161,7 +161,7 @@ class ExternalScripts(Addon): download_folder = self.config['general']['download_folder'] for script in self.scripts['package_finished']: - self.callScript(script, pypack.id, pypack.name, download_folder) + self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) def packageDeleted(self, pid): @@ -173,7 +173,7 @@ class ExternalScripts(Addon): download_folder = self.config['general']['download_folder'] for script in self.scripts['package_deleted']: - self.callScript(script, pack.id, pack.name, download_folder) + self.callScript(script, pack.id, pack.name, download_folder, pack.password) def package_extract_failed(self, pypack): @@ -183,7 +183,7 @@ class ExternalScripts(Addon): download_folder = self.config['general']['download_folder'] for script in self.scripts['package_extract_failed']: - self.callScript(script, pypack.id, pypack.name, download_folder) + self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) def package_extracted(self, pypack): diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index 93dd52e46..07b388ecd 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -4,9 +4,9 @@ from __future__ import with_statement import os import sys +import traceback from copy import copy -from traceback import print_exc # monkey patch bug in python 2.6 and lower # http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 @@ -106,24 +106,25 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "addon" - __version__ = "1.38" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("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" ), - ("delete" , "No;Permanent;Trash", "Delete archive after extraction" , "No" ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder" , "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Run after all downloads was processed" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.41" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("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" ), + ("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 ), + ("destination" , "folder" , "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -146,7 +147,16 @@ class ExtractArchive(Addon): self.extractors = [] self.passwords = [] self.repair = False - self.trash = False + + try: + import send2trash + + except ImportError: + self.logDebug("Send2Trash lib not found") + self.trashable = False + + else: + self.trashable = True def activate(self): @@ -161,19 +171,19 @@ class ExtractArchive(Addon): except OSError, e: if e.errno == 2: - self.logInfo(_("No %s installed") % p) + self.logWarning(_("No %s installed") % p) else: self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: - print_exc() + traceback.print_exc() except Exception, e: self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: - print_exc() + traceback.print_exc() if self.extractors: - self.logInfo(_("Activated") + " " + "|".join("%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")) @@ -319,6 +329,7 @@ class ExtractArchive(Addon): new_files = self._extract(pyfile, archive, pypack.password) finally: + pyfile.setProgress(100) thread.finishFile(pyfile) except Exception, e: @@ -447,31 +458,25 @@ class ExtractArchive(Addon): pyfile.setStatus("processing") delfiles = archive.getDeleteFiles() - if self.core.debug: - self.logDebug("Would delete: %s" % ", ".join(delfiles)) + self.logDebug("Would delete: " + ", ".join(delfiles)) - if self.getConfig('delete') != 'No': - try: - from send2trash import send2trash - if self.getConfig('delete') == "Trash": - self.trash = True - self.logInfo(_("Sending %s files to trash") % len(delfiles)) - except ImportError: - self.logError(name, _("Send2Trash not installed, no files deleted")) - self.trash = False - - if self.getConfig('delete') == "Permanent": - self.trash = False - self.logInfo(_("Deleting %s files") % len(delfiles)) + if self.getConfig('delete'): + self.logInfo(_("Deleting %s files") % len(delfiles)) + deltotrash = self.getConfig('deltotrash') for f in delfiles: file = fs_encode(f) - if os.path.exists(file) and self.trash: - send2trash(file) - elif os.path.exists(file): + if not os.path.exists(file): + continue + + if not deltotrash: os.remove(file) + + elif self.trashable: + send2trash.send2trash(file) + else: - self.logDebug("%s does not exists" % f) + self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() @@ -490,7 +495,7 @@ class ExtractArchive(Addon): except Exception, e: self.logError(name, _("Unknown error"), e) if self.core.debug: - print_exc() + traceback.print_exc() self.manager.dispatchEvent("archive_extract_failed", pyfile, archive) diff --git a/pyload/plugin/addon/IRCInterface.py b/pyload/plugin/addon/IRCInterface.py index 6d85a5681..170055ee8 100644 --- a/pyload/plugin/addon/IRCInterface.py +++ b/pyload/plugin/addon/IRCInterface.py @@ -4,11 +4,11 @@ import re import socket import ssl import time +import traceback from pycurl import FORM_FILE from select import select from threading import Thread -from traceback import print_exc from pyload.api import PackageDoesNotExists, FileDoesNotExists from pyload.network.RequestFactory import getURL @@ -103,7 +103,7 @@ class IRCInterface(Thread, Addon): except IRCError, ex: self.sock.send("QUIT :byebye\r\n") - print_exc() + traceback.print_exc() self.sock.close() diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py index 393e66628..ee6a86d9f 100644 --- a/pyload/plugin/addon/MergeFiles.py +++ b/pyload/plugin/addon/MergeFiles.py @@ -4,8 +4,7 @@ from __future__ import with_statement import os import re - -from traceback import print_exc +import traceback from pyload.plugin.Addon import Addon, threaded from pyload.utils import fs_join @@ -71,7 +70,7 @@ class MergeFiles(Addon): self.logDebug("Finished merging part", splitted_file) except Exception, e: - print_exc() + traceback.print_exc() finally: pyfile.setProgress(100) diff --git a/pyload/plugin/addon/RestartSlow.py b/pyload/plugin/addon/RestartSlow.py deleted file mode 100644 index 34416e79a..000000000 --- a/pyload/plugin/addon/RestartSlow.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- - -import pycurl - -from pyload.plugin.Addon import Addon - - -class RestartSlow(Addon): - __name__ = "RestartSlow" - __type__ = "addon" - __version__ = "0.04" - - __config__ = [("free_limit" , "int" , "Transfer speed threshold in kilobytes" , 100 ), - ("free_time" , "int" , "Sample interval in minutes" , 5 ), - ("premium_limit", "int" , "Transfer speed threshold for premium download in kilobytes", 300 ), - ("premium_time" , "int" , "Sample interval for premium download in minutes" , 2 ), - ("safe_mode" , "bool", "Don't restart if download is not resumable" , True)] - - __description__ = """Restart slow downloads""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - event_list = ["downloadStarts"] - - - def setup(self): - self.info = {'chunk': {}} - - - def periodical(self): - if not self.pyfile.plugin.req.dl: - return - - if self.getConfig('safe_mode') and not self.pyfile.plugin.resumeDownload: - time = 30 - limit = 5 - else: - type = "premium" if self.pyfile.plugin.premium else "free" - time = max(30, self.getConfig('%s_time' % type) * 60) - limit = max(5, self.getConfig('%s_limit' % type) * 1024) - - chunks = [chunk for chunk in self.pyfile.plugin.req.dl.chunks \ - if chunk.id not in self.info['chunk'] or self.info['chunk'][chunk.id] is not (time, limit)] - - for chunk in chunks: - chunk.c.setopt(pycurl.LOW_SPEED_TIME , time) - chunk.c.setopt(pycurl.LOW_SPEED_LIMIT, limit) - - self.info['chunk'][chunk.id] = (time, limit) - - - def downloadStarts(self, pyfile, url, filename): - if self.cb or (self.getConfig('safe_mode') and not pyfile.plugin.resumeDownload): - return - self.pyfile = pyfile - self.initPeriodical() diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py index 8e27d9959..c5bee16a1 100644 --- a/pyload/plugin/addon/UpdateManager.py +++ b/pyload/plugin/addon/UpdateManager.py @@ -113,7 +113,7 @@ class UpdateManager(Addon): return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() except Exception: - self.logWarning(_("Unable to contact server to get updates")) + self.logWarning(_("Unable to retrieve server to get updates")) @Expose @threaded @@ -251,7 +251,7 @@ class UpdateManager(Addon): if self.core.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.logWarning(_("pyLoad restart required to reload the updated plugins")) + self.logWarning(_("Restart pyLoad to reload the updated plugins")) self.info['plugins'] = True exitcode = 2 |