summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/addon
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-07 15:34:19 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-07 15:34:19 +0100
commitd8771b13f1c658ac726ac93195a48ad87169eccd (patch)
treea81899c2905d59ff20341ffcad35c949d880a0b4 /pyload/plugins/addon
parentTiny code cosmetics (diff)
parent[SkipRev] Tiny fixup (diff)
downloadpyload-d8771b13f1c658ac726ac93195a48ad87169eccd.tar.xz
Merge branch 'stable' into 0.4.10
Conflicts: module/plugins/hoster/NowDownloadEu.py module/plugins/hoster/NowDownloadSx.py module/plugins/hoster/NowVideoAt.py module/plugins/hoster/NowVideoSx.py pyload/plugins/account/RapidshareCom.py pyload/plugins/addon/ExtractArchive.py pyload/plugins/addon/HotFolder.py pyload/plugins/addon/UpdateManager.py pyload/plugins/hook/Captcha9kw.py pyload/plugins/hook/DebridItaliaCom.py pyload/plugins/hoster/DebridItaliaCom.py pyload/plugins/hoster/Keep2shareCc.py pyload/plugins/hoster/NetloadIn.py pyload/plugins/hoster/NowDownloadEu.py pyload/plugins/hoster/NowVideoAt.py pyload/plugins/hoster/RapidshareCom.py pyload/plugins/hoster/ShareonlineBiz.py pyload/plugins/internal/MultiHoster.py pyload/plugins/internal/SimpleHoster.py
Diffstat (limited to 'pyload/plugins/addon')
-rw-r--r--pyload/plugins/addon/Checksum.py9
-rw-r--r--pyload/plugins/addon/ExtractArchive.py4
-rw-r--r--pyload/plugins/addon/HotFolder.py7
-rw-r--r--pyload/plugins/addon/UpdateManager.py79
4 files changed, 56 insertions, 43 deletions
diff --git a/pyload/plugins/addon/Checksum.py b/pyload/plugins/addon/Checksum.py
index 3e1b90941..84024ce83 100644
--- a/pyload/plugins/addon/Checksum.py
+++ b/pyload/plugins/addon/Checksum.py
@@ -82,10 +82,15 @@ class Checksum(Addon):
a) if known, the exact filesize in bytes (e.g. "size": 123456789)
b) hexadecimal hash string with algorithm name as key (e.g. "md5": "d76505d0869f9f928a17d42d66326307")
"""
- if hasattr(pyfile.plugin, "check_data") and (isinstance(pyfile.plugin.check_data, dict)):
+ if hasattr(pyfile.plugin, "check_data") and isinstance(pyfile.plugin.check_data, dict):
data = pyfile.plugin.check_data.copy()
- elif hasattr(pyfile.plugin, "api_data") and (isinstance(pyfile.plugin.api_data, dict)):
+
+ elif hasattr(pyfile.plugin, "api_data") and isinstance(pyfile.plugin.api_data, dict):
data = pyfile.plugin.api_data.copy()
+
+ # elif hasattr(pyfile.plugin, "info") and isinstance(pyfile.plugin.info, dict):
+ # data = pyfile.plugin.info.copy()
+
else:
return
diff --git a/pyload/plugins/addon/ExtractArchive.py b/pyload/plugins/addon/ExtractArchive.py
index 91f477cf8..eef8f00ef 100644
--- a/pyload/plugins/addon/ExtractArchive.py
+++ b/pyload/plugins/addon/ExtractArchive.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+from __future__ import with_statement
+
import os
import sys
@@ -57,7 +59,7 @@ from pyload.utils import safe_join, fs_encode
class ExtractArchive(Addon):
__name__ = "ExtractArchive"
__type__ = "addon"
- __version__ = "0.17"
+ __version__ = "0.18"
__config__ = [("activated" , "bool" , "Activated" , True ),
("fullpath" , "bool" , "Extract full path" , True ),
diff --git a/pyload/plugins/addon/HotFolder.py b/pyload/plugins/addon/HotFolder.py
index e91b9e04f..b16c02cf8 100644
--- a/pyload/plugins/addon/HotFolder.py
+++ b/pyload/plugins/addon/HotFolder.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+from __future__ import with_statement
+
import time
from os import listdir, makedirs
@@ -13,10 +15,9 @@ from pyload.utils import fs_encode, safe_join
class HotFolder(Addon):
__name__ = "HotFolder"
__type__ = "addon"
- __version__ = "0.11"
+ __version__ = "0.12"
- __config__ = [("activated" , "bool", "Activated" , False ),
- ("folder" , "str" , "Folder to observe" , "container"),
+ __config__ = [("folder" , "str" , "Folder to observe" , "container"),
("watch_file", "bool", "Observe link file" , False ),
("keep" , "bool", "Keep added containers", True ),
("file" , "str" , "Link file" , "links.txt")]
diff --git a/pyload/plugins/addon/UpdateManager.py b/pyload/plugins/addon/UpdateManager.py
index 622374136..97fa4a399 100644
--- a/pyload/plugins/addon/UpdateManager.py
+++ b/pyload/plugins/addon/UpdateManager.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+from __future__ import with_statement
+
import re
import sys
@@ -14,13 +16,14 @@ from pyload.utils import safe_join
class UpdateManager(Addon):
__name__ = "UpdateManager"
__type__ = "addon"
- __version__ = "0.40"
+ __version__ = "0.42"
- __config__ = [("activated" , "bool" , "Activated" , True ),
- ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"),
- ("interval" , "int" , "Check interval in hours" , 8 ),
- ("reloadplugins", "bool" , "Monitor plugins for code changes (debug mode only)", True ),
- ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , True )]
+ __config__ = [("activated" , "bool" , "Activated" , True ),
+ ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"),
+ ("interval" , "int" , "Check interval in hours" , 8 ),
+ ("autorestart" , "bool" , "Automatically restart pyLoad when required" , True ),
+ ("reloadplugins", "bool" , "Monitor plugins for code changes in debug mode", True ),
+ ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , True )]
__description__ = """Check for updates"""
__license__ = "GPLv3"
@@ -29,8 +32,9 @@ class UpdateManager(Addon):
# event_list = ["pluginConfigChanged"]
- SERVER_URL = "http://updatemanager.pyload.org"
- MIN_INTERVAL = 6 * 60 * 60 #: 6h minimum check interval (value is in seconds)
+ SERVER_URL = "http://updatemanager.pyload.org"
+ VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)')
+ MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds)
def pluginConfigChanged(self, plugin, name, value):
@@ -125,7 +129,7 @@ class UpdateManager(Addon):
status = self.update(onlyplugin=self.getConfig("mode") == "plugins only")
- if status == 2:
+ if status is 2 and self.getConfig("autorestart"):
self.core.api.restart()
else:
self.updating = False
@@ -173,21 +177,38 @@ class UpdateManager(Addon):
exitcode = 0
updated = []
- vre = re.compile(r'__version__.*=.*("|\')([\d.]+)')
- url = updates[0]
+ url = updates[0]
schema = updates[1].split('|')
if "BLACKLIST" in updates:
blacklist = updates[updates.index('BLACKLIST') + 1:]
- updates = updates[2:updates.index('BLACKLIST')]
+ updates = updates[2:updates.index('BLACKLIST')]
else:
blacklist = None
- updates = updates[2:]
+ updates = updates[2:]
+
+ upgradable = [dict(zip(schema, x.split('|'))) for x in updates]
+ blacklisted = [(x.split('|')[0], x.split('|')[1].rsplit('.', 1)[0]) for x in blacklist] if blacklist else []
- upgradable = sorted(map(lambda x: dict(zip(schema, x.split('|'))), updates),
- key=itemgetter("type", "name"))
+ if blacklist:
+ # Protect internal plugins against removing
+ for i, t, n in enumerate(blacklisted):
+ if t == "internal":
+ blacklisted.pop(i)
+ continue
+
+ for idx, plugin in enumerate(upgradable):
+ if n == plugin['name'] and t == plugin['type']:
+ upgradable.pop(idx)
+ break
+
+ for t, n in self.removePlugins(sorted(blacklisted)):
+ self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % {
+ 'type': t,
+ 'name': n,
+ })
- for plugin in upgradable:
+ for plugin in sorted(upgradable, key=itemgetter("type", "name")):
filename = plugin['name']
type = plugin['type']
version = plugin['version']
@@ -215,34 +236,18 @@ class UpdateManager(Addon):
'newver': newver})
try:
content = getURL(url % plugin)
- m = vre.search(content)
+ m = self.VERSION.search(content)
if m and m.group(2) == version:
- f = open(safe_join("userplugins", prefix, filename), "wb")
- f.write(content)
- f.close()
+ with open(safe_join("userplugins", prefix, filename), "wb") as f:
+ f.write(content)
+
updated.append((prefix, name))
else:
raise Exception, _("Version mismatch")
except Exception, e:
- self.logError(_("Error updating plugin %s") % filename, e)
-
- if blacklist:
- blacklisted = map(lambda x: (x.split('|')[0], x.split('|')[1].rsplit('.', 1)[0]), blacklist)
-
- # Always protect internal plugins from removing
- for i, n, t in blacklisted.enumerate():
- if t == "internal":
- del blacklisted[i]
-
- blacklisted = sorted(blacklisted)
- removed = self.removePlugins(blacklisted)
- for t, n in removed:
- self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % {
- 'type': t,
- 'name': n,
- })
+ self.logError(_("Error updating plugin: %s") % filename, str(e))
if updated:
reloaded = self.core.pluginManager.reloadPlugins(updated)