From 1a5a9cb32a93da47fa6aa0da8407337feaf901f8 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Tue, 13 Nov 2018 16:06:26 +0000 Subject: [PATCH] usertools: check for lspci dependency On some distributions (such as CentOS 7) lspci may not be installed by default, causing exceptions which are difficult to interpret. Fix devbind script to check if lspci is installed at script startup. Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov Reviewed-by: Rami Rosen --- usertools/dpdk-devbind.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 7d564634ca..40dc28a7df 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -655,6 +655,13 @@ def do_arg_actions(): def main(): '''program main function''' + # check if lspci is installed, suppress any output + with open(os.devnull, 'w') as devnull: + ret = subprocess.call(['which', 'lspci'], + stdout=devnull, stderr=devnull) + if ret != 0: + print("'lspci' not found - please install 'pciutils'") + sys.exit(1) parse_args() check_modules() clear_data() -- 2.20.1