def update_check(): ''' Checks for any available updates Returns dict from core.version.Version.manager.update_check(): {'status': 'error', 'error': <error> } {'status': 'behind', 'behind_count': #, 'local_hash': 'abcdefg', 'new_hash': 'bcdefgh'} {'status': 'current'} ''' ver = version.Version() data = ver.manager.update_check() # if data['status'] == u'current', nothing to do. if data['status'] == u'error': notif = { 'type': 'warning', 'closeButton': 'true', 'title': 'Error Checking for Updates', 'body': data['error'], 'params': '{closeButton: true, timeOut: 0, extendedTimeOut: 0}' } Notification.add(notif) elif data['status'] == u'behind': if data['behind_count'] == 1: title = u'1 Update Available' else: title = u'{} Updates Available'.format(data['behind_count']) compare = u'{}/compare/{}...{}'.format(core.GIT_URL, data['local_hash'], data['new_hash']) notif = { 'type': 'update', 'title': title, 'body': 'Click <a href="update_now"><u>here</u></a> to update now.' '<br/> Click <a href="' + compare + '"><u>here</u></a> to view changes.', 'params': { 'timeOut': 0, 'extendedTimeOut': 0, 'tapToDismiss': 0 } } Notification.add(notif) return data
def update_check(): ''' Checks for any available updates Returns dict from core.version.Version.manager.update_check(): {'status': 'error', 'error': <error> } {'status': 'behind', 'behind_count': #, 'local_hash': 'abcdefg', 'new_hash': 'bcdefgh'} {'status': 'current'} ''' ver = version.Version() data = ver.manager.update_check() # if data['status'] == 'current', nothing to do. if data['status'] == 'error': notif = { 'icon': 'fa-exclamation-triangle', 'title': 'Error Checking for Updates', 'text': data['error'] } Notification.add(notif) elif data['status'] == 'behind': if core.CONFIG['Server']['installupdates'] == 'true': hour = core.CONFIG['Server']['installupdatehr'] minute = core.CONFIG['Server']['installupdatemin'] text = 'Updates will install automatically at {}:{}'.format( hour, minute) else: text = '' if data['behind_count'] == 1: title = '1 Update Available' else: title = '{} Updates Available'.format(data['behind_count']) title_link = '{}/compare/{}...{}'.format(core.GIT_API, data['new_hash'], data['local_hash']) button = ('Update Now', '/update_now', 'fa-arrow-circle-up') notif = { 'icon': 'fa-star', 'title': title, 'title_link': title_link, 'text': text, 'button': button } Notification.add(notif) return data