summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/addon
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugin/addon')
-rw-r--r--pyload/plugin/addon/AntiVirus.py2
-rw-r--r--pyload/plugin/addon/Checksum.py4
-rw-r--r--pyload/plugin/addon/ClickNLoad.py4
-rw-r--r--pyload/plugin/addon/ExternalScripts.py44
-rw-r--r--pyload/plugin/addon/ExtractArchive.py20
-rw-r--r--pyload/plugin/addon/MergeFiles.py4
-rw-r--r--pyload/plugin/addon/MultiHome.py2
-rw-r--r--pyload/plugin/addon/UpdateManager.py28
-rw-r--r--pyload/plugin/addon/UserAgentSwitcher.py4
9 files changed, 57 insertions, 55 deletions
diff --git a/pyload/plugin/addon/AntiVirus.py b/pyload/plugin/addon/AntiVirus.py
index 3866014ee..87780e337 100644
--- a/pyload/plugin/addon/AntiVirus.py
+++ b/pyload/plugin/addon/AntiVirus.py
@@ -28,8 +28,6 @@ class AntiVirus(Addon):
def setup(self):
- self.info = {} #@TODO: Remove in 0.4.10
-
try:
import send2trash
diff --git a/pyload/plugin/addon/Checksum.py b/pyload/plugin/addon/Checksum.py
index 53b9b4e9f..ed50b0f5e 100644
--- a/pyload/plugin/addon/Checksum.py
+++ b/pyload/plugin/addon/Checksum.py
@@ -105,7 +105,7 @@ class Checksum(Addon):
self.checkFailed(pyfile, None, "No file downloaded")
local_file = fs_encode(pyfile.plugin.lastDownload)
- #download_folder = self.config['general']['download_folder']
+ #download_folder = self.config.get("general", "download_folder")
#local_file = fs_encode(fs_join(download_folder, pyfile.package().folder, pyfile.name))
if not isfile(local_file):
@@ -166,7 +166,7 @@ class Checksum(Addon):
def packageFinished(self, pypack):
- download_folder = fs_join(self.config['general']['download_folder'], pypack.folder, "")
+ download_folder = fs_join(self.config.get("general", "download_folder"), pypack.folder, "")
for link in pypack.getChildren().itervalues():
file_type = splitext(link['name'])[1][1:].lower()
diff --git a/pyload/plugin/addon/ClickNLoad.py b/pyload/plugin/addon/ClickNLoad.py
index b6448598a..4e1be807d 100644
--- a/pyload/plugin/addon/ClickNLoad.py
+++ b/pyload/plugin/addon/ClickNLoad.py
@@ -37,11 +37,11 @@ class ClickNLoad(Addon):
def activate(self):
- if not self.core.config['webui']['activated']:
+ if not self.core.config.get("webui", "activated"):
return
ip = "" if self.getConfig('extern') else "127.0.0.1"
- webport = self.core.config['webui']['port']
+ webport = self.core.config.get("webui", "port")
cnlport = self.getConfig('port')
self.proxy(ip, webport, cnlport)
diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py
index 75c9ae810..341dd6dcd 100644
--- a/pyload/plugin/addon/ExternalScripts.py
+++ b/pyload/plugin/addon/ExternalScripts.py
@@ -30,7 +30,7 @@ class ExternalScripts(Addon):
def setup(self):
- self.info = {'oldip': None}
+ self.info['oldip'] = None
self.scripts = {}
folders = ["pyload_start", "pyload_restart", "pyload_stop",
@@ -38,7 +38,7 @@ class ExternalScripts(Addon):
"download_preparing", "download_failed", "download_finished",
"archive_extract_failed", "archive_extracted",
"package_finished", "package_deleted", "package_extract_failed", "package_extracted",
- "all_downloads_processed", "all_downloads_finished", # @TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10
+ "all_downloads_processed", "all_downloads_finished", #@TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10
"all_archives_extracted", "all_archives_processed"]
for folder in folders:
@@ -84,7 +84,7 @@ class ExternalScripts(Addon):
self.logDebug("Executing: %s" % os.path.abspath(script), "Args: " + ' '.join(cmd_args))
- p = subprocess.Popen(cmd, bufsize=-1) # @NOTE: output goes to pyload
+ p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload
if self.getConfig('waitend'):
p.communicate()
@@ -113,7 +113,7 @@ class ExternalScripts(Addon):
def afterReconnecting(self, ip):
for script in self.scripts['after_reconnect']:
- self.callScript(script, ip, self.info['oldip']) # @TODO: Use built-in oldip in 0.4.10
+ self.callScript(script, ip, self.info['oldip']) #@TODO: Use built-in oldip in 0.4.10
def downloadPreparing(self, pyfile):
@@ -122,10 +122,10 @@ class ExternalScripts(Addon):
def downloadFailed(self, pyfile):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['download_failed']:
file = fs_join(download_folder, pyfile.name)
@@ -133,10 +133,10 @@ class ExternalScripts(Addon):
def downloadFinished(self, pyfile):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['download_finished']:
file = fs_join(download_folder, pyfile.name)
@@ -154,10 +154,10 @@ class ExternalScripts(Addon):
def packageFinished(self, pypack):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_finished']:
self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
@@ -166,30 +166,30 @@ class ExternalScripts(Addon):
def packageDeleted(self, pid):
pack = self.core.api.getPackageInfo(pid)
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_deleted']:
self.callScript(script, pack.id, pack.name, download_folder, pack.password)
def package_extract_failed(self, pypack):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_extract_failed']:
self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
def package_extracted(self, pypack):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_extracted']:
self.callScript(script, pypack.id, pypack.name, download_folder)
diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py
index bc1b06306..a106d22ab 100644
--- a/pyload/plugin/addon/ExtractArchive.py
+++ b/pyload/plugin/addon/ExtractArchive.py
@@ -198,11 +198,11 @@ class ExtractArchive(Addon):
while packages:
if self.lastPackage: #: called from allDownloadsProcessed
self.lastPackage = False
- if self.extract(packages, thread): # @NOTE: check only if all gone fine, no failed reporting for now
+ if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now
self.manager.dispatchEvent("all_archives_extracted")
self.manager.dispatchEvent("all_archives_processed")
else:
- if self.extract(packages, thread): # @NOTE: check only if all gone fine, no failed reporting for now
+ if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now
pass
packages = self.queue.get() #: check for packages added during extraction
@@ -234,7 +234,7 @@ class ExtractArchive(Addon):
@Expose
- def extract(self, ids, thread=None): # @TODO: Use pypack, not pid to improve method usability
+ def extract(self, ids, thread=None): #@TODO: Use pypack, not pid to improve method usability
if not ids:
return False
@@ -264,7 +264,7 @@ class ExtractArchive(Addon):
# reload from txt file
self.reloadPasswords()
- download_folder = self.config['general']['download_folder']
+ download_folder = self.config.get("general", "download_folder")
# iterate packages -> extractors -> targets
for pid in ids:
@@ -551,16 +551,16 @@ class ExtractArchive(Addon):
continue
try:
- if self.config['permission']['change_file']:
+ if self.config.get("permission", "change_file"):
if os.path.isfile(f):
- os.chmod(f, int(self.config['permission']['file'], 8))
+ os.chmod(f, int(self.config.get("permission", "file"), 8))
elif os.path.isdir(f):
- os.chmod(f, int(self.config['permission']['folder'], 8))
+ os.chmod(f, int(self.config.get("permission", "folder"), 8))
- if self.config['permission']['change_dl'] and os.name != "nt":
- uid = getpwnam(self.config['permission']['user'])[2]
- gid = getgrnam(self.config['permission']['group'])[2]
+ if self.config.get("permission", "change_dl") and os.name != "nt":
+ uid = getpwnam(self.config.get("permission", "user"))[2]
+ gid = getgrnam(self.config.get("permission", "group"))[2]
os.chown(f, uid, gid)
except Exception, e:
diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py
index dfc5f41d4..4f95ef9d7 100644
--- a/pyload/plugin/addon/MergeFiles.py
+++ b/pyload/plugin/addon/MergeFiles.py
@@ -37,9 +37,9 @@ class MergeFiles(Addon):
files[data['name'][:-4]].sort()
fid_dict[data['name']] = fid
- download_folder = self.config['general']['download_folder']
+ download_folder = self.config.get("general", "download_folder")
- if self.config['general']['folder_per_package']:
+ if self.config.get("general", "folder_per_package"):
download_folder = fs_join(download_folder, pack.folder)
for name, file_list in files.iteritems():
diff --git a/pyload/plugin/addon/MultiHome.py b/pyload/plugin/addon/MultiHome.py
index 057764a1e..bca6493db 100644
--- a/pyload/plugin/addon/MultiHome.py
+++ b/pyload/plugin/addon/MultiHome.py
@@ -24,7 +24,7 @@ class MultiHome(Addon):
self.parseInterfaces(self.getConfig('interfaces').split(";"))
if not self.interfaces:
- self.parseInterfaces([self.config['download']['interface']])
+ self.parseInterfaces([self.config.get("download", "interface")])
self.setConfig("interfaces", self.toConfig())
diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py
index 60fc71d0a..cf8349e79 100644
--- a/pyload/plugin/addon/UpdateManager.py
+++ b/pyload/plugin/addon/UpdateManager.py
@@ -30,7 +30,7 @@ def exists(path):
class UpdateManager(Addon):
__name = "UpdateManager"
__type = "addon"
- __version = "0.50"
+ __version = "0.51"
__config = [("activated", "bool", "Activated", False),
("checkinterval", "int", "Check interval in hours", 8),
@@ -50,6 +50,8 @@ class UpdateManager(Addon):
SERVER_URL = "http://updatemanager.pyload.org" if release_status == 5 else None
MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours
+ event_list = ["allDownloadsProcessed"]
+
def activate(self):
if self.checkonstart:
@@ -69,6 +71,14 @@ class UpdateManager(Addon):
else:
self.checkonstart = False
+ self.do_restart = False
+
+
+ def allDownloadsProcessed(self):
+ if self.do_restart is True:
+ self.logWarning(_("Downloads are done, restarting pyLoad to reload the updated plugins"))
+ self.core.api.restart()
+
def periodical(self):
if self.core.debug:
@@ -129,7 +139,11 @@ class UpdateManager(Addon):
self.core.api.pauseServer()
if self._update() is 2 and self.getConfig('autorestart'):
- self.core.api.restart()
+ if not self.core.api.statusDownloads():
+ self.core.api.restart()
+ else:
+ self.do_restart = True
+ self.logWarning(_("Downloads are active, will restart once the download is done"))
else:
self.core.api.unpauseServer()
@@ -208,7 +222,7 @@ class UpdateManager(Addon):
for plugin in sorted(updatelist, key=itemgetter("type", "name")):
filename = plugin['name']
- prefix = plugin['type']
+ type = plugin['type']
version = plugin['version']
if filename.endswith(".pyc"):
@@ -216,12 +230,6 @@ class UpdateManager(Addon):
else:
name = filename.replace(".py", "")
- #@TODO: Remove in 0.4.10
- if prefix.endswith("s"):
- type = prefix[:-1]
- else:
- type = prefix
-
plugins = getattr(self.core.pluginManager, "%sPlugins" % type)
oldver = float(plugins[name]['version']) if name in plugins else None
@@ -259,7 +267,7 @@ class UpdateManager(Addon):
if self.core.pluginManager.reloadPlugins(updated):
exitcode = 1
else:
- self.logWarning(_("Restart pyLoad to reload the updated plugins"))
+ self.logWarning(_("pyLoad restart required to reload the updated plugins"))
self.info['plugins'] = True
exitcode = 2
diff --git a/pyload/plugin/addon/UserAgentSwitcher.py b/pyload/plugin/addon/UserAgentSwitcher.py
index ec1640e63..31a2b763b 100644
--- a/pyload/plugin/addon/UserAgentSwitcher.py
+++ b/pyload/plugin/addon/UserAgentSwitcher.py
@@ -25,10 +25,6 @@ class UserAgentSwitcher(Addon):
__authors = [("Walter Purcaro", "vuolter@gmail.com")]
- def setup(self):
- self.info = {} #@TODO: Remove in 0.4.10
-
-
def downloadPreparing(self, pyfile):
uar = self.getConfig('uar')
uaf = fs_encode(self.getConfig('uaf'))