Merge into master from pull request #64:
fix/workaround all pylint errors (https://github.com/floodlight/oftest/pull/64)
diff --git a/.abat-automerge b/.abat-automerge
new file mode 100755
index 0000000..ad5e15d
--- /dev/null
+++ b/.abat-automerge
@@ -0,0 +1,9 @@
+#!/bin/bash -eux
+cd $(dirname $(readlink -f $0))
+./pylint.sh
+
+# Exercise uncommonly used options
+./oft --version
+./oft --help
+./oft --list
+./oft --list-test-names
diff --git a/oft b/oft
index 28de9f7..029c675 100755
--- a/oft
+++ b/oft
@@ -38,14 +38,6 @@
import oftest.help_formatter
import loxi
-try:
- import scapy.all as scapy
-except:
- try:
- import scapy as scapy
- except:
- sys.exit("Need to install scapy for packet parsing")
-
##@var DEBUG_LEVELS
# Map from strings to debugging levels
DEBUG_LEVELS = {
diff --git a/pylint.sh b/pylint.sh
new file mode 100755
index 0000000..e3d136b
--- /dev/null
+++ b/pylint.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+cd $(dirname $(readlink -f $0))
+PYTHONPATH=src/python:tests:tests-1.3 pylint -E tests/*.py tests-1.3/*.py src/python/oftest/*.py
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index df24c89..b23eefa 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -26,6 +26,7 @@
"""
+import sys
import os
import socket
import time
@@ -472,7 +473,7 @@
self.wakeup()
with self.connect_cv:
if self.initial_hello:
- self.message_send(hello())
+ self.message_send(ofp.message.hello())
self.connect_cv.notify() # Notify anyone waiting
else:
self.logger.error("Could not actively connect to switch %s",
diff --git a/src/python/oftest/help_formatter.py b/src/python/oftest/help_formatter.py
index 0e0a7c9..bd6feb1 100644
--- a/src/python/oftest/help_formatter.py
+++ b/src/python/oftest/help_formatter.py
@@ -7,4 +7,4 @@
indent = " "*self.current_indent
return indent + description
else:
- return none
+ return None
diff --git a/src/python/oftest/packet.py b/src/python/oftest/packet.py
new file mode 100644
index 0000000..1b43091
--- /dev/null
+++ b/src/python/oftest/packet.py
@@ -0,0 +1,28 @@
+# Distributed under the OpenFlow Software License (see LICENSE)
+# Copyright (c) 2010 The Board of Trustees of The Leland Stanford Junior University
+# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+"""
+Wrap scapy to satisfy pylint
+"""
+import sys
+
+try:
+ import scapy.layers.l2
+ import scapy.layers.inet
+ import scapy.layers.inet6
+except ImportError:
+ sys.exit("Need to install scapy for packet parsing")
+
+Ether = scapy.layers.l2.Ether
+LLC = scapy.layers.l2.LLC
+SNAP = scapy.layers.l2.SNAP
+Dot1Q = scapy.layers.l2.Dot1Q
+IP = scapy.layers.inet.IP
+IPOption = scapy.layers.inet.IPOption
+IPv6 = scapy.layers.inet6.IPv6
+ARP = scapy.layers.inet.ARP
+TCP = scapy.layers.inet.TCP
+UDP = scapy.layers.inet.UDP
+ICMP = scapy.layers.inet.ICMP
+ICMPv6Unknown = scapy.layers.inet6.ICMPv6Unknown
+ICMPv6EchoRequest = scapy.layers.inet6.ICMPv6EchoRequest
diff --git a/src/python/oftest/parse.py b/src/python/oftest/parse.py
index 7963c0c..0d57443 100644
--- a/src/python/oftest/parse.py
+++ b/src/python/oftest/parse.py
@@ -4,13 +4,7 @@
import sys
import socket
-try:
- import scapy.all as scapy
-except:
- try:
- import scapy as scapy
- except:
- sys.exit("Need to install scapy for packet parsing")
+import packet as scapy
def parse_mac(mac_str):
"""
diff --git a/src/python/oftest/test_parse.py b/src/python/oftest/test_parse.py
index 7143350..b6c8fce 100755
--- a/src/python/oftest/test_parse.py
+++ b/src/python/oftest/test_parse.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import unittest
import parse
-import scapy.all as scapy
+import packet as scapy
class TestPacketToFlowMatchV3(unittest.TestCase):
def test_tcp(self):
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index d92f180..8556214 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -4,14 +4,7 @@
import types
import time
import re
-
-try:
- import scapy.all as scapy
-except:
- try:
- import scapy as scapy
- except:
- sys.exit("Need to install scapy for packet parsing")
+import packet as scapy
import oftest
import oftest.controller
@@ -950,10 +943,8 @@
except:
return default
- s = "val = " + str(key)
try:
- exec s
- return val
+ return eval(str(key))
except:
return default
@@ -1218,10 +1209,11 @@
out = None
backup = sys.stdout
try:
- sys.stdout = StringIO()
+ tmp = StringIO()
+ sys.stdout = tmp
pkt.show2()
- out = sys.stdout.getvalue()
- sys.stdout.close()
+ out = tmp.getvalue()
+ tmp.close()
finally:
sys.stdout = backup
return out
@@ -1308,7 +1300,7 @@
test.assertTrue(reply is not None, "No response to stats request")
stats.extend(reply.entries)
while reply.flags & more_flag != 0:
- reply, pkt = self.controller.poll(exp_msg=ofp.OFPT_STATS_REPLY)
+ reply, pkt = test.controller.poll(exp_msg=ofp.OFPT_STATS_REPLY)
test.assertTrue(reply is not None, "No response to stats request")
stats.extend(reply.entries)
return stats
diff --git a/tests-1.3/match.py b/tests-1.3/match.py
index c807ee8..c45858f 100644
--- a/tests-1.3/match.py
+++ b/tests-1.3/match.py
@@ -13,7 +13,7 @@
from oftest import config
import oftest.base_tests as base_tests
import ofp
-import scapy.all as scapy
+import oftest.packet as scapy
from oftest.testutils import *
from oftest.parse import parse_ipv6
diff --git a/tests/pktact.py b/tests/pktact.py
index f803cfd..04edf95 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -17,7 +17,7 @@
import time
import unittest
import random
-import scapy.all as scapy
+import oftest.packet as scapy
from oftest import config
import oftest.controller as controller