[Neo-report] r2131 vincent - /trunk/neo/pt.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Jun 4 17:06:44 CEST 2010
Author: vincent
Date: Fri Jun 4 17:06:43 2010
New Revision: 2131
Log:
Make it possible to get pt representation as text.
Modified:
trunk/neo/pt.py
Modified: trunk/neo/pt.py
==============================================================================
--- trunk/neo/pt.py [iso-8859-1] (original)
+++ trunk/neo/pt.py [iso-8859-1] Fri Jun 4 17:06:43 2010
@@ -231,6 +231,13 @@
return self.num_filled_rows == self.np
def log(self):
+ for line in self._format():
+ logging.debug(line)
+
+ def format(self):
+ return '\n'.join(self._format())
+
+ def _format(self):
"""Help debugging partition table management.
Output sample:
@@ -249,6 +256,8 @@
partition on the line (here, line length is 9 to keep the docstring
width under 80 column).
"""
+ result = []
+ append = result.append
node_list = self.count_dict.keys()
node_list = [k for k, v in self.count_dict.items() if v != 0]
node_list.sort()
@@ -256,15 +265,15 @@
for i, node in enumerate(node_list):
uuid = node.getUUID()
node_dict[uuid] = i
- logging.debug('pt: node %d: %s, %s', i, dump(uuid),
- protocol.node_state_prefix_dict[node.getState()])
+ append('pt: node %d: %s, %s' % (i, dump(uuid),
+ protocol.node_state_prefix_dict[node.getState()]))
line = []
max_line_len = 20 # XXX: hardcoded number of partitions per line
cell_state_dict = protocol.cell_state_prefix_dict
for offset, row in enumerate(self.partition_list):
if len(line) == max_line_len:
- logging.debug('pt: %08d: %s', offset - max_line_len,
- '|'.join(line))
+ append('pt: %08d: %s' % (offset - max_line_len,
+ '|'.join(line)))
line = []
if row is None:
line.append('X' * len(node_list))
@@ -279,8 +288,9 @@
cell.append('.')
line.append(''.join(cell))
if len(line):
- logging.debug('pt: %08d: %s', offset - len(line) + 1,
- '|'.join(line))
+ append('pt: %08d: %s' % (offset - len(line) + 1,
+ '|'.join(line)))
+ return result
def operational(self):
if not self.filled():
More information about the Neo-report
mailing list