test suite reviews and discussions
 help / color / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 7/7] framework/pktgen: fix pep8 issue
Date: Tue,  6 Aug 2019 15:51:28 +0800
Message-ID: <1565077888-4431-8-git-send-email-yufengx.mo@intel.com> (raw)
In-Reply-To: <1565077888-4431-1-git-send-email-yufengx.mo@intel.com>


*. remove un-used libs import.
*. remove set dts libs directory in system path.
*. fix pep8 issue.

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 framework/pktgen.py | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/framework/pktgen.py b/framework/pktgen.py
index f87baa3..8132fe5 100644
--- a/framework/pktgen.py
+++ b/framework/pktgen.py
@@ -29,7 +29,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import os, sys
+import os
 from copy import deepcopy
 
 from scapy.all import conf
@@ -38,13 +38,6 @@ from scapy.packet import Packet as scapyPacket
 from scapy.fields import ConditionalField
 from scapy.utils import rdpcap
 
-# import dts libs
-cwd = os.getcwd()
-sys.path.append(cwd + '/nics')
-sys.path.append(cwd + '/framework')
-sys.path.append(cwd + '/tests')
-sys.path.append(cwd + '/dep')
-
 # dts libs
 from utils import (convert_int2ip, convert_ip2int,
                    convert_mac2long, convert_mac2str)
@@ -59,13 +52,13 @@ from pktgen_trex import TrexPacketGenerator
 class PacketGeneratorHelper(object):
     ''' default packet generator stream option for all streams '''
     default_opt = {
-        'stream_config':{
-            'txmode' : {},
+        'stream_config': {
+            'txmode': {},
             'transmit_mode': TRANSMIT_CONT,
             # for temporary usage because current pktgen design don't support
             # port level configuration, here using stream configuration to pass
             # rate percent
-            'rate': 100,}}
+            'rate': 100, }}
 
     def __init__(self):
         self.packetLayers = dict()
@@ -78,7 +71,7 @@ class PacketGeneratorHelper(object):
         self.packetLayers[pkt_object.name] = dict()
         for curfield in pkt_object.fields_desc:
             if isinstance(curfield, ConditionalField) and \
-                not curfield._evalcond(pkt_object):
+               not curfield._evalcond(pkt_object):
                 continue
             field_value = pkt_object.getfieldval(curfield.name)
             if isinstance(field_value, scapyPacket) or (curfield.islist and \
@@ -87,7 +80,7 @@ class PacketGeneratorHelper(object):
             repr_value = curfield.i2repr(pkt_object, field_value)
             if isinstance(repr_value, str):
                 repr_value = repr_value.replace(os.linesep,
-                                    os.linesep + " "*(len(curfield.name) +4))
+                                                os.linesep + " " * (len(curfield.name) + 4))
             self.packetLayers[pkt_object.name][curfield.name] = repr_value
 
         if isinstance(pkt_object.payload, NoPayload):
@@ -107,7 +100,7 @@ class PacketGeneratorHelper(object):
         if len(pcap_pkts) == 0:
             warning = "{0} is empty".format(pcapFile)
             raise Exception(warning)
-        elif number>= len(pcap_pkts):
+        elif number >= len(pcap_pkts):
             warning = "{0} is missing No.{1} packet".format(pcapFile, number)
             raise Exception(warning)
         else:
@@ -136,7 +129,8 @@ class PacketGeneratorHelper(object):
                 range = config.get('range') or 64
                 step = config.get('step') or 1
                 start_mac = pcap_fields.get(name)
-                end_mac = convert_mac2str(convert_mac2long(start_mac) + range-1)
+                end_mac = convert_mac2str(
+                    convert_mac2long(start_mac) + range - 1)
                 fields_config[layer_name][name] = {}
                 fields_config[layer_name][name]['start'] = start_mac
                 fields_config[layer_name][name]['end'] = end_mac
@@ -203,6 +197,7 @@ class PacketGeneratorHelper(object):
             stream_ids.append(stream_id)
         return stream_ids
 
+
 def getPacketGenerator(tester, pktgen_type=PKTGEN_IXIA):
     """
     Get packet generator object
@@ -212,11 +207,11 @@ def getPacketGenerator(tester, pktgen_type=PKTGEN_IXIA):
     pktgen_cls = {
         PKTGEN_DPDK: DpdkPacketGenerator,
         PKTGEN_IXIA: IxiaPacketGenerator,
-        PKTGEN_TREX: TrexPacketGenerator,}
+        PKTGEN_TREX: TrexPacketGenerator, }
 
     if pktgen_type in pktgen_cls.keys():
         CLS = pktgen_cls.get(pktgen_type)
         return CLS(tester)
     else:
         msg = "not support <{0}> packet generator".format(pktgen_type)
-        raise Exception(msg)
\ No newline at end of file
+        raise Exception(msg)
-- 
1.9.3


      parent reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06  7:51 [dts] [PATCH V1 0/7] dts/pktgen: fix internal bugs yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 1/7] framework/logger: add pktgen logger and remove duplicate yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 2/7] framework/dut: fix logger quit issue yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 3/7] framework/tester: " yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 4/7] framework/pktgen_base: fix internal bug yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 5/7] framework/pktgen_ixia: " yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 6/7] framework/pktgen_trex: " yufengmx
2019-08-06  7:51 ` yufengmx [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1565077888-4431-8-git-send-email-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

test suite reviews and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dts/0 dts/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dts dts/ http://inbox.dpdk.org/dts \
		dts@dpdk.org
	public-inbox-index dts


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


AGPL code for this site: git clone https://public-inbox.org/ public-inbox