From: jordan Date: Sat, 30 Jul 2011 17:55:28 +0000 (+0000) Subject: Resolves Jira OSQA-733, we encode the unicode data according to the ASCII XML Unicode... X-Git-Tag: live~179 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/66a9b774bae30bc2d43dce226b4fd95ceea6f126 Resolves Jira OSQA-733, we encode the unicode data according to the ASCII XML Unicode chars specification, also making the updater module log the fails silently git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1134 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum_modules/updates/base.py b/forum_modules/updates/base.py index 2303152..ce5bc8b 100644 --- a/forum_modules/updates/base.py +++ b/forum_modules/updates/base.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import os import sys import platform @@ -92,7 +94,7 @@ def check_for_updates(): database_type = get_database_engine() - statistics = """ + statistics = u""" @@ -129,6 +131,7 @@ def check_for_updates(): } # Compress the statistics XML dump + statistics = statistics.encode('ascii', 'xmlcharrefreplace') statistics_compressed = bz2.compress(statistics) # Pass the compressed statistics to the update server @@ -175,7 +178,10 @@ def update_trigger(): # Trigger the update process now = datetime.datetime.now() if (now - settings.LATEST_UPDATE_DATETIME) > datetime.timedelta(days=1): - update_status = check_for_updates() - - logging.error(smart_unicode("Update process has been triggered: %s" % update_status)) - settings.LATEST_UPDATE_DATETIME.set_value(now) + try: + update_status = check_for_updates() + logging.log(logging.INFO, smart_unicode("Update process has been triggered: %s" % update_status)) + except Exception, e: + logging.errror(smart_unicode(e)) + finally: + settings.LATEST_UPDATE_DATETIME.set_value(now)