From 2b3d3d91e30715b44db2220216c8ee4f6a3ab6d6 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 21 Apr 2013 19:43:09 -0400 Subject: added utf8 encoding to stdout writes --- askbot/management/__init__.py | 2 +- askbot/management/commands/dump_forum.py | 2 +- askbot/management/commands/merge_users.py | 4 ++-- askbot/startup_procedures.py | 11 ----------- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/askbot/management/__init__.py b/askbot/management/__init__.py index 6dc50083..8decc48a 100644 --- a/askbot/management/__init__.py +++ b/askbot/management/__init__.py @@ -55,7 +55,7 @@ class NoArgsJob(NoArgsCommand): afterwards there will be a short summary """ - sys.stdout.write(batch['title']) + sys.stdout.write(batch['title'].encode('utf-8')) changed_count = 0 checked_count = 0 total_count = batch['query_set'].count() diff --git a/askbot/management/commands/dump_forum.py b/askbot/management/commands/dump_forum.py index cabc8ae8..0bead908 100644 --- a/askbot/management/commands/dump_forum.py +++ b/askbot/management/commands/dump_forum.py @@ -20,7 +20,7 @@ The extension ".json" will be added automatically.""" hint = options.get('dump_file', None), extension = '.json' ) - print "Saving file %s ..." % dump_file.name + print ("Saving file %s ..." % dump_file.name).encode('utf-8') stdout_orig = sys.stdout try: sys.stdout = dump_file diff --git a/askbot/management/commands/merge_users.py b/askbot/management/commands/merge_users.py index 9eb76756..189b74bb 100644 --- a/askbot/management/commands/merge_users.py +++ b/askbot/management/commands/merge_users.py @@ -21,13 +21,13 @@ class MergeUsersBaseCommand(BaseCommand): try: self.process_field(rel.model, rel.field.name) except Exception, error: - self.stdout.write(u'Warning: %s\n' % error) + self.stdout.write((u'Warning: %s\n' % error).encode('utf-8')) for rel in User._meta.get_all_related_many_to_many_objects(): try: self.process_m2m_field(rel.model, rel.field.name) except Exception, error: - self.stdout.write(u'Warning: %s\n' % error) + self.stdout.write((u'Warning: %s\n' % error).encode('utf-8')) self.process_custom_user_fields() diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index d91464f4..2c8b1eb4 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -218,16 +218,6 @@ def test_postgres(): else: pass #everythin is ok -def test_encoding(): - """prints warning if encoding error is not UTF-8""" - if hasattr(sys.stdout, 'encoding'): - if sys.stdout.encoding != 'UTF-8': - askbot_warning( - 'Your output encoding is not UTF-8, there may be ' - 'issues with the software when anything is printed ' - 'to the terminal or log files' - ) - def test_template_loader(): """Sends a warning if you have an old style template loader that used to send a warning""" @@ -919,7 +909,6 @@ def run_startup_tests(): test_celery() test_compressor() test_custom_user_profile_tab() - test_encoding() test_group_messaging() test_haystack() test_jinja2() -- cgit v1.2.3-1-g7c22