|
From: <fcr...@us...> - 2012-12-29 04:29:52
|
Revision: 827
http://safekeep.svn.sourceforge.net/safekeep/?rev=827&view=rev
Author: fcrawford
Date: 2012-12-29 04:29:43 +0000 (Sat, 29 Dec 2012)
Log Message:
-----------
Handle issues with random characters in log messages.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2012-12-23 08:11:42 UTC (rev 826)
+++ safekeep/trunk/safekeep 2012-12-29 04:29:43 UTC (rev 827)
@@ -92,7 +92,10 @@
return repr(self.value)
def send(msg):
- print msg.encode('utf-8')
+ try:
+ print msg.encode('utf-8', 'backslashreplace')
+ except UnicodeDecodeError:
+ print str(msg).encode('string_escape')
sys.stdout.flush()
def log(msg, cls=None):
@@ -111,11 +114,15 @@
cutoff = VEBOSITY_BY_CLASS.get(cls.upper())
if cutoff is None: cutoff = 3
if is_client or verbosity_level >= cutoff:
- logbuf.append(msg)
+ try:
+ str_msg = msg.encode('utf-8', 'backslashreplace')
+ except UnicodeDecodeError:
+ str_msg = str(msg).encode('string_escape')
+ logbuf.append(str_msg)
if is_client:
- send(msg)
+ send(str_msg)
else:
- print >> sys.stderr, msg.encode('utf-8')
+ print >> sys.stderr, str_msg
def info_file(filename, marker=None, stats=None):
info('# File: ' + filename)
@@ -312,7 +319,7 @@
'Mirror size',
'Total changed') + \
'\r\n',
- '-' * 141 + '\r\n'];
+ '-' * 141 + '\r\n']
for stats in statistics:
result.append(print_stats_table_list_text(stats) + '\r\n' + '-' * 141 + '\r\n')
@@ -330,7 +337,7 @@
'<th>Source size</th>'
'<th>Mirror size</th>'
'<th>Total changed</th>'
- '</tr>'];
+ '</tr>']
for stats in statistics:
result.append(print_stats_table_list_html(stats))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|