summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/addon
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugin/addon')
-rw-r--r--pyload/plugin/addon/AntiVirus.py45
-rw-r--r--pyload/plugin/addon/DeleteFinished.py5
-rw-r--r--pyload/plugin/addon/ExternalScripts.py18
-rw-r--r--pyload/plugin/addon/ExtractArchive.py93
-rw-r--r--pyload/plugin/addon/IRCInterface.py4
-rw-r--r--pyload/plugin/addon/MergeFiles.py5
-rw-r--r--pyload/plugin/addon/RestartSlow.py57
-rw-r--r--pyload/plugin/addon/UpdateManager.py4
8 files changed, 102 insertions, 129 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:
diff --git a/pyload/plugin/addon/DeleteFinished.py b/pyload/plugin/addon/DeleteFinished.py
index 8bb681cca..801e48ed6 100644
--- a/pyload/plugin/addon/DeleteFinished.py
+++ b/pyload/plugin/addon/DeleteFinished.py
@@ -9,9 +9,8 @@ class DeleteFinished(Addon):
__type__ = "addon"
__version__ = "1.12"
- __config__ = [("activated" , "bool", "Activated" , "False"),
- ("interval" , "int" , "Delete every (hours)" , "72" ),
- ("deloffline", "bool", "Delete packages with offline links", "False")]
+ __config__ = [("interval" , "int" , "Check interval in hours" , 72 ),
+ ("deloffline", "bool", "Delete package with offline links", False)]
__description__ = """Automatically delete all finished packages from queue"""
__license__ = "GPLv3"
diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py
index 502a6dc7b..05b1d7b65 100644
--- a/pyload/plugin/addon/ExternalScripts.py
+++ b/pyload/plugin/addon/ExternalScripts.py
@@ -10,7 +10,7 @@ from pyload.utils import fs_encode, fs_join
class ExternalScripts(Addon):
__name__ = "ExternalScripts"
__type__ = "addon"
- __version__ = "0.37"
+ __version__ = "0.39"
__config__ = [("activated", "bool", "Activated" , True ),
("waitend" , "bool", "Wait script ending", False)]
@@ -119,7 +119,7 @@ class ExternalScripts(Addon):
def downloadPreparing(self, pyfile):
for script in self.scripts['download_preparing']:
- self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, None)
+ self.callScript(script, pyfile.id, pyfile.name, None, pyfile.pluginname, pyfile.url)
def downloadFailed(self, pyfile):
@@ -130,7 +130,7 @@ class ExternalScripts(Addon):
for script in self.scripts['download_failed']:
file = fs_join(download_folder, pyfile.name)
- self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file)
+ self.callScript(script, pyfile.id, pyfile.name, file, pyfile.pluginname, pyfile.url)
def downloadFinished(self, pyfile):
@@ -141,17 +141,17 @@ class ExternalScripts(Addon):
for script in self.scripts['download_finished']:
file = fs_join(download_folder, pyfile.name)
- self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file)
+ self.callScript(script, pyfile.id, pyfile.name, file, pyfile.pluginname, pyfile.url)
def archive_extract_failed(self, pyfile, archive):
for script in self.scripts['archive_extract_failed']:
- self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files)
+ self.callScript(script, pyfile.id, pyfile.name, archive.filename, archive.out, archive.files)
def archive_extracted(self, pyfile, archive):
for script in self.scripts['archive_extracted']:
- self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files)
+ self.callScript(script, pyfile.id, pyfile.name, archive.filename, archive.out, archive.files)
def packageFinished(self, pypack):
@@ -161,7 +161,7 @@ class ExternalScripts(Addon):
download_folder = self.config['general']['download_folder']
for script in self.scripts['package_finished']:
- self.callScript(script, pypack.id, pypack.name, download_folder)
+ self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
def packageDeleted(self, pid):
@@ -173,7 +173,7 @@ class ExternalScripts(Addon):
download_folder = self.config['general']['download_folder']
for script in self.scripts['package_deleted']:
- self.callScript(script, pack.id, pack.name, download_folder)
+ self.callScript(script, pack.id, pack.name, download_folder, pack.password)
def package_extract_failed(self, pypack):
@@ -183,7 +183,7 @@ class ExternalScripts(Addon):
download_folder = self.config['general']['download_folder']
for script in self.scripts['package_extract_failed']:
- self.callScript(script, pypack.id, pypack.name, download_folder)
+ self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
def package_extracted(self, pypack):
diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py
index 93dd52e46..07b388ecd 100644
--- a/pyload/plugin/addon/ExtractArchive.py
+++ b/pyload/plugin/addon/ExtractArchive.py
@@ -4,9 +4,9 @@ from __future__ import with_statement
import os
import sys
+import traceback
from copy import copy
-from traceback import print_exc
# monkey patch bug in python 2.6 and lower
# http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717
@@ -106,24 +106,25 @@ class ArchiveQueue(object):
class ExtractArchive(Addon):
__name__ = "ExtractArchive"
__type__ = "addon"
- __version__ = "1.38"
-
- __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 ),
- ("test" , "bool" , "Test archive before extracting" , False ),
- ("usepasswordfile", "bool" , "Use password file" , True ),
- ("passwordfile" , "file" , "Password file" , "archive_password.txt" ),
- ("delete" , "No;Permanent;Trash", "Delete archive after extraction" , "No" ),
- ("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 )]
+ __version__ = "1.41"
+
+ __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 ),
+ ("test" , "bool" , "Test archive before extracting" , False ),
+ ("usepasswordfile", "bool" , "Use password file" , True ),
+ ("passwordfile" , "file" , "Password file" , "archive_password.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 )]
__description__ = """Extract different kind of archives"""
__license__ = "GPLv3"
@@ -146,7 +147,16 @@ class ExtractArchive(Addon):
self.extractors = []
self.passwords = []
self.repair = False
- self.trash = False
+
+ try:
+ import send2trash
+
+ except ImportError:
+ self.logDebug("Send2Trash lib not found")
+ self.trashable = False
+
+ else:
+ self.trashable = True
def activate(self):
@@ -161,19 +171,19 @@ class ExtractArchive(Addon):
except OSError, e:
if e.errno == 2:
- self.logInfo(_("No %s installed") % p)
+ self.logWarning(_("No %s installed") % p)
else:
self.logWarning(_("Could not activate: %s") % p, e)
if self.core.debug:
- print_exc()
+ traceback.print_exc()
except Exception, e:
self.logWarning(_("Could not activate: %s") % p, e)
if self.core.debug:
- print_exc()
+ traceback.print_exc()
if self.extractors:
- self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__,Extractor.VERSION) for Extractor in self.extractors))
+ self.logDebug(*["Found %s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors])
self.extractQueued() #: Resume unfinished extractions
else:
self.logInfo(_("No Extract plugins activated"))
@@ -319,6 +329,7 @@ class ExtractArchive(Addon):
new_files = self._extract(pyfile, archive, pypack.password)
finally:
+ pyfile.setProgress(100)
thread.finishFile(pyfile)
except Exception, e:
@@ -447,31 +458,25 @@ class ExtractArchive(Addon):
pyfile.setStatus("processing")
delfiles = archive.getDeleteFiles()
- if self.core.debug:
- self.logDebug("Would delete: %s" % ", ".join(delfiles))
+ self.logDebug("Would delete: " + ", ".join(delfiles))
- if self.getConfig('delete') != 'No':
- try:
- from send2trash import send2trash
- if self.getConfig('delete') == "Trash":
- self.trash = True
- self.logInfo(_("Sending %s files to trash") % len(delfiles))
- except ImportError:
- self.logError(name, _("Send2Trash not installed, no files deleted"))
- self.trash = False
-
- if self.getConfig('delete') == "Permanent":
- self.trash = False
- self.logInfo(_("Deleting %s files") % len(delfiles))
+ if self.getConfig('delete'):
+ self.logInfo(_("Deleting %s files") % len(delfiles))
+ deltotrash = self.getConfig('deltotrash')
for f in delfiles:
file = fs_encode(f)
- if os.path.exists(file) and self.trash:
- send2trash(file)
- elif os.path.exists(file):
+ if not os.path.exists(file):
+ continue
+
+ if not deltotrash:
os.remove(file)
+
+ elif self.trashable:
+ send2trash.send2trash(file)
+
else:
- self.logDebug("%s does not exists" % f)
+ self.logWarning(_("Unable to move %s to trash") % os.path.basename(f))
self.logInfo(name, _("Extracting finished"))
extracted_files = archive.files or archive.list()
@@ -490,7 +495,7 @@ class ExtractArchive(Addon):
except Exception, e:
self.logError(name, _("Unknown error"), e)
if self.core.debug:
- print_exc()
+ traceback.print_exc()
self.manager.dispatchEvent("archive_extract_failed", pyfile, archive)
diff --git a/pyload/plugin/addon/IRCInterface.py b/pyload/plugin/addon/IRCInterface.py
index 6d85a5681..170055ee8 100644
--- a/pyload/plugin/addon/IRCInterface.py
+++ b/pyload/plugin/addon/IRCInterface.py
@@ -4,11 +4,11 @@ import re
import socket
import ssl
import time
+import traceback
from pycurl import FORM_FILE
from select import select
from threading import Thread
-from traceback import print_exc
from pyload.api import PackageDoesNotExists, FileDoesNotExists
from pyload.network.RequestFactory import getURL
@@ -103,7 +103,7 @@ class IRCInterface(Thread, Addon):
except IRCError, ex:
self.sock.send("QUIT :byebye\r\n")
- print_exc()
+ traceback.print_exc()
self.sock.close()
diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py
index 393e66628..ee6a86d9f 100644
--- a/pyload/plugin/addon/MergeFiles.py
+++ b/pyload/plugin/addon/MergeFiles.py
@@ -4,8 +4,7 @@ from __future__ import with_statement
import os
import re
-
-from traceback import print_exc
+import traceback
from pyload.plugin.Addon import Addon, threaded
from pyload.utils import fs_join
@@ -71,7 +70,7 @@ class MergeFiles(Addon):
self.logDebug("Finished merging part", splitted_file)
except Exception, e:
- print_exc()
+ traceback.print_exc()
finally:
pyfile.setProgress(100)
diff --git a/pyload/plugin/addon/RestartSlow.py b/pyload/plugin/addon/RestartSlow.py
deleted file mode 100644
index 34416e79a..000000000
--- a/pyload/plugin/addon/RestartSlow.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import pycurl
-
-from pyload.plugin.Addon import Addon
-
-
-class RestartSlow(Addon):
- __name__ = "RestartSlow"
- __type__ = "addon"
- __version__ = "0.04"
-
- __config__ = [("free_limit" , "int" , "Transfer speed threshold in kilobytes" , 100 ),
- ("free_time" , "int" , "Sample interval in minutes" , 5 ),
- ("premium_limit", "int" , "Transfer speed threshold for premium download in kilobytes", 300 ),
- ("premium_time" , "int" , "Sample interval for premium download in minutes" , 2 ),
- ("safe_mode" , "bool", "Don't restart if download is not resumable" , True)]
-
- __description__ = """Restart slow downloads"""
- __license__ = "GPLv3"
- __authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
-
-
- event_list = ["downloadStarts"]
-
-
- def setup(self):
- self.info = {'chunk': {}}
-
-
- def periodical(self):
- if not self.pyfile.plugin.req.dl:
- return
-
- if self.getConfig('safe_mode') and not self.pyfile.plugin.resumeDownload:
- time = 30
- limit = 5
- else:
- type = "premium" if self.pyfile.plugin.premium else "free"
- time = max(30, self.getConfig('%s_time' % type) * 60)
- limit = max(5, self.getConfig('%s_limit' % type) * 1024)
-
- chunks = [chunk for chunk in self.pyfile.plugin.req.dl.chunks \
- if chunk.id not in self.info['chunk'] or self.info['chunk'][chunk.id] is not (time, limit)]
-
- for chunk in chunks:
- chunk.c.setopt(pycurl.LOW_SPEED_TIME , time)
- chunk.c.setopt(pycurl.LOW_SPEED_LIMIT, limit)
-
- self.info['chunk'][chunk.id] = (time, limit)
-
-
- def downloadStarts(self, pyfile, url, filename):
- if self.cb or (self.getConfig('safe_mode') and not pyfile.plugin.resumeDownload):
- return
- self.pyfile = pyfile
- self.initPeriodical()
diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py
index 8e27d9959..c5bee16a1 100644
--- a/pyload/plugin/addon/UpdateManager.py
+++ b/pyload/plugin/addon/UpdateManager.py
@@ -113,7 +113,7 @@ class UpdateManager(Addon):
return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines()
except Exception:
- self.logWarning(_("Unable to contact server to get updates"))
+ self.logWarning(_("Unable to retrieve server to get updates"))
@Expose
@threaded
@@ -251,7 +251,7 @@ class UpdateManager(Addon):
if self.core.pluginManager.reloadPlugins(updated):
exitcode = 1
else:
- self.logWarning(_("pyLoad restart required to reload the updated plugins"))
+ self.logWarning(_("Restart pyLoad to reload the updated plugins"))
self.info['plugins'] = True
exitcode = 2