[tor-bugs] #13887 [Chutney]: Pick a reporting format for Chutney
Tor Bug Tracker & Wiki
blackhole at torproject.org
Wed Dec 3 16:48:42 UTC 2014
#13887: Pick a reporting format for Chutney
-------------------------+--------------------------------------
Reporter: nickm | Owner: nickm
Type: defect | Status: new
Priority: normal | Milestone:
Component: Chutney | Version:
Resolution: | Keywords: SponsorS design bikeshed
Actual Points: | Parent ID:
Points: |
-------------------------+--------------------------------------
Comment (by atagar):
> I'm especially interested in atagar's opinion about what would be
friendliest to a stem-based chutney.
Depends. Would you like to persist events to disk, then be able to parse
them back into Stem Event objects? If so then the text-based format would
work well, but it would be nice to find a delimitator that doesn't appear
in events (they already end with '\r\n'). Maybe something like
'\n-------\n'
To persist...
{{{
DIVIDER = '\n%s\n' % '-' * 80
events = my_events() # list of events you've received from tor
with open('/place/to/persist', 'w') as dump_file:
dump_file.write('DIVIDER'.join([msg.raw_content() for msg in events]))
}}}
... then to get them back...
{{{
events = []
with open('/place/to/persist') as dump_file:
for entry in dump_file.read().split(DIVIDER):
msg = stem.response.ControlMessage.from_str(entry)
stem.response.convert('EVENT', msg)
events.append(msg)
}}}
This might need a little twiddling (just wrote it off the top of my head,
didn't run it).
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/13887#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list