diff options
Diffstat (limited to 'module/plugins/hooks/UpdateManager.py')
-rw-r--r-- | module/plugins/hooks/UpdateManager.py | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index caebdaa9b..41c11ed98 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -10,13 +10,13 @@ import time from module.plugins.internal.Addon import Expose, Addon, threaded from module.plugins.internal.Plugin import exists -from module.utils import fs_encode, save_join as fs_join +from module.plugins.internal.utils import encode, fs_join class UpdateManager(Addon): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "1.00" + __version__ = "1.01" __status__ = "testing" __config__ = [("activated" , "bool", "Activated" , True ), @@ -34,9 +34,8 @@ class UpdateManager(Addon): _VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') - SERVER_URL = "http://updatemanager.pyload.org" - - PERIODICAL_INTERVAL = 3 * 60 * 60 #: 3 hours + SERVER_URL = "http://updatemanager.pyload.org" + CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours def activate(self): @@ -66,7 +65,6 @@ class UpdateManager(Addon): def all_downloads_processed(self): if self.do_restart is True: - self.log_warning(_("Downloads are done, restarting pyLoad to reload the updated plugins")) self.pyload.api.restart() @@ -79,7 +77,7 @@ class UpdateManager(Addon): return if self.get_config('checkperiod') and \ - time.time() - max(self.PERIODICAL_INTERVAL, self.get_config('checkinterval') * 60 * 60) > self.info['last_check']: + time.time() - max(self.CHECK_INTERVAL, self.get_config('checkinterval') * 60 * 60) > self.info['last_check']: self.update() @@ -129,7 +127,7 @@ class UpdateManager(Addon): get={'v': self.pyload.api.getServerVersion()}) except Exception: - self.log_warning(_("Unable to retrieve server to get updates")) + self.log_warning(_("Unable to connect to the server to retrieve updates")) else: res = html.splitlines() @@ -156,7 +154,7 @@ class UpdateManager(Addon): self.pyload.api.restart() else: self.do_restart = True - self.log_warning(_("Downloads are active, will restart once the download is done")) + self.log_warning(_("pyLoad restart scheduled"), _("Downloads are active, pyLoad restart postponed once the download is done")) self.pyload.api.pauseServer() @@ -170,11 +168,11 @@ class UpdateManager(Addon): exitcode = 0 elif newversion == "None": - self.log_info(_("No new pyLoad version available")) + self.log_info(_("pyLoad is up to date!")) exitcode = self.update_plugins() else: - self.log_info(_("*** New pyLoad Version %s available ***") % newversion) + self.log_info(_("*** New pyLoad %s available ***") % newversion) self.log_info(_("*** Get it here: https://github.com/pyload/pyload/releases ***")) self.info['pyload'] = True exitcode = 3 @@ -202,13 +200,13 @@ class UpdateManager(Addon): if self.pyload.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.log_warning(_("You have to restart pyLoad to reload the updated plugins")) + self.log_warning(_("You have to restart pyLoad to use the updated plugins")) self.info['plugins'] = True exitcode = 2 self.manager.dispatchEvent("plugin_updated", updated) else: - self.log_info(_("*** No plugin updates available ***")) + self.log_info(_("All plugins are up to date!")) exitcode = 0 #: Exit codes: @@ -278,6 +276,7 @@ class UpdateManager(Addon): 'name': n, }) + req = self.pyload.requestFactory.getRequest(self.classname) for plugin in updatelist: name = plugin['name'] type = plugin['type'] @@ -300,9 +299,12 @@ class UpdateManager(Addon): 'oldver': oldver, 'newver': newver}) try: - content = self.load(url % plugin + ".py", decode=False) - m = self._VERSION.search(content) + content = self.load(url % plugin + ".py", decode=False, req=req) + if req.code == 404: + raise Exception(_("Plugin URL not found (404)")) + + m = self._VERSION.search(content) if m and m.group(2) == version: #@TODO: Remove in 0.4.10 if type in ("account", "hook"): @@ -311,11 +313,11 @@ class UpdateManager(Addon): folder = type with open(fs_join("userplugins", folder, name + ".py"), "wb") as f: - f.write(fs_encode(content)) + f.write(encode(content)) updated.append((type, name)) else: - raise Exception(_("Version mismatch")) + raise Exception(_("Plugin version mismatch")) except Exception, e: self.log_error(_("Error updating plugin: %s %s") % (type.upper(), name), e) @@ -372,7 +374,7 @@ class UpdateManager(Addon): os.remove(filename) except OSError, e: - self.log_warning(_("Error removing: %s") % filename, e) + self.log_error(_("Error removing: %s") % filename, e) else: id = (type, name) |