Skip to content

Commit

Permalink
Turn dict_keys and dict_values into lists.
Browse files Browse the repository at this point in the history
The tool 2to3 discovered these issues.
  • Loading branch information
NullHypothesis committed May 8, 2020
1 parent 2ab97fc commit 1655649
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions onionperf/analysis.py
Expand Up @@ -50,7 +50,7 @@ def add_torctl_file(self, filepath):
self.torctl_filepaths.append(filepath)

def get_nodes(self):
return self.json_db['data'].keys()
return list(self.json_db['data'].keys())

def get_tor_bandwidth_summary(self, node, direction):
try:
Expand Down Expand Up @@ -160,13 +160,13 @@ def export_torperf_version_1_1(self, output_prefix=os.getcwd(), do_compress=Fals
continue

xfers_by_filesize = {}
for xfer_db in self.json_db['data'][nickname]['tgen']['transfers'].values():
for xfer_db in list(self.json_db['data'][nickname]['tgen']['transfers'].values()):
xfers_by_filesize.setdefault(xfer_db['filesize_bytes'], []).append(xfer_db)

streams_by_srcport, circuits = {}, []
if 'tor' in self.json_db['data'][nickname]:
if 'streams' in self.json_db['data'][nickname]['tor']:
for streams_db in self.json_db['data'][nickname]['tor']['streams'].values():
for streams_db in list(self.json_db['data'][nickname]['tor']['streams'].values()):
if 'source' in streams_db:
srcport = int(streams_db['source'].split(':')[1])
streams_by_srcport[srcport] = streams_db
Expand Down Expand Up @@ -264,9 +264,9 @@ def ts_to_str(ts): return"{0:.02f}".format(ts)
srcport = int(xfer_db['endpoint_local'].split(':')[2])
if srcport in streams_by_srcport:
stream_db = streams_by_srcport[srcport]
if 'failure_reason_local' in stream_db.keys():
if 'failure_reason_local' in list(stream_db.keys()):
d['ERRORCODE'] += '_' + stream_db['failure_reason_local']
if 'failure_reason_remote' in stream_db.keys():
if 'failure_reason_remote' in list(stream_db.keys()):
d['ERRORCODE'] += '_' + stream_db['failure_reason_remote']
circid = int(stream_db['circuit_id'] or 0)
if circid in circuits:
Expand All @@ -280,7 +280,7 @@ def ts_to_str(ts): return"{0:.02f}".format(ts)
d['CIRC_ID'] = circid
d['USED_AT'] = stream_db['unix_ts_end']
d['USED_BY'] = int(stream_db['stream_id'])
if 'ERRORCODE' in d.keys():
if 'ERRORCODE' in list(d.keys()):
d['ERRORCODE'] = ERRORS[d['ERRORCODE']]

output.write("@type torperf 1.1\r\n")
Expand Down

0 comments on commit 1655649

Please sign in to comment.