From: Dong JunX <junx.dong@intel.com>
To: dts@dpdk.org
Cc: lijuan.tu@intel.com, weix.ling@intel.com, junx.dong@intel.com
Subject: [dts] [PATCH V1] framework/*: changed method of import Dot1BR
Date: Thu, 2 Dec 2021 13:42:01 +0800 [thread overview]
Message-ID: <1638423721-75428-1-git-send-email-junx.dong@intel.com> (raw)
Signed-off-by: Dong JunX <junx.dong@intel.com>
---
framework/packet.py | 8 ++++++--
framework/utils.py | 6 ------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/framework/packet.py b/framework/packet.py
index adfa985..dac3ea5 100644
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -32,12 +32,14 @@
Generic packet create, transmit and analyze module
Base on scapy(python program for packet manipulation)
"""
+import os
+import subprocess
import shutil
from importlib import import_module
from socket import AF_INET6
from scapy.all import *
-from .utils import convert_int2ip, convert_ip2int, get_module_path
+from .utils import convert_int2ip, convert_ip2int
# load extension layers
exec_file = os.path.realpath(__file__)
@@ -49,7 +51,9 @@ if not os.path.exists(TMP_PATH):
os.system('mkdir -p %s' % TMP_PATH)
# copy dep/Dot1BR to scapy
-_contrib_module_path = get_module_path('scapy.contrib')
+_scapy_module_path = subprocess.check_output("python3 -m pip show scapy |grep Location |awk -F': ' '{print $2}'",
+ encoding='utf-8', stderr=subprocess.STDOUT, shell=True)
+_contrib_module_path = os.path.join(_scapy_module_path.strip(), 'scapy', 'contrib')
shutil.copy(DTS_PATH + '/dep/scapy_modules/Dot1BR.py', _contrib_module_path)
scapy_modules_required = {'scapy.contrib.gtp': ['GTP_U_Header', 'GTPPDUSessionContainer'],
diff --git a/framework/utils.py b/framework/utils.py
index 269bfbb..5eefd0a 100644
--- a/framework/utils.py
+++ b/framework/utils.py
@@ -309,9 +309,3 @@ def check_dts_python_version():
"and will not work in future releases.")), file=sys.stderr)
print(RED("Please use Python >= 3.6.9 instead"), file=sys.stderr)
-def get_module_path(module_name):
- from importlib import import_module
- _module = import_module(module_name)
- _module_file_path = _module.__file__
- del _module
- return os.path.dirname(_module_file_path)
--
1.8.3.1
reply other threads:[~2021-12-02 5:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly 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=1638423721-75428-1-git-send-email-junx.dong@intel.com \
--to=junx.dong@intel.com \
--cc=dts@dpdk.org \
--cc=lijuan.tu@intel.com \
--cc=weix.ling@intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).