python: Fix print function compatibility.
[cascardo/ovs.git] / utilities / ovs-pcap.in
index 8ab4756..ae30047 100755 (executable)
@@ -1,6 +1,6 @@
 #! @PYTHON@
 #
-# Copyright (c) 2010 Nicira Networks.
+# Copyright (c) 2010 Nicira, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import print_function
+
 import binascii
 import getopt
 import struct
 import sys
 
+
 class PcapException(Exception):
     pass
 
+
 class PcapReader(object):
     def __init__(self, file_name):
         self.file = open(file_name, "rb")
@@ -53,8 +57,9 @@ class PcapReader(object):
         return packet
 argv0 = sys.argv[0]
 
+
 def usage():
-    print """\
+    print("""\
 %(argv0)s: print pcap file packet data as hex
 usage: %(argv0)s FILE
 where FILE is a PCAP file.
@@ -62,7 +67,7 @@ where FILE is a PCAP file.
 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__":
@@ -70,7 +75,7 @@ if __name__ == "__main__":
         try:
             options, args = getopt.gnu_getopt(sys.argv[1:], 'hV',
                                               ['help', 'version'])
-        except getopt.GetoptException, geo:
+        except getopt.GetoptException as geo:
             sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
             sys.exit(1)
 
@@ -78,7 +83,7 @@ if __name__ == "__main__":
             if key in ['-h', '--help']:
                 usage()
             elif key in ['-V', '--version']:
-                print "ovs-pcap (Open vSwitch) @VERSION@"
+                print("ovs-pcap (Open vSwitch) @VERSION@")
             else:
                 sys.exit(0)
 
@@ -93,9 +98,9 @@ if __name__ == "__main__":
             if packet is None:
                 break
 
-            print binascii.hexlify(packet)
+            print(binascii.hexlify(packet))
 
-    except PcapException, e:
+    except PcapException as e:
         sys.stderr.write("%s: %s\n" % (argv0, e))
         sys.exit(1)