[tor-bugs] #29351 [Core Tor/Stem]: BandwidthFile TypeError when initializing or accessing attributes

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Feb 6 19:03:12 UTC 2019


#29351: BandwidthFile TypeError when initializing or accessing attributes
---------------------------+------------------------
 Reporter:  juga           |          Owner:  atagar
     Type:  defect         |         Status:  new
 Priority:  Medium         |      Milestone:
Component:  Core Tor/Stem  |        Version:
 Severity:  Normal         |     Resolution:
 Keywords:  tor-bwauth     |  Actual Points:
Parent ID:                 |         Points:
 Reviewer:                 |        Sponsor:
---------------------------+------------------------

Comment (by atagar):

 Hi juga, there's several ways of creating a descriptor depending on what
 you are making it from...

 = String Descriptor Content =

 {{{
 >>> from stem.descriptor.bandwidth_file import BandwidthFile
 >>> content = """1523911758
 ... node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=760 nick=Test"""
 >>> bwfile = BandwidthFile.from_str(content)
 >>> bwfile.measurements
 {u'68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80': {u'nick': u'Test',
 u'node_id': u'$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80', u'bw': u'760'}}
 }}}

 = File Descriptor Content =

 {{{
 >>> import stem.descriptor
 >>> bwfile = next(stem.descriptor.parse_file('bandwidth_file_v1.2',
 'bandwidth-file 1.2'))
 >>> print("This file has data for %i relays" % len(bwfile.measurements))
 This file has data for 81 relays
 }}}

 = Individual Attributes =

 {{{
 >>> from stem.descriptor.bandwidth_file import BandwidthFile
 >>> bwfile = BandwidthFile.create({
 ...   'version': '5.4.3',
 ...   'software': 'my_application',
 ...   'content': [
 ...     'bw=1 bw_mean=191643 bw_median=218251
 node_id=$92808CA58D8F32CA34A34C547610869BF4E2A6EC',
 ...     'bw=1 bw_mean=93766 bw_median=93606
 node_id=$A6443E49306288C7DAE9B8466568F08DA5BD58D4',
 ...   ],
 ... })
 >>> print(bwfile)
 1549479544
 version=5.4.3
 software=my_application
 =====
 bw=1 bw_mean=191643 bw_median=218251
 node_id=$92808CA58D8F32CA34A34C547610869BF4E2A6EC
 bw=1 bw_mean=93766 bw_median=93606
 node_id=$A6443E49306288C7DAE9B8466568F08DA5BD58D4
 }}}

 ----

 Did you have any other questions?

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/29351#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list