From fc36aa1a426fb8c75897debdc6cb4104dbff8200 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Sat, 2 May 2015 22:36:02 +0300 Subject: [AntiVirus] report missing send2trash --- module/plugins/hooks/AntiVirus.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index ac9373a37..69dffbe73 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 class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.08" + __version__ = "0.09" #@TODO: add trash option (use Send2Trash lib) __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), @@ -80,8 +80,13 @@ class AntiVirus(Hook): try: send2trash.send2trash(file) - except Exception: - self.logWarning(_("Unable to move file to trash, move to quarantine instead")) + except NameError: + self.logWarning(_("Send2Trash lib not found, moving to quarantine instead")) + pyfile.setCustomStatus(_("file moving")) + shutil.move(file, self.getConfig('quardir')) + + except Exception: + self.logWarning(_("Unable to move file to trash, moving to quarantine instead")) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) -- cgit v1.2.3 From dec360bee84f046bf40612173ec4e74aebd60599 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Sat, 2 May 2015 22:40:55 +0300 Subject: [ExtractArchive] report missing send2trash --- module/plugins/hooks/ExtractArchive.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 05a1e368a..609d0ad62 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -110,7 +110,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.42" + __version__ = "1.43" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -472,6 +472,9 @@ class ExtractArchive(Hook): try: send2trash.send2trash(file) + except NameError: + self.logWarning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f)) + except Exception: self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) -- cgit v1.2.3 From c6932a1ea6e44867e2b2caedfad444d4b34aea4f Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Mon, 4 May 2015 01:33:47 +0300 Subject: more verbose --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 609d0ad62..d0a84364a 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -475,8 +475,8 @@ class ExtractArchive(Hook): except NameError: self.logWarning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f)) - except Exception: - self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) + except Exception, e: + self.logWarning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From dc7c81b6ab0813745ee03116c27f870138b3fc7f Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Mon, 4 May 2015 01:36:23 +0300 Subject: more verbose --- module/plugins/hooks/AntiVirus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 69dffbe73..6823729af 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -85,8 +85,8 @@ class AntiVirus(Hook): pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) - except Exception: - self.logWarning(_("Unable to move file to trash, moving to quarantine instead")) + except Exception, e: + self.logWarning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) -- cgit v1.2.3 From e26ba64714e84745db1f6dfc73ccc8c68ad4abcc Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Mon, 4 May 2015 02:22:06 +0300 Subject: even more --- module/plugins/hooks/ExtractArchive.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index d0a84364a..5b90b28fc 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -478,6 +478,9 @@ class ExtractArchive(Hook): except Exception, e: 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.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From ee360021434803991226d1cc36e7221fb9cbc418 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Mon, 4 May 2015 02:24:23 +0300 Subject: even more --- module/plugins/hooks/AntiVirus.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 6823729af..c620f556d 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -85,11 +85,14 @@ class AntiVirus(Hook): pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) - except Exception, e: + except Exception, e: self.logWarning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) + else: + self.logDebug(_("Successfully moved file to trash")) + elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) -- cgit v1.2.3