X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/4bb54868305058b21955e0a9d31368c11ab3d6ab..823a4dcbdbc04ed9cc21b4adf5e75b195f3196bc:/forum_modules/updater/views.py diff --git a/forum_modules/updater/views.py b/forum_modules/updater/views.py index 3066074..cc46914 100644 --- a/forum_modules/updater/views.py +++ b/forum_modules/updater/views.py @@ -4,14 +4,16 @@ import bz2 import urllib2, urllib import binascii +from xml.dom.minidom import parse, parseString + from django import VERSION as DJANGO_VERSION from django.http import HttpResponse from django.utils.translation import ugettext as _ from django.utils import simplejson from django.conf import settings -from base import get_site_views, get_server_name -from settings import SITE_KEY, UPDATE_SERVER_URL +from base import get_site_views, get_server_name, get_admin_emails +import settings as updater_settings from forum.settings import APP_URL, SVN_REVISION from forum.views.admin import admin_tools_page, admin_page @@ -32,6 +34,11 @@ def updater_check(request): # Here we'll have to find another way of getting the SVN revision svn_revision = 0 + admin_emails_xml = '' + for email in get_admin_emails(): + admin_emails_xml += '' % email + admin_emails_xml += '' + statistics = """ @@ -43,8 +50,9 @@ def updater_check(request): + %(emails)s """ % { - 'site_key' : SITE_KEY, + 'site_key' : updater_settings.SITE_KEY, 'app_url' : APP_URL, 'svn_revision' : svn_revision, 'site_views' : get_site_views(), @@ -53,6 +61,7 @@ def updater_check(request): 'django_version' : str(DJANGO_VERSION), 'database' : settings.DATABASE_ENGINE, 'os' : str(os.uname()), + 'emails' : admin_emails_xml, } # Compress the statistics XML dump @@ -69,11 +78,22 @@ def updater_check(request): headers={ 'User-Agent' : user_agent,} try: - check_request = urllib2.Request('%s%s' % (UPDATE_SERVER_URL, '/site_check/'), data, headers=headers) + check_request = urllib2.Request('%s%s' % (updater_settings.UPDATE_SERVER_URL, '/site_check/'), data, headers=headers) check_response = urllib2.urlopen(check_request) content = check_response.read() except urllib2.HTTPError, error: content = error.read() - json = simplejson.dumps({}) - return HttpResponse(content, mimetype='text/html') \ No newline at end of file + # Read the messages from the Update Server + messages_xml_url = '%s%s' % (updater_settings.UPDATE_SERVER_URL, '/messages/xml/') + messages_request = urllib2.Request(messages_xml_url, headers=headers) + messages_response = urllib2.urlopen(messages_request) + messages_xml = messages_response.read() + + # Store the messages XML in a Setting object + updater_settings.UPDATE_MESSAGES_XML.set_value(messages_xml) + + messages_dom = parseString(messages_xml) + messages_count = len(messages_dom.getElementsByTagName('message')) + + return HttpResponse(_('%d update messages have been downloaded') % messages_count, mimetype='text/html') \ No newline at end of file