Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft fix for proper output log encoding of the send_newsletter management command #56

Open
nnseva opened this issue Feb 1, 2012 · 0 comments

Comments

@nnseva
Copy link

nnseva commented Feb 1, 2012

Wrong encoding leads to message from the cron like:

/usr/local/lib/python2.6/site-packages/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
  from sets import ImmutableSet
Starting sending newsletters...
Traceback (most recent call last):
  File "/data/www/django/djangosite/manage.py", line 11, in <module>
    execute_manager(settings)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/local/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/data/www/django/djangosite/emencia/django/newsletter/management/commands/send_newsletter.py", line 23, in handle_noargs
    print 'Start emailing %s' % newsletter.title
UnicodeEncodeError: 'ascii' codec can't encode characters in position 25-31: ordinal not in range(128)

This fix is a draft, because proper encoding fix should probably use current system locale, fixing unprintable characters

--- send_newsletter.py.orig
+++ send_newsletter.py 
@@ -20,7 +20,7 @@
             mailer = Mailer(newsletter)
             if mailer.can_send:
                 if verbose:
-                    print 'Start emailing %s' % newsletter.title
+                    print 'Start emailing %s' % unicode(newsletter.title).encode('utf-8')
                 mailer.run()

         if verbose:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant