Rev 26: Make verbose more detailed. in http://code.launchpad.net/%7Ev-ladeuil/bzr/transportstats
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Nov 26 09:53:39 GMT 2007
At http://code.launchpad.net/%7Ev-ladeuil/bzr/transportstats
------------------------------------------------------------
revno: 26
revision-id:v.ladeuil+lp at free.fr-20071126095337-sndr0b2f47g0m26z
parent: v.ladeuil+lp at free.fr-20071120103420-r9wpl2gl0w7u3e20
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: transportstats
timestamp: Mon 2007-11-26 10:53:37 +0100
message:
Make verbose more detailed.
* statsfile.py:
(UniqueByteLongStringsContainer): 255 is the highest value
storable on a byte, AFAIK.
(StatsContainer): Name the serializer by what they contains not by
how they store their content.
(StatsFile): Bump the format since the previous one was bogus.
* stats.py:
(StatsPart.__init__): Create a format usable with print
* commands.py:
(cmd_ts_display.run): Display all the raw attributes when using
'-v'.
modified:
commands.py commands.py-20070927123419-zy82qayy9xzwxvzi-1
stats.py stats.py-20070928061304-7i3r2h4gg6rbi03e-1
statsfile.py structuredfile.py-20070927123433-krruwbx4mkalu3xs-1
-------------- next part --------------
=== modified file 'commands.py'
--- a/commands.py 2007-10-09 07:11:09 +0000
+++ b/commands.py 2007-11-26 09:53:37 +0000
@@ -66,7 +66,7 @@
total_latency = 0
for stat in mystats:
if verbose:
- print '%s: %s%s' % (stat.name, stat.base, stat.relpath)
+ print stat._print_fmt % stat.__dict__
bytes_read += getattr(stat, 'bytes_read', 0)
bytes_written += getattr(stat, 'bytes_written', 0)
latency = getattr(stat, 'latency', None)
=== modified file 'stats.py'
--- a/stats.py 2007-11-20 10:34:20 +0000
+++ b/stats.py 2007-11-26 09:53:37 +0000
@@ -43,8 +43,16 @@
def __init__(self, name, format, *args):
self.name = name
+ # Create the attributes holding the values
for fmt_spec, value in map(None, format.parts, args):
object.__setattr__(self, fmt_spec.name, value)
+ # Create a format usable for print showing the raw parameters provided
+ # for serialization
+ print_fmt = '%(name)s('
+ print_fmt += ','.join(['%(' + fmt_spec.name + ')r'
+ for fmt_spec in format.parts])
+ print_fmt += ')'
+ self._print_fmt = print_fmt
class TransportStat(StatsPart):
=== modified file 'statsfile.py'
--- a/statsfile.py 2007-10-08 14:19:14 +0000
+++ b/statsfile.py 2007-11-26 09:53:37 +0000
@@ -33,8 +33,8 @@
'_nb_ustrings')
_string_serializer = serialize.format_specifier_registry.get('s')('_string')
- def __init__(self, size=256):
- if size > 256:
+ def __init__(self, size=255):
+ if size > 255:
raise ValueError("Can't store %d on a byte" % size - 1)
self.idx_of = {} # Used when collecting
self.strings = [] # Used when exploiting
@@ -190,13 +190,13 @@
# FIXME: implement array format specifier and use it
class StatsContainer(list):
- _ubyte_serializer = serialize.format_specifier_registry.get('H')(
+ _nb_strings_serializer = serialize.format_specifier_registry.get('H')(
'_nb_stats')
- _string_serializer = serialize.format_specifier_registry.get('s')('_stat')
+ _strings_serializer = serialize.format_specifier_registry.get('s')('_stat')
- def __init__(self, max_size=65536):
+ def __init__(self, max_size=65535):
super(StatsContainer, self).__init__()
- if max_size > 65536:
+ if max_size > 65535:
raise ValueError("Can't store %d on a two bytes" % max_size - 1)
self._max_size = max_size
@@ -205,10 +205,10 @@
def write(self, file):
# How many stats
- self._ubyte_serializer.pack(file, len(self))
+ self._nb_strings_serializer.pack(file, len(self))
# The stats themselves
for stat in self:
- self._string_serializer.pack(file, stat)
+ self._strings_serializer.pack(file, stat)
def flush(self, file):
self.write(file)
@@ -217,10 +217,10 @@
def read(self, file):
del self[:]
# How many stats
- nb = self._ubyte_serializer.unpack(file)
+ nb = self._nb_strings_serializer.unpack(file)
# The stats themselves
for i in range(nb):
- self.append(self._string_serializer.unpack(file))
+ self.append(self._strings_serializer.unpack(file))
class _file_wrapper(object):
@@ -239,8 +239,8 @@
class StatsFile(_file_wrapper):
- _current_format = 'Transport stats Bzr plugin 1'
- _default_buf_size = 65536
+ _current_format = 'Transport stats Bzr plugin 2'
+ _default_buf_size = 65535
_header_of = {'file': Header(_current_format),
'marker': Header('\xde\xad\xbe\xef'),
'ustrings': Header('ustrings'),
More information about the bazaar-commits
mailing list