wrap scapy with explicit imports
pylint can't handle scapy's magical imports.
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/src/python/oftest/packet.py b/src/python/oftest/packet.py
new file mode 100644
index 0000000..67dffb2
--- /dev/null
+++ b/src/python/oftest/packet.py
@@ -0,0 +1,27 @@
+# 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
+"""
+
+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 e87b7a0..26c25d3 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
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