Skip to content

Commit

Permalink
ovs-dpctl-top: python3 compatibility
Browse files Browse the repository at this point in the history
During the transition to python3 support, some syntax errors weren't
adequately cleaned.  This addresses the various errors, plus one
minor issue with string type conversion.

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1809184
Tested-by: Flavio Leitner <[email protected]>
Acked-by: Flavio Leitner <[email protected]>
Signed-off-by: Aaron Conole <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
apconole authored and blp committed Mar 5, 2020
1 parent ffbe63c commit 704ae35
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions utilities/ovs-dpctl-top.in
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def flows_read(ihdl, flow_db):

try:
flow_db.flow_line_add(line)
except ValueError, arg:
except ValueError as arg:
logging.error(arg)

return flow_db
Expand Down Expand Up @@ -958,6 +958,9 @@ class FlowDB:
change order of fields of the same flow.
"""

if not isinstance(line, str):
line = str(line)

line = line.rstrip("\n")
(fields, stats, _) = flow_line_split(line)

Expand Down Expand Up @@ -988,7 +991,7 @@ class FlowDB:

self.flow_event(fields_dict, stats_old_dict, stats_dict)

except ValueError, arg:
except ValueError as arg:
logging.error(arg)
self._error_count += 1
raise
Expand Down Expand Up @@ -1192,7 +1195,7 @@ def flows_top(args):
flows_read(ihdl, flow_db)
finally:
ihdl.close()
except OSError, arg:
except OSError as arg:
logging.critical(arg)
break

Expand Down Expand Up @@ -1220,7 +1223,7 @@ def flows_top(args):

# repeat output
for (count, line) in lines:
print line
print(line)


def flows_script(args):
Expand Down Expand Up @@ -1249,7 +1252,7 @@ def flows_script(args):
render = Render(console_width, Render.FIELD_SELECT_SCRIPT)

for line in render.format(flow_db):
print line
print(line)


def main():
Expand Down

0 comments on commit 704ae35

Please sign in to comment.