From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29CFFA00BE; Mon, 13 Dec 2021 16:45:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE03440E09; Mon, 13 Dec 2021 16:45:52 +0100 (CET) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id BE65D406A2 for ; Mon, 13 Dec 2021 16:45:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id F1A3B15CCA8; Mon, 13 Dec 2021 16:45:50 +0100 (CET) X-Virus-Scanned: amavisd-new at siecit.sk Received: from lb.pantheon.sk ([127.0.0.1]) by localhost (lb.pantheon.sk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ic1aYrN8DMMy; Mon, 13 Dec 2021 16:45:49 +0100 (CET) Received: from service-node1.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id 5DF931376E9; Mon, 13 Dec 2021 16:45:49 +0100 (CET) From: =?UTF-8?q?Juraj=20Linke=C5=A1?= To: lijuan.tu@intel.com, ohilyard@iol.unh.edu, junx.dong@intel.com Cc: dts@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [PATCH v2] framework/packet: fix pylama errors Date: Mon, 13 Dec 2021 16:45:48 +0100 Message-Id: <1639410348-21262-1-git-send-email-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1638793208-2584-1-git-send-email-juraj.linkes@pantheon.tech> References: <1638793208-2584-1-git-send-email-juraj.linkes@pantheon.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org 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š --- Lijuan, please add additional people to review if needed. --- framework/packet.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/framework/packet.py b/framework/packet.py index adfa985a..787cfaee 100644 --- a/framework/packet.py +++ b/framework/packet.py @@ -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): """ -- 2.20.1