summaryrefslogtreecommitdiffstats
path: root/module/plugins/addons/UpdateManager.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-24 17:16:34 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-24 17:16:34 +0100
commit3ae2fbb170ad0f2bfe1ebf7f59e76d3645861f0a (patch)
treeb01e2c881aaf744aaab0af613a7a26e7129f2028 /module/plugins/addons/UpdateManager.py
parententer captchas on webui (diff)
parentRapidgator: fixed bug #47 (diff)
downloadpyload-3ae2fbb170ad0f2bfe1ebf7f59e76d3645861f0a.tar.xz
Merge remote-tracking branch 'origin/stable'
Conflicts: module/plugins/accounts/FilesonicCom.py module/plugins/accounts/OronCom.py module/plugins/accounts/ShareonlineBiz.py module/plugins/addons/UpdateManager.py module/plugins/crypter/FilesonicComFolder.py module/plugins/hoster/BezvadataCz.py module/plugins/hoster/EuroshareEu.py module/plugins/hoster/FilesonicCom.py module/plugins/hoster/MegauploadCom.py module/plugins/hoster/Premium4Me.py module/plugins/hoster/YoutubeCom.py module/plugins/internal/MultiHoster.py module/utils.py
Diffstat (limited to 'module/plugins/addons/UpdateManager.py')
-rw-r--r--module/plugins/addons/UpdateManager.py86
1 files changed, 44 insertions, 42 deletions
diff --git a/module/plugins/addons/UpdateManager.py b/module/plugins/addons/UpdateManager.py
index 5bc6ac447..c800b44bf 100644
--- a/module/plugins/addons/UpdateManager.py
+++ b/module/plugins/addons/UpdateManager.py
@@ -23,25 +23,27 @@ from os import stat
from os.path import join, exists
from time import time
-from module.plugins.PluginManager import IGNORE
+from module.ConfigParser import IGNORE
from module.network.RequestFactory import getURL
-from module.plugins.Addon import threaded, Expose, Addon
+from module.plugins.Hook import threaded, Expose, Hook
-class UpdateManager(Addon):
+class UpdateManager(Hook):
__name__ = "UpdateManager"
- __version__ = "0.12"
+ __version__ = "0.13"
__description__ = """checks for updates"""
__config__ = [("activated", "bool", "Activated", "True"),
- ("interval", "int", "Check interval in minutes", "360"),
+ ("interval", "int", "Check interval in minutes", "480"),
("debug", "bool", "Check for plugin changes when in debug mode", False)]
__author_name__ = ("RaNaN")
__author_mail__ = ("ranan@pyload.org")
+ URL = "http://get.pyload.org/check2/%s/"
+ MIN_TIME = 3 * 60 * 60 # 3h minimum check interval
+
@property
def debug(self):
return self.core.debug and self.getConfig("debug")
-
def setup(self):
if self.debug:
self.logDebug("Monitoring file changes")
@@ -51,26 +53,20 @@ class UpdateManager(Addon):
self.periodical = self.checkChanges
self.mtimes = {} #recordes times
else:
- self.interval = self.getConfig("interval") * 60
+ self.interval = max(self.getConfig("interval") * 60, self.MIN_TIME)
self.updated = False
self.reloaded = True
+ self.version = "None"
self.info = {"pyload": False, "plugins": False}
@threaded
def periodical(self):
- if self.core.version.endswith("-dev"):
- self.logDebug("No update check performed on dev version.")
- return
-
- update = self.checkForUpdate()
- if update:
- self.info["pyload"] = True
- else:
- self.log.info(_("No Updates for pyLoad"))
- self.checkPlugins()
+ updates = self.checkForUpdate()
+ if updates:
+ self.checkPlugins(updates)
if self.updated and not self.reloaded:
self.info["plugins"] = True
@@ -78,7 +74,7 @@ class UpdateManager(Addon):
elif self.updated and self.reloaded:
self.log.info(_("Plugins updated and reloaded"))
self.updated = False
- else:
+ elif self.version == "None":
self.log.info(_("No plugin updates available"))
@Expose
@@ -87,57 +83,63 @@ class UpdateManager(Addon):
self.periodical()
def checkForUpdate(self):
- """checks if an update is available"""
+ """checks if an update is available, return result"""
try:
- version_check = getURL("http://get.pyload.org/check/%s/" % self.core.api.getServerVersion())
- if version_check == "":
- return False
- else:
- self.log.info(_("*** New pyLoad Version %s available ***") % version_check)
- self.log.info(_("*** Get it here: http://pyload.org/download ***"))
- return True
+ if self.version == "None": # No updated known
+ version_check = getURL(self.URL % self.core.api.getServerVersion()).splitlines()
+ self.version = version_check[0]
+
+ # Still no updates, plugins will be checked
+ if self.version == "None":
+ self.log.info(_("No Updates for pyLoad"))
+ return version_check[1:]
+
+
+ self.info["pyload"] = True
+ self.log.info(_("*** New pyLoad Version %s available ***") % self.version)
+ self.log.info(_("*** Get it here: http://pyload.org/download ***"))
+
except:
self.log.warning(_("Not able to connect server for updates"))
- return False
+
+ return None # Nothing will be done
- def checkPlugins(self):
+ def checkPlugins(self, updates):
""" checks for plugins updates"""
# plugins were already updated
if self.info["plugins"]: return
- try:
- updates = getURL("http://get.pyload.org/plugins/check/")
- except:
- self.log.warning(_("Not able to connect server for updates"))
- return False
-
- updates = updates.splitlines()
reloads = []
vre = re.compile(r'__version__.*=.*("|\')([0-9.]+)')
+ url = updates[0]
+ schema = updates[1].split("|")
+ updates = updates[2:]
for plugin in updates:
- path, version = plugin.split(":")
- prefix, filename = path.split("/")
+ info = dict(zip(schema, plugin.split("|")))
+ filename = info["name"]
+ prefix = info["type"]
+ version = info["version"]
if filename.endswith(".pyc"):
name = filename[:filename.find("_")]
else:
name = filename.replace(".py", "")
- #TODO: obsolete
+ #TODO: obsolete in 0.5.0
if prefix.endswith("s"):
type = prefix[:-1]
else:
type = prefix
- plugins = self.core.pluginManager.getPlugins(type)
+ plugins = getattr(self.core.pluginManager, "%sPlugins" % type)
if name in plugins:
- if float(plugins[name].version) >= float(version):
+ if float(plugins[name]["v"]) >= float(version):
continue
if name in IGNORE or (type, name) in IGNORE:
@@ -150,7 +152,7 @@ class UpdateManager(Addon):
})
try:
- content = getURL("http://get.pyload.org/plugins/get/" + path)
+ content = getURL(url % info)
except Exception, e:
self.logWarning(_("Error when updating %s") % filename, str(e))
continue
@@ -171,7 +173,7 @@ class UpdateManager(Addon):
def checkChanges(self):
- if self.last_check + self.getConfig("interval") * 60 < time():
+ if self.last_check + max(self.getConfig("interval") * 60, self.MIN_TIME) < time():
self.old_periodical()
self.last_check = time()