[z3-checkins] r26131 - z3/jsonserver/branch/merge/utils
reebalazs at codespeak.net
reebalazs at codespeak.net
Sat Apr 22 12:31:48 CEST 2006
Author: reebalazs
Date: Sat Apr 22 12:31:48 2006
New Revision: 26131
Modified:
z3/jsonserver/branch/merge/utils/tcpwatch
Log:
Fix tcpwatch
Modified: z3/jsonserver/branch/merge/utils/tcpwatch
==============================================================================
--- z3/jsonserver/branch/merge/utils/tcpwatch (original)
+++ z3/jsonserver/branch/merge/utils/tcpwatch Sat Apr 22 12:31:48 2006
@@ -93,6 +93,9 @@
# To use the json_read, minjson, zope.component and zope.interface
# must be installable from the python level. If this does not happen,
# we provide a simple conversion that however will not always work.
+#
+# XXX other problem:
+# longer streams can be split. That destroys conversion.
try:
from minjson import read as json_read
# best to try these imports too, right away
@@ -215,6 +218,8 @@
writer.newline()
writer.write('}')
writer.indentoff()
+ elif isinstance(value, unicode):
+ writer.write('"%s"' % (value.encode('utf8', ))
else:
writer.write(repr(value))
@@ -477,14 +482,18 @@
lines = map(escape, lines)
# Try to prettify JSON output
if lines:
- result = json_prettify(lines[-1])
+ # find where to start from
+ for i, line in enumerate(lines):
+ if not line:
+ break
+ result = json_prettify('\n'.join(lines[i+1:]))
if result:
if getattr(self, '_colorized', True):
if from_client:
result = '\x1b[0;32m' + result + '\x1b[0m'
else:
result = '\x1b[0;31m' + result + '\x1b[0m'
- del lines[-1]
+ del lines[i+1:]
lines.extend(result.splitlines())
s = ('\n%s' % arrow).join(lines)
More information about the z3-checkins
mailing list