diff mbox series

[ovs-dev] ovs-tcpundump: Fix incompatibilities with python3

Message ID 85d64d647576215ebd9fcbcfb04dced86ee11ee0.1532449658.git.tredaelli@redhat.com
State Accepted
Headers show
Series [ovs-dev] ovs-tcpundump: Fix incompatibilities with python3 | expand

Commit Message

Timothy Redaelli July 24, 2018, 4:35 p.m. UTC
Added parenthesis after print and use "as" instead of "," in except.

This commit fixes also a couple of flake8 warnings:

    utilities/ovs-tcpundump:23:1: E302 expected 2 blank lines, found 1
    utilities/ovs-tcpundump:35:1: E305 expected 2 blank lines after class or
    function definition, found 1

Tested on Python 2.7.15 and Python 3.6.5

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 utilities/ovs-tcpundump.in | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Ben Pfaff July 24, 2018, 11:01 p.m. UTC | #1
On Tue, Jul 24, 2018 at 06:35:22PM +0200, Timothy Redaelli wrote:
> Added parenthesis after print and use "as" instead of "," in except.
> 
> This commit fixes also a couple of flake8 warnings:
> 
>     utilities/ovs-tcpundump:23:1: E302 expected 2 blank lines, found 1
>     utilities/ovs-tcpundump:35:1: E305 expected 2 blank lines after class or
>     function definition, found 1
> 
> Tested on Python 2.7.15 and Python 3.6.5
> 
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>

Applied to master, thanks!
diff mbox series

Patch

diff --git a/utilities/ovs-tcpundump.in b/utilities/ovs-tcpundump.in
index c99015b5b..c29870062 100755
--- a/utilities/ovs-tcpundump.in
+++ b/utilities/ovs-tcpundump.in
@@ -20,8 +20,9 @@  import sys
 
 argv0 = sys.argv[0]
 
+
 def usage():
-    print """\
+    print("""\
 %(argv0)s: print "tcpdump -xx" output as hex
 usage: %(argv0)s < FILE
 where FILE is output from "tcpdump -xx".
@@ -29,14 +30,15 @@  where FILE is output from "tcpdump -xx".
 The following options are also available:
   -h, --help                  display this help message
   -V, --version               display version information\
-""" % {'argv0': argv0}
+""" % {'argv0': argv0})
     sys.exit(0)
 
+
 if __name__ == "__main__":
     try:
         options, args = getopt.gnu_getopt(sys.argv[1:], 'hV',
                                           ['help', 'version'])
-    except getopt.GetoptError, geo:
+    except getopt.GetoptError as geo:
         sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
         sys.exit(1)
 
@@ -44,7 +46,7 @@  if __name__ == "__main__":
         if key in ['-h', '--help']:
             usage()
         elif key in ['-V', '--version']:
-            print "ovs-tcpundump (Open vSwitch) @VERSION@"
+            print("ovs-tcpundump (Open vSwitch) @VERSION@")
         else:
             sys.exit(0)
 
@@ -63,12 +65,12 @@  if __name__ == "__main__":
         m = regex.match(line)
         if m is None or int(m.group(1), 16) == 0:
             if packet != '':
-                print packet
+                print(packet)
             packet = ''
         if m:
             packet += re.sub(r'\s', '', m.group(2), 0)
     if packet != '':
-        print packet
+        print(packet)
 
 # Local variables:
 # mode: python