summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/addon/AntiVirus.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 09:22:01 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 09:22:01 +0200
commit2432ade6c9bd7284a5bf0d760796638eef634be9 (patch)
tree877cfd29c6e5117a974377ead73cbbc150f6544d /pyload/plugin/addon/AntiVirus.py
parentPrepare hook plugins to merging from stable (diff)
parent[LolabitsEs] Cleanup (diff)
downloadpyload-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/AntiVirus.py')
-rw-r--r--pyload/plugin/addon/AntiVirus.py45
1 files changed, 36 insertions, 9 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: