Notify on update. closes #486

This commit is contained in:
Ruud
2012-06-26 23:06:22 +02:00
parent ea1b0c2816
commit 63a7ba85f3
2 changed files with 16 additions and 10 deletions
+12 -9
View File
@@ -51,7 +51,18 @@ class Updater(Plugin):
def autoUpdate(self):
if self.check() and self.conf('automatic') and not self.updater.update_failed:
self.updater.doUpdate()
if self.updater.doUpdate():
# Notify before restarting
try:
if self.conf('notification'):
info = self.updater.info()
version_date = datetime.fromtimestamp(info['update_version']['date'])
fireEvent('updater.updated', 'Updated to a new version with hash "%s", this version is from %s' % (info['update_version']['hash'], version_date), data = info)
except:
log.error('Failed notifying for update: %s', traceback.format_exc())
fireEventAsync('app.restart')
def check(self):
if self.isDisabled():
@@ -163,12 +174,6 @@ class GitUpdater(BaseUpdater):
# Delete leftover .pyc files
self.deletePyc()
# Notify before returning and restarting
version_date = datetime.fromtimestamp(info['update_version']['date'])
fireEvent('updater.updated', 'Updated to a new version with hash "%s", this version is from %s' % (info['update_version']['hash'], version_date), data = info)
fireEventAsync('app.restart')
return True
except:
log.error('Failed updating via GIT: %s', traceback.format_exc())
@@ -260,8 +265,6 @@ class SourceUpdater(BaseUpdater):
# Write update version to file
self.createFile(self.version_file, json.dumps(self.update_version))
fireEventAsync('app.restart')
return True
except:
log.error('Failed updating: %s', traceback.format_exc())
+4 -1
View File
@@ -13,7 +13,10 @@ class Notification(Plugin):
default_title = Env.get('appname')
test_message = 'ZOMG Lazors Pewpewpew!'
listen_to = ['movie.downloaded', 'movie.snatched', 'updater.available']
listen_to = [
'movie.downloaded', 'movie.snatched',
'updater.available', 'updater.updated',
]
dont_listen_to = []
def __init__(self):