diff options
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r-- | module/plugins/hooks/AntiVirus.py | 72 | ||||
-rw-r--r-- | module/plugins/hooks/Captcha9Kw.py | 9 | ||||
-rw-r--r-- | module/plugins/hooks/ClickAndLoad.py | 2 | ||||
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 32 | ||||
-rw-r--r-- | module/plugins/hooks/UpdateManager.py | 6 |
5 files changed, 73 insertions, 48 deletions
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index b58d0b61d..d7ec69031 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -10,23 +10,25 @@ except ImportError: pass from module.plugins.internal.Addon import Addon, Expose, threaded +from module.plugins.internal.Plugin import exists from module.utils import fs_encode, save_join as fs_join class AntiVirus(Addon): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.12" + __version__ = "0.13" __status__ = "testing" #@TODO: add trash option (use Send2Trash lib) - __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 )] + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + ("quardir" , "folder" , "Quarantine folder" , "" ), + ("deltotrash", "bool" , "Move to trash instead delete", True ), + ("scanfailed", "bool" , "Scan failed downloads" , False ), + ("avfile" , "file" , "Antivirus executable" , "" ), + ("avargs" , "str" , "Executable arguments" , "" ), + ("avtarget" , "file;folder" , "Scan target" , "file" ), + ("ignore-err", "bool" , "Ignore scan errors" , False )] __description__ = """Scan downloaded files with antivirus program""" __license__ = "GPLv3" @@ -36,12 +38,24 @@ class AntiVirus(Addon): @Expose @threaded def scan(self, pyfile, thread): - file = fs_encode(pyfile.plugin.last_download) - filename = os.path.basename(pyfile.plugin.last_download) - cmdfile = fs_encode(self.get_config('cmdfile')) - cmdargs = fs_encode(self.get_config('cmdargs').strip()) + avfile = fs_encode(self.get_config('avfile')) + avargs = fs_encode(self.get_config('avargs').strip()) - if not os.path.isfile(file) or not os.path.isfile(cmdfile): + if not os.path.isfile(avfile): + self.fail(_("Antivirus executable not found")) + + scanfolder = self.get_config('avtarget') is "folder" + + if scanfolder: + download_folder = self.pyload.config.get("general", "download_folder") + package_folder = pyfile.package().folder if self.pyload.config.get("general", "folder_per_package") else "" + target = fs_join(download_folder, package_folder, pyfile.name) + target_repr = "Folder: " + package_folder or download_folder + else: + target = fs_encode(pyfile.plugin.last_download) + target_repr = "File: " + os.path.basename(pyfile.plugin.last_download) + + if not exists(target): return thread.addActive(pyfile) @@ -49,24 +63,34 @@ class AntiVirus(Addon): pyfile.setProgress(0) try: - p = subprocess.Popen([cmdfile, cmdargs, file], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([avfile, avargs, target], + bufsize=-1, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = map(str.strip, p.communicate()) if out: - self.log_info(filename, out) + self.log_info(target_repr, out) if err: - self.log_warning(filename, err) + self.log_warning(target_repr, err) if not self.get_config('ignore-err'): - self.log_debug("Delete/Quarantine task is aborted") + self.log_debug("Delete/Quarantine task aborted due scan error") return if p.returncode: - pyfile.error = _("Infected file") action = self.get_config('action') + + if scanfolder: + if action is "Antivirus default": + self.log_warning(_("Delete/Quarantine task skipped in folder scan mode") + return + + pyfile.error = _("Infected file") + try: - if action == "Delete": + if action is "Delete": if not self.get_config('deltotrash'): os.remove(file) @@ -87,15 +111,15 @@ class AntiVirus(Addon): else: self.log_debug("Successfully moved file to trash") - elif action == "Quarantine": + elif action is "Quarantine": pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.get_config('quardir')) except (IOError, shutil.Error), e: - self.log_error(filename, action + " action failed!", e) + self.log_error(target_repr, action + " action failed!", e) - elif not out and not err: - self.log_debug(filename, "No infected file found") + elif not err: + self.log_debug(target_repr, "No infected file found") finally: pyfile.setProgress(100) @@ -108,5 +132,5 @@ class AntiVirus(Addon): def download_failed(self, pyfile): #: Check if pyfile is still "failed", maybe might has been restarted in meantime - if pyfile.status == 8 and self.get_config('scanfailed'): + if pyfile.status is 8 and self.get_config('scanfailed'): return self.scan(pyfile) diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 2e2685978..656497dd6 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -78,7 +78,6 @@ class Captcha9Kw(Hook): 'cpm' : self.get_config('captchapermin')} for opt in str(self.get_config('hoster_options').split('|')): - details = map(str.strip, opt.split(':')) if not details or details[0].lower() is not pluginname.lower(): @@ -149,6 +148,7 @@ class Captcha9Kw(Hook): time.sleep(5) else: break + else: self.log_debug("Could not send request: %s" % res) result = None @@ -184,6 +184,7 @@ class Captcha9Kw(Hook): break time.sleep(10) + else: self.fail(_("Too many captchas in queue")) @@ -196,9 +197,9 @@ class Captcha9Kw(Hook): for d in details: hosteroption = d.split("=") - if len(hosteroption) > 1 \ - and hosteroption[0].lower() == "timeout" \ - and hosteroption[1].isdigit(): + if len(hosteroption) > 1 and \ + hosteroption[0].lower() == "timeout" and \ + hosteroption[1].isdigit(): timeout = int(hosteroption[1]) break diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index ba03129e6..591be8b59 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -84,7 +84,7 @@ class ClickAndLoad(Addon): server_socket = ssl.wrap_socket(server_socket) except NameError: - self.log_error(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or disable HTTPS")) + self.log_error(_("Missing SSL lib"), _("Please disable HTTPS in pyLoad settings")) client_socket.close() #: Reset the connection. continue diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 19d8bef94..b5a714533 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -110,22 +110,22 @@ class ExtractArchive(Addon): __version__ = "1.51" __status__ = "testing" - __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 ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("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 ), - ("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 )] + __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 ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "passwords.txt" ), + ("delete" , "bool" , "Delete archive after extraction" , True ), + ("deltotrash" , "bool" , "Move to trash 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" diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index ec262e672..312355675 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -79,8 +79,8 @@ class UpdateManager(Addon): if self.get_config('nodebugupdate'): return - if self.get_config('checkperiod') \ - and time.time() - max(self.MIN_CHECK_INTERVAL, self.get_config('checkinterval') * 60 * 60) > self.info['last_check']: + if self.get_config('checkperiod') and \ + time.time() - max(self.MIN_CHECK_INTERVAL, self.get_config('checkinterval') * 60 * 60) > self.info['last_check']: self.update() @@ -275,7 +275,7 @@ class UpdateManager(Addon): if self.pyload.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.log_warning(_("pyLoad restart required to reload the updated plugins")) + self.log_warning(_("You have to restart pyLoad to reload the updated plugins")) self.info['plugins'] = True exitcode = 2 |