summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/AntiVirus.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks/AntiVirus.py')
-rw-r--r--module/plugins/hooks/AntiVirus.py63
1 files changed, 28 insertions, 35 deletions
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py
index c620f556d..b58d0b61d 100644
--- a/module/plugins/hooks/AntiVirus.py
+++ b/module/plugins/hooks/AntiVirus.py
@@ -9,14 +9,15 @@ try:
except ImportError:
pass
-from module.plugins.Hook import Hook, Expose, threaded
-from module.utils import fs_encode, save_join
+from module.plugins.internal.Addon import Addon, Expose, threaded
+from module.utils import fs_encode, save_join as fs_join
-class AntiVirus(Hook):
+class AntiVirus(Addon):
__name__ = "AntiVirus"
__type__ = "hook"
- __version__ = "0.09"
+ __version__ = "0.12"
+ __status__ = "testing"
#@TODO: add trash option (use Send2Trash lib)
__config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"),
@@ -32,20 +33,13 @@ class AntiVirus(Hook):
__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
-
-
@Expose
@threaded
def scan(self, pyfile, thread):
- file = fs_encode(pyfile.plugin.lastDownload)
- filename = os.path.basename(pyfile.plugin.lastDownload)
- cmdfile = fs_encode(self.getConfig('cmdfile'))
- cmdargs = fs_encode(self.getConfig('cmdargs').strip())
+ 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())
if not os.path.isfile(file) or not os.path.isfile(cmdfile):
return
@@ -60,20 +54,20 @@ class AntiVirus(Hook):
out, err = map(str.strip, p.communicate())
if out:
- self.logInfo(filename, out)
+ self.log_info(filename, out)
if err:
- self.logWarning(filename, err)
- if not self.getConfig('ignore-err'):
- self.logDebug("Delete/Quarantine task is aborted")
+ self.log_warning(filename, err)
+ if not self.get_config('ignore-err'):
+ self.log_debug("Delete/Quarantine task is aborted")
return
if p.returncode:
- pyfile.error = _("infected file")
- action = self.getConfig('action')
+ pyfile.error = _("Infected file")
+ action = self.get_config('action')
try:
if action == "Delete":
- if not self.getConfig('deltotrash'):
+ if not self.get_config('deltotrash'):
os.remove(file)
else:
@@ -81,39 +75,38 @@ class AntiVirus(Hook):
send2trash.send2trash(file)
except NameError:
- self.logWarning(_("Send2Trash lib not found, moving to quarantine instead"))
+ self.log_warning(_("Send2Trash lib not found, moving to quarantine instead"))
pyfile.setCustomStatus(_("file moving"))
- shutil.move(file, self.getConfig('quardir'))
+ shutil.move(file, self.get_config('quardir'))
except Exception, e:
- self.logWarning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message)
+ self.log_warning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message)
pyfile.setCustomStatus(_("file moving"))
- shutil.move(file, self.getConfig('quardir'))
+ shutil.move(file, self.get_config('quardir'))
else:
- self.logDebug(_("Successfully moved file to trash"))
+ self.log_debug("Successfully moved file to trash")
elif action == "Quarantine":
pyfile.setCustomStatus(_("file moving"))
- shutil.move(file, self.getConfig('quardir'))
+ shutil.move(file, self.get_config('quardir'))
except (IOError, shutil.Error), e:
- self.logError(filename, action + " action failed!", e)
+ self.log_error(filename, action + " action failed!", e)
elif not out and not err:
- self.logDebug(filename, "No infected file found")
+ self.log_debug(filename, "No infected file found")
finally:
pyfile.setProgress(100)
thread.finishFile(pyfile)
- def downloadFinished(self, pyfile):
+ def download_finished(self, pyfile):
return self.scan(pyfile)
- def downloadFailed(self, pyfile):
- #: Check if pyfile is still "failed",
- # maybe might has been restarted in meantime
- if pyfile.status == 8 and self.getConfig('scanfailed'):
+ 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'):
return self.scan(pyfile)