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.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py
index 02b1df67b..cb9d5aaa6 100644
--- a/module/plugins/hooks/AntiVirus.py
+++ b/module/plugins/hooks/AntiVirus.py
@@ -16,7 +16,7 @@ from module.utils import fs_encode, save_join as fs_join
class AntiVirus(Hook):
__name__ = "AntiVirus"
__type__ = "hook"
- __version__ = "0.10"
+ __version__ = "0.11"
#@TODO: add trash option (use Send2Trash lib)
__config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"),
@@ -44,8 +44,8 @@ class AntiVirus(Hook):
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())
+ 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 +60,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')
+ 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,27 +81,27 @@ 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)
@@ -114,5 +114,5 @@ class AntiVirus(Hook):
def download_failed(self, pyfile):
#: Check if pyfile is still "failed", maybe might has been restarted in meantime
- if pyfile.status == 8 and self.getConfig('scanfailed'):
+ if pyfile.status == 8 and self.get_config('scanfailed'):
return self.scan(pyfile)