[v2] framework/packet: fix pylama errors
Checks
Commit Message
Pylama found the following errors:
framework/packet.py:119: [E] E0102 class already defined line 38 [pylint]
framework/packet.py:121: [E] E0602 Undefined variable 'Ether' [pylint]
framework/packet.py:122: [E] E0602 Undefined variable 'Dot1Q' [pylint]
framework/packet.py:123: [E] E0602 Undefined variable 'Dot1BR' [pylint]
framework/packet.py:124: [E] E0602 Undefined variable 'Ether' [pylint]
framework/packet.py:125: [E] E0602 Undefined variable 'ARP' [pylint]
framework/packet.py:126: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:127: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:128: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:129: [E] E0602 Undefined variable 'IPv6' [pylint]
framework/packet.py:130: [E] E0602 Undefined variable 'IPv6' [pylint]
framework/packet.py:131: [E] E0602 Undefined variable 'IPv6' [pylint]
framework/packet.py:132: [E] E0602 Undefined variable 'UDP' [pylint]
framework/packet.py:133: [E] E0602 Undefined variable 'TCP' [pylint]
framework/packet.py:134: [E] E0602 Undefined variable 'SCTP' [pylint]
framework/packet.py:135: [E] E0602 Undefined variable 'ICMP' [pylint]
framework/packet.py:136: [E] E0602 Undefined variable 'GRE' [pylint]
framework/packet.py:138: [E] E0602 Undefined variable 'VXLAN' [pylint]
framework/packet.py:139: [E] E0602 Undefined variable 'NSH' [pylint]
framework/packet.py:140: [E] E0602 Undefined variable 'MPLS' [pylint]
framework/packet.py:142: [E] E0602 Undefined variable 'Ether' [pylint]
framework/packet.py:143: [E] E0602 Undefined variable 'Dot1Q' [pylint]
framework/packet.py:144: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:145: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:146: [E] E0602 Undefined variable 'IPv6' [pylint]
framework/packet.py:147: [E] E0602 Undefined variable 'IPv6' [pylint]
framework/packet.py:149: [E] E0602 Undefined variable 'TCP' [pylint]
framework/packet.py:150: [E] E0602 Undefined variable 'UDP' [pylint]
framework/packet.py:151: [E] E0602 Undefined variable 'SCTP' [pylint]
framework/packet.py:152: [E] E0602 Undefined variable 'ICMP' [pylint]
framework/packet.py:154: [E] E0602 Undefined variable 'LLDPDU' [pylint]
framework/packet.py:155: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:156: [E] E0602 Undefined variable 'IPv6' [pylint]
framework/packet.py:157: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:158: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:159: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:160: [E] E0602 Undefined variable 'IP' [pylint]
framework/packet.py:161: [E] E0602 Undefined variable 'GRE' [pylint]
framework/packet.py:212: [E] E0602 Undefined variable 'Dot1Q' [pylint]
framework/packet.py:230: [E] E0602 Undefined variable 'Dot1BR' [pylint]
framework/packet.py:381: [E] E0102 class already defined line 38 [pylint]
framework/packet.py:895: [E] E0704 The raise statement is not inside an except clause [pylint]
framework/packet.py:898: [E] E0704 The raise statement is not inside an except clause [pylint]
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
framework/packet.py | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
Comments
> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: 2021年12月13日 23:46
> To: Tu, Lijuan <lijuan.tu@intel.com>; ohilyard@iol.unh.edu; Dong, JunX
> <junx.dong@intel.com>
> Cc: dts@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v2] framework/packet: fix pylama errors
>
> Pylama found the following errors:
> framework/packet.py:119: [E] E0102 class already defined line 38 [pylint]
> framework/packet.py:121: [E] E0602 Undefined variable 'Ether' [pylint]
> framework/packet.py:122: [E] E0602 Undefined variable 'Dot1Q' [pylint]
> framework/packet.py:123: [E] E0602 Undefined variable 'Dot1BR' [pylint]
> framework/packet.py:124: [E] E0602 Undefined variable 'Ether' [pylint]
> framework/packet.py:125: [E] E0602 Undefined variable 'ARP' [pylint]
> framework/packet.py:126: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:127: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:128: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:129: [E] E0602 Undefined variable 'IPv6' [pylint]
> framework/packet.py:130: [E] E0602 Undefined variable 'IPv6' [pylint]
> framework/packet.py:131: [E] E0602 Undefined variable 'IPv6' [pylint]
> framework/packet.py:132: [E] E0602 Undefined variable 'UDP' [pylint]
> framework/packet.py:133: [E] E0602 Undefined variable 'TCP' [pylint]
> framework/packet.py:134: [E] E0602 Undefined variable 'SCTP' [pylint]
> framework/packet.py:135: [E] E0602 Undefined variable 'ICMP' [pylint]
> framework/packet.py:136: [E] E0602 Undefined variable 'GRE' [pylint]
> framework/packet.py:138: [E] E0602 Undefined variable 'VXLAN' [pylint]
> framework/packet.py:139: [E] E0602 Undefined variable 'NSH' [pylint]
> framework/packet.py:140: [E] E0602 Undefined variable 'MPLS' [pylint]
> framework/packet.py:142: [E] E0602 Undefined variable 'Ether' [pylint]
> framework/packet.py:143: [E] E0602 Undefined variable 'Dot1Q' [pylint]
> framework/packet.py:144: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:145: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:146: [E] E0602 Undefined variable 'IPv6' [pylint]
> framework/packet.py:147: [E] E0602 Undefined variable 'IPv6' [pylint]
> framework/packet.py:149: [E] E0602 Undefined variable 'TCP' [pylint]
> framework/packet.py:150: [E] E0602 Undefined variable 'UDP' [pylint]
> framework/packet.py:151: [E] E0602 Undefined variable 'SCTP' [pylint]
> framework/packet.py:152: [E] E0602 Undefined variable 'ICMP' [pylint]
> framework/packet.py:154: [E] E0602 Undefined variable 'LLDPDU' [pylint]
> framework/packet.py:155: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:156: [E] E0602 Undefined variable 'IPv6' [pylint]
> framework/packet.py:157: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:158: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:159: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:160: [E] E0602 Undefined variable 'IP' [pylint]
> framework/packet.py:161: [E] E0602 Undefined variable 'GRE' [pylint]
> framework/packet.py:212: [E] E0602 Undefined variable 'Dot1Q' [pylint]
> framework/packet.py:230: [E] E0602 Undefined variable 'Dot1BR' [pylint]
> framework/packet.py:381: [E] E0102 class already defined line 38 [pylint]
> framework/packet.py:895: [E] E0704 The raise statement is not inside an except
> clause [pylint]
> framework/packet.py:898: [E] E0704 The raise statement is not inside an except
> clause [pylint]
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Applied
@@ -34,9 +34,30 @@ Base on scapy(python program for packet manipulation)
"""
import shutil
+import os
+import random
+import re
+import socket
+import struct
+import sys
+import time
from importlib import import_module
from socket import AF_INET6
-from scapy.all import *
+
+from scapy.contrib.lldp import LLDPDU, LLDPDUManagementAddress
+from scapy.contrib.mpls import MPLS
+from scapy.contrib.nsh import NSH
+from scapy.layers.inet import ICMP, IP, TCP, UDP
+from scapy.layers.inet6 import IPv6, IPv6ExtHdrFragment, IPv6ExtHdrRouting
+from scapy.layers.l2 import ARP, GRE, Dot1Q, Ether
+from scapy.layers.sctp import SCTP
+from scapy.layers.vxlan import VXLAN
+from scapy.packet import Raw
+from scapy.sendrecv import sendp
+from scapy.utils import hexstr, rdpcap, wrpcap
+
+from dep.scapy_modules.Dot1BR import Dot1BR
+
from .utils import convert_int2ip, convert_ip2int, get_module_path
# load extension layers
@@ -893,10 +914,10 @@ class Packet(object):
name, config = layer
if name not in self.pkt_layers:
print("[%s] is missing in packet!!!" % name)
- raise
+ raise Exception(f"{name} is missing in packet!!!")
if self.config_layer(name, config) is False:
print("[%s] failed to configure!!!" % name)
- raise
+ raise Exception(f"{name} failed to configure!!!")
def strip_layer_element(self, layer, element, p_index=0):
"""