From 8eae2fa62baa096832bc4f5fb0c6d49ddb0470d1 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 15 May 2012 22:26:53 +0200 Subject: [PATCH] Desktop updater basics --- couchpotato/core/_base/updater/main.py | 28 ++++++++++++++++--- .../core/_base/updater/static/updater.js | 6 +++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index c3256038..ac9ad834 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -349,7 +349,13 @@ class DesktopUpdater(Plugin): self.desktop = Env.get('desktop') def doUpdate(self): - pass + try: + self.desktop.CheckForUpdate(silentUnlessUpdate = True) + except: + log.error('Failed updating desktop: %s' % traceback.format_exc()) + self.update_failed = True + + return False def info(self): return { @@ -360,12 +366,26 @@ class DesktopUpdater(Plugin): } def check(self): - self.desktop.CheckForUpdate(silentUnlessUpdate = True) + current_version = self.getVersion() + try: + latest = self.desktop._esky.find_update() + + if latest != current_version.get('hash'): + self.update_version = { + 'hash': latest, + 'date': None, + 'changelog': self.desktop._changelogURL, + } + + self.last_check = time.time() + except: + log.error('Failed updating desktop: %s' % traceback.format_exc()) + + return self.update_version is not None def getVersion(self): return { 'hash': self.desktop._esky.active_version, - 'data': None, + 'date': None, 'type': 'desktop', } - diff --git a/couchpotato/core/_base/updater/static/updater.js b/couchpotato/core/_base/updater/static/updater.js index 899f8796..bcbf48a8 100644 --- a/couchpotato/core/_base/updater/static/updater.js +++ b/couchpotato/core/_base/updater/static/updater.js @@ -52,12 +52,16 @@ var UpdaterBase = new Class({ createMessage: function(data){ var self = this; + var changelog = 'https://github.com/'+data.repo_name+'/compare/'+data.version.hash+'...'+data.update_version.hash; + if(data.update_version.changelog) + changelog = data.update_version.changelog + '#' + data.version.hash+'...'+data.update_version.hash + self.message = new Element('div.message.update').adopt( new Element('span', { 'text': 'A new version is available' }), new Element('a', { - 'href': 'https://github.com/'+data.repo_name+'/compare/'+data.version.hash+'...'+data.update_version.hash, + 'href': changelog, 'text': 'see what has changed', 'target': '_blank' }),