@@ -14,7 +14,7 @@ deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:pep8]
-commands = flake8 --exclude="*testsuite.dir*" ovs/ ovstest/ {toxinidir}/../tests/ {toxinidir}/../debian/ovs-monitor-ipsec
+commands = flake8 --exclude="*testsuite.dir*" ovs/ ovstest/ {toxinidir}/../tests/ {toxinidir}/../debian/ovs-monitor-ipsec {toxinidir}/../utilities/ovs-pcap.in
[flake8]
ignore=E111,E113,E126,E127,E128,E129,E131
@@ -14,14 +14,18 @@
# 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)
Also address style errors found by flake8 and add it to the list of files checked in the pep8 tox environment. Signed-off-by: Russell Bryant <russell@ovn.org> --- python/tox.ini | 2 +- utilities/ovs-pcap.in | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-)