Cron task: make sure log output is encoded to utf-8 before printing
authorGu1 <gu1@cafai.fr>
Tue, 31 Dec 2013 14:33:34 +0000 (15:33 +0100)
committerGu1 <gu1@cafai.fr>
Tue, 31 Dec 2013 14:33:34 +0000 (15:33 +0100)
In python, if stdout is not a tty (e.g piped output), then the output
encoding will fall back to the 'ascii' codec.

ffdnispdb/cron_task.py

index e04205e..cb8c1ba 100644 (file)
@@ -131,7 +131,7 @@ try:
                     print u'    three strikes, you\'re out'
                     send_warning_email(isp, log)
 
-                print log.rstrip()+'\n'
+                print log.rstrip().encode('utf-8')+'\n'
                 if exc:
                     print u'Unexpected exception in the validator: %r' % exc
                     print exc_log