From patchwork Wed Nov 4 06:48:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83642 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 05DA8A0521; Wed, 4 Nov 2020 07:49:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D897ABE9F; Wed, 4 Nov 2020 07:48:57 +0100 (CET) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id F0536BE7B for ; Wed, 4 Nov 2020 07:48:53 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id w65so16512097pfd.3 for ; Tue, 03 Nov 2020 22:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+I97ORinggSpAxlykndpMsIbCkjHdqnrrc4mcPDuiiI=; b=VfnSw5HYelIczuoDv7Lk0mD6OOdCf1iKsGBXL8YmON0s15Wz55fnAhFFTbCNH/0r6K c2nWi/+YbyOdo71nby7ChdbaszSN755o/uELSoEU/gu1o2SX4AKkwVXm4tL+SVfKaafo A2vfbg2McoVoYBKBg0loe6mcCnsMDrtGHyBzQlVRRV3UPdC48+wiHuTLxzowkZbHvy+f n6AfvdEobm0KfK7CJsYAALFg8PI8waWX9qz3PN750yXv3huNHJDhIvjzl1egzHA5SB1U 34mS1A7lSbnzrx8vSN8QjjaW2yYYbo2vNeyCSsAV2tMN6L88jGy0zdeOBMHCjOkV23rs svqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+I97ORinggSpAxlykndpMsIbCkjHdqnrrc4mcPDuiiI=; b=o46RFX3q9G5uLw0gqV7G5EnIYEnq/+HSHLSffWPvDdTbT6LlOzFHedAciV280oV4TA /7Fi6HfesCmHiLvounkRcJx2XJNrgC12rKa2KgppP77gDZY4LJGo6SaXyIV40/xmN/l5 fKJiTCnVyEPndUm/OXIPxUXGvyGX0l3nM/tAnXsutwlWzR6sV/UkHgyRK12uReskZJ70 0R7MGc5BNCbcgSIOPiAzs6CTkKtUwGjom5MM4/OkZwageCp27/fx7U40ezjSXWN9rlHh M+zUh94Chz/FP7CGLj42L8sOmtiRiVTdrZ/vVdVVnhAKV13gyczxLnaQSBHUTfDjfoZR mZag== X-Gm-Message-State: AOAM530Rtwc1Cbh9APragUe9Gze0yynulABCzPGr76hozN6qsHELNdc2 Tc5stn0PJNHvXBtLoirnu6StwIV4HEl1tGVz X-Google-Smtp-Source: ABdhPJx7/xj50N0rmfB9YL3kR+txISlLdPjzPZGBp+IJt+fdww0XDurT5pVRLpEgv6IraE2izA7QHQ== X-Received: by 2002:a63:e449:: with SMTP id i9mr12310318pgk.438.1604472532106; Tue, 03 Nov 2020 22:48:52 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm1144137pgi.14.2020.11.03.22.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:51 -0800 (PST) From: Stephen Hemminger To: nhorman@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 3 Nov 2020 22:48:36 -0800 Message-Id: <20201104064842.25832-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104064842.25832-1-stephen@networkplumber.org> References: <20200906013133.26360-3-stephen@networkplumber.org> <20201104064842.25832-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 1/7] dpdk-pmdinfo: replace string.split with split X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In python3 the standard way to split strings is to use the split() on the string object itself. The old way is broken and would cause a traceback. Signed-off-by: Stephen Hemminger --- usertools/dpdk-pmdinfo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index 16619827911a..7576a3313f36 100755 --- a/usertools/dpdk-pmdinfo.py +++ b/usertools/dpdk-pmdinfo.py @@ -11,7 +11,6 @@ import io import os import platform -import string import sys from elftools.common.exceptions import ELFError from elftools.common.py3compat import byte2int @@ -229,7 +228,7 @@ def loadLocal(self): def search_file(filename, search_path): """ Given a search path, find file with requested name """ - for path in string.split(search_path, ":"): + for path in search_path.split(':'): candidate = os.path.join(path, filename) if os.path.exists(candidate): return os.path.abspath(candidate) From patchwork Wed Nov 4 06:48:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83643 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B81FAA04E7; Wed, 4 Nov 2020 07:49:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97B54C321; Wed, 4 Nov 2020 07:48:59 +0100 (CET) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by dpdk.org (Postfix) with ESMTP id 24557BE97 for ; Wed, 4 Nov 2020 07:48:54 +0100 (CET) Received: by mail-pg1-f169.google.com with SMTP id 62so8458674pgg.12 for ; Tue, 03 Nov 2020 22:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PFsX6joj8+LucDxtxZNyqLzFyGOrNSF26W4kRtBfMww=; b=Nj8P5quIEitEgPZJWX3sR7OVNG5Ed4s6wyb40Rx//MgbT9cv6X4uEslppqA7W0iU01 EGY39n0vq1QQAeEEkPYE8G1qLjV7/ACyh/Wl7X0bWPA4tSEqL8ONs5GTtphpmTVzySsT dp9K+Xs3TmhL0GZMUdg8rzxchw3yt90RzNzBB+qckwnhmltAt8avw3WceWWrwP9BDhYl T4N7zwHNLd6S4JMJGD2MR6xTjQ0aMs3HYkjjBzw7CYv0FPNwF6CUFF4/AjW9X9A8bwQa qfJAg09GbgTflErWPW38g/igPj1uUlDbrGEU3tzNi+PRwzquNhBHWbM8pmy0e4/J28W4 hvvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PFsX6joj8+LucDxtxZNyqLzFyGOrNSF26W4kRtBfMww=; b=ITe2goLZxHo3qMO2Ij+DjjLPME/Js5YuC2BRhLDW2DXLgFzBqAadTP/G74eDiTEvP+ M+XWbT7hQM55rkwJ6l7oMHU1l3syt10KYtge6UA7SPYL8M+yWKibvHFCkZcVb5vOfMHQ KKpTeIgKS45Fot4JaZlXhMFTGE+ysnZik6aZAWaYnnmTjM9rybTZoVUqYwNWzHXPl/tl uwrgdQokv4nfzZNxAfevjVFdsT9utEVjak6qlF+sOnWOHDcFBEVHsx82wWjNXLfrfKJ6 ofyJ94sTRtvWwbJxbIXIIZ1O7Sju754ygGCn6Fl7nU7YqUWPszjl7eS+Gb3QoEnyc/P/ rg4A== X-Gm-Message-State: AOAM532f2KGh8joCsG3q4xuzcex4d2qpZclQ11A0UwLIPDYYn6bKD0PZ TYImxYBcG3E8CM+XQDPQlFINQQ== X-Google-Smtp-Source: ABdhPJxSlCwTRUQmx67pa1gZHKCpfkm3nLemXTy2O6sJubaAib3q17L4JNf0EIk2EGZEgdaUsbb5sQ== X-Received: by 2002:a63:6c09:: with SMTP id h9mr19629405pgc.214.1604472533444; Tue, 03 Nov 2020 22:48:53 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm1144137pgi.14.2020.11.03.22.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:52 -0800 (PST) From: Stephen Hemminger To: nhorman@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 3 Nov 2020 22:48:37 -0800 Message-Id: <20201104064842.25832-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104064842.25832-1-stephen@networkplumber.org> References: <20200906013133.26360-3-stephen@networkplumber.org> <20201104064842.25832-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 2/7] dpdk-pmdinfo: replace io.open with open X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The builtin open() is the recommended approach in python3. io.open was for compatiablity with older versions. Signed-off-by: Stephen Hemminger --- usertools/dpdk-pmdinfo.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index 7576a3313f36..4fefdc83e583 100755 --- a/usertools/dpdk-pmdinfo.py +++ b/usertools/dpdk-pmdinfo.py @@ -8,7 +8,6 @@ # # ------------------------------------------------------------------------- import json -import io import os import platform import sys @@ -211,7 +210,7 @@ def readLocal(self, filename): """ Reads the local file """ - with io.open(filename, 'r', encoding='utf-8') as f: + with open(filename, 'r', encoding='utf-8') as f: self.contents = f.readlines() self.date = self.findDate(self.contents) @@ -380,7 +379,7 @@ def search_for_autoload_path(self): return (None, None) if raw_output is False: print("Scanning for autoload path in %s" % library) - scanfile = io.open(library, 'rb') + scanfile = open(library, 'rb') scanelf = ReadElf(scanfile, sys.stdout) except AttributeError: # Not a dynamic binary @@ -456,7 +455,7 @@ def process_dt_needed_entries(self): if library is not None: if raw_output is False: print("Scanning %s for pmd information" % library) - with io.open(library, 'rb') as file: + with open(library, 'rb') as file: try: libelf = ReadElf(file, sys.stdout) except ELFError: @@ -499,7 +498,7 @@ def scan_autoload_path(autoload_path): scan_autoload_path(dpath) if os.path.isfile(dpath): try: - file = io.open(dpath, 'rb') + file = open(dpath, 'rb') readelf = ReadElf(file, sys.stdout) except ELFError: # this is likely not an elf file, skip it @@ -526,7 +525,7 @@ def scan_for_autoload_pmds(dpdk_path): print("Must specify a file name") return - file = io.open(dpdk_path, 'rb') + file = open(dpdk_path, 'rb') try: readelf = ReadElf(file, sys.stdout) except ElfError: @@ -621,7 +620,7 @@ def main(stream=None): print("File not found") sys.exit(1) - with io.open(myelffile, 'rb') as file: + with open(myelffile, 'rb') as file: try: readelf = ReadElf(file, sys.stdout) readelf.process_dt_needed_entries() From patchwork Wed Nov 4 06:48:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83644 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 28BC2A04E7; Wed, 4 Nov 2020 07:49:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2FED5C7E8; Wed, 4 Nov 2020 07:49:01 +0100 (CET) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by dpdk.org (Postfix) with ESMTP id 65093BE99 for ; Wed, 4 Nov 2020 07:48:56 +0100 (CET) Received: by mail-pg1-f173.google.com with SMTP id h6so15752370pgk.4 for ; Tue, 03 Nov 2020 22:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qZB4PD1GvuhXF/cjRt7NYpwfbfiRoAUqkDbpgtbiiac=; b=hWDpgtF6riG4e74GK9ik4nqHs11Xf1hKKmI4QE1FCO5N2Je0ZBclqOWv+3h7Yo0bVD FSk7jQW+YQg4VId2ucv6bkncD+w4H+lTD2ooRWmMM0z7WFWveL3TeTlEtgYw8DWF1SmQ 1aR82Y432p+ShMcc4OJH/FwieVxpxunhFn4C817eLzPhUv+vBhmQdlpkJIj22BEni5Jj 4wEGzJ1j+qff41UY1wjxYe4wsgz/TMK2je3HbwuG7sHcv8eLvsDH78W39XHddajOg1E+ jb1gk9mI1oBQsqhFlQG6JoKMcK9grPSTX8sngwJUNoOVf65SBncSv3IERZ2OvbRDOtLM L9Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qZB4PD1GvuhXF/cjRt7NYpwfbfiRoAUqkDbpgtbiiac=; b=FUV691GZ/h31hD3yy7MnN1xivWW/Gky/G64dGfnE1Q+MgBOYxhU2/EQ3NU4gByf0Fc ZCFCqXgyn/CfGMuIJ5W7GDO7dqdRpJOdA9nQDsCAU7UZM1iSWePT9AidHVtUqsFvF3I7 8iQltFHvpsOJIlLFKanGtztiMo0UtXq9HCcWH5abT4Y95cZin5vtV1Hbu2Zju9aZBj3z 42LEUuA/mLGm748SBxnw2XPsgpHojKF1MQBGFercyCf61WTWIBKK4CqW4MwzqepaYMe+ GgMICQM9LXW2hk1uYXQL/iPFCZSxEvbOerwSewR0JwpVeVEfeo/lz/sA7VzQYAlGpBbN wHqA== X-Gm-Message-State: AOAM530/EEn0EMgYVfDBuFzzsUF04qBczaTOyYF2Nzc0dt+vSiPKqrDY L7VImC5f54UWn2ijvhJicNRWTGk2bUckjinP X-Google-Smtp-Source: ABdhPJx+NI3nLxnd7iUGpmF3YAz9vaf2RyWLXI/5artXZHM2nyhkFhrL5V5MV6d7leZ8+wT5/AD8Yw== X-Received: by 2002:a63:7009:: with SMTP id l9mr19065205pgc.199.1604472534720; Tue, 03 Nov 2020 22:48:54 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm1144137pgi.14.2020.11.03.22.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:53 -0800 (PST) From: Stephen Hemminger To: nhorman@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 3 Nov 2020 22:48:38 -0800 Message-Id: <20201104064842.25832-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104064842.25832-1-stephen@networkplumber.org> References: <20200906013133.26360-3-stephen@networkplumber.org> <20201104064842.25832-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 3/7] dpdk-pmdinfo: remove unnecessary paren and else X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Python lint complains: usertools/dpdk-pmdinfo.py:303:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:328:0: C0325: Unnecessary parens after 'not' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:341:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:394:0: C0325: Unnecessary parens after 'not' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:407:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:515:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:530:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:533:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:534:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:539:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:594:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:602:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:605:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:611:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens) usertools/dpdk-pmdinfo.py:110:12: R1705: Unnecessary "else" after "return" (no-else-return) usertools/dpdk-pmdinfo.py:254:12: R1705: Unnecessary "else" after "return" (no-else-return) Signed-off-by: Stephen Hemminger --- usertools/dpdk-pmdinfo.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index 4fefdc83e583..c9ecf45a72f3 100755 --- a/usertools/dpdk-pmdinfo.py +++ b/usertools/dpdk-pmdinfo.py @@ -109,8 +109,7 @@ def find_subid(self, subven, subdev): except: if (subven == "ffff" and subdev == "ffff"): return SubDevice("ffff", "ffff", "(All Subdevices)") - else: - return SubDevice(subven, subdev, "(Unknown Subdevice)") + return SubDevice(subven, subdev, "(Unknown Subdevice)") class SubDevice: @@ -261,8 +260,7 @@ def _section_from_spec(self, spec): num = int(spec) if num < self.elffile.num_sections(): return self.elffile.get_section(num) - else: - return None + return None except ValueError: # Not a number. Must be a name then section = self.elffile.get_section_by_name(force_unicode(spec)) @@ -308,7 +306,7 @@ def parse_pmd_info_string(self, mystring): except KeyError: continue - if (len(pmdinfo["pci_ids"]) != 0): + if len(pmdinfo["pci_ids"]) != 0: print("PMD HW SUPPORT:") if pcidb is not None: self.pretty_print_pmdinfo(pmdinfo) @@ -333,7 +331,7 @@ def display_pmd_info_strings(self, section_spec): while dataptr < len(data): while (dataptr < len(data) and - not (32 <= byte2int(data[dataptr]) <= 127)): + not 32 <= byte2int(data[dataptr]) <= 127): dataptr += 1 if dataptr >= len(data): @@ -346,7 +344,7 @@ def display_pmd_info_strings(self, section_spec): # pyelftools may return byte-strings, force decode them mystring = force_unicode(data[dataptr:endptr]) rc = mystring.find("PMD_INFO_STRING") - if (rc != -1): + if rc != -1: self.parse_pmd_info_string(mystring) dataptr = endptr @@ -399,7 +397,7 @@ def search_for_autoload_path(self): while dataptr < len(data): while (dataptr < len(data) and - not (32 <= byte2int(data[dataptr]) <= 127)): + not 32 <= byte2int(data[dataptr]) <= 127): dataptr += 1 if dataptr >= len(data): @@ -412,7 +410,7 @@ def search_for_autoload_path(self): # pyelftools may return byte-strings, force decode them mystring = force_unicode(data[dataptr:endptr]) rc = mystring.find("DPDK_PLUGIN_PATH") - if (rc != -1): + if rc != -1: rc = mystring.find("=") return (mystring[rc + 1:], library) @@ -520,7 +518,7 @@ def scan_for_autoload_pmds(dpdk_path): """ global raw_output - if (os.path.isfile(dpdk_path) is False): + if os.path.isfile(dpdk_path) is False: if raw_output is False: print("Must specify a file name") return @@ -535,16 +533,16 @@ def scan_for_autoload_pmds(dpdk_path): (autoload_path, scannedfile) = readelf.search_for_autoload_path() if not autoload_path: - if (raw_output is False): + if raw_output is False: print("No autoload path configured in %s" % dpdk_path) return - if (raw_output is False): - if (scannedfile is None): + if raw_output is False: + if scannedfile is None: scannedfile = dpdk_path print("Found autoload path %s in %s" % (autoload_path, scannedfile)) file.close() - if (raw_output is False): + if raw_output is False: print("Discovered Autoload HW Support:") scan_autoload_path(autoload_path) return @@ -599,7 +597,7 @@ def main(stream=None): options.pcifile = None pcidb = None - if (len(args) == 0): + if len(args) == 0: optparser.print_usage() exit(1) @@ -607,16 +605,16 @@ def main(stream=None): exit(scan_for_autoload_pmds(args[0])) ldlibpath = os.environ.get('LD_LIBRARY_PATH') - if (ldlibpath is None): + if ldlibpath is None: ldlibpath = "" - if (os.path.exists(args[0]) is True): + if os.path.exists(args[0]) is True: myelffile = args[0] else: myelffile = search_file( args[0], ldlibpath + ":/usr/lib64:/lib64:/usr/lib:/lib") - if (myelffile is None): + if myelffile is None: print("File not found") sys.exit(1) From patchwork Wed Nov 4 06:48:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83645 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA71AA04E7; Wed, 4 Nov 2020 07:50:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B9CB0C7F4; Wed, 4 Nov 2020 07:49:02 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by dpdk.org (Postfix) with ESMTP id C10DCBE99 for ; Wed, 4 Nov 2020 07:48:57 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id r10so15729150pgb.10 for ; Tue, 03 Nov 2020 22:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3CDta7I/VzmOX9PRytegahW9P/kftjJF4vnSIXOrsVo=; b=BymJSOc2zhZ/d7v+AdQi+PaDVDq4+AFmlTAmLSv3IB2+pdqwTjq2a2Ovvg6gSICaqf iqwT4nbxZQ2QW4zW85118mWGjLr7yp3u46HbETxzZIjmvD7stOZJ7E3P3Dk8500J7XMO xaGcvWQ2JzbFmEEw/d/rArK5JgSUbMi0hvr3m4eaaeOiPhPnvfJU/qOq8Ddd3dP5qeYn YcQD1FoxeURUYmmCCZKi1w7ovXf143IAsCSwtDoyBqrNYNXLsU+daqpCP3e7qhsdFc/X Ro95Btr0BtJUtn6jHmhbu6R7G2jaDdA6e78uRZmvKu9kaFr3NL++3H4tq1Eg2iiY98iE G6PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3CDta7I/VzmOX9PRytegahW9P/kftjJF4vnSIXOrsVo=; b=oqe6mJfnUHlICtgSNVFSelRSnZrI5pGMGjWbPo3PwQ+ss/DxtzUJgaOXTnLNzzBmpu 8W20AR9V0YJGvWaKzEBlThqUIdamo+f0qAtBCHS9cTyIQfx2gYu9S1D1jQJNjR4zZUJI MIZXNweIKVKN37mhwmB/LHVKSXPscXYQ93FX0MecssNWPzanruHx+FmXENAVoa75CPtO JwTaEETyQ394NK+8Px78+h13wKMY4EZwfN8vYeKOFRHvI063pm9vacERFzspAyoV/ryR mdnywzzQAuyIrixxTvNkIsSnulFn9ZNdcEY5naBN0IqppMaJNPWa7gQxGnmTU48cNPwG noGQ== X-Gm-Message-State: AOAM533/IpZZ+irn2uyQSCCSIJ8mpiS+WHZf+XUrB2jx8JKOCIy8mul8 lQ/7sdUOslfwScHU4ydUIIdhDSyFfxFK4S60 X-Google-Smtp-Source: ABdhPJwGB4LlUS2eFQ2y/ElZ5CnF9CwgGY1BeGxvKuP30vQ8JZV9o7K65KWQzJRVcVa5siviQI3Njw== X-Received: by 2002:a65:52cb:: with SMTP id z11mr19702144pgp.368.1604472536044; Tue, 03 Nov 2020 22:48:56 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm1144137pgi.14.2020.11.03.22.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:55 -0800 (PST) From: Stephen Hemminger To: nhorman@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 3 Nov 2020 22:48:39 -0800 Message-Id: <20201104064842.25832-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104064842.25832-1-stephen@networkplumber.org> References: <20200906013133.26360-3-stephen@networkplumber.org> <20201104064842.25832-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 4/7] dpdk-pmdinfo: replace is False and is True X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Code reads better if unnecessary comparison with False and True is not used. Signed-off-by: Stephen Hemminger --- usertools/dpdk-pmdinfo.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index c9ecf45a72f3..8c4698063fb4 100755 --- a/usertools/dpdk-pmdinfo.py +++ b/usertools/dpdk-pmdinfo.py @@ -375,7 +375,7 @@ def search_for_autoload_path(self): ":/usr/lib64:/lib64:/usr/lib:/lib") if library is None: return (None, None) - if raw_output is False: + if not raw_output: print("Scanning for autoload path in %s" % library) scanfile = open(library, 'rb') scanelf = ReadElf(scanfile, sys.stdout) @@ -451,7 +451,7 @@ def process_dt_needed_entries(self): runpath + ":" + ldlibpath + ":/usr/lib64:/lib64:/usr/lib:/lib") if library is not None: - if raw_output is False: + if not raw_output: print("Scanning %s for pmd information" % library) with open(library, 'rb') as file: try: @@ -481,7 +481,7 @@ def force_bytes(s): def scan_autoload_path(autoload_path): global raw_output - if os.path.exists(autoload_path) is False: + if not os.path.exists(autoload_path): return try: @@ -505,7 +505,7 @@ def scan_autoload_path(autoload_path): # No permission to read the file, skip it continue - if raw_output is False: + if not raw_output: print("Hw Support for library %s" % d) readelf.display_pmd_info_strings(".rodata") file.close() @@ -518,8 +518,8 @@ def scan_for_autoload_pmds(dpdk_path): """ global raw_output - if os.path.isfile(dpdk_path) is False: - if raw_output is False: + if not os.path.isfile(dpdk_path): + if not raw_output: print("Must specify a file name") return @@ -527,22 +527,22 @@ def scan_for_autoload_pmds(dpdk_path): try: readelf = ReadElf(file, sys.stdout) except ElfError: - if raw_output is False: + if not raw_output: print("Unable to parse %s" % file) return (autoload_path, scannedfile) = readelf.search_for_autoload_path() if not autoload_path: - if raw_output is False: + if not raw_output: print("No autoload path configured in %s" % dpdk_path) return - if raw_output is False: + if not raw_output: if scannedfile is None: scannedfile = dpdk_path print("Found autoload path %s in %s" % (autoload_path, scannedfile)) file.close() - if raw_output is False: + if not raw_output: print("Discovered Autoload HW Support:") scan_autoload_path(autoload_path) return @@ -601,14 +601,14 @@ def main(stream=None): optparser.print_usage() exit(1) - if options.pdir is True: + if options.pdir: exit(scan_for_autoload_pmds(args[0])) ldlibpath = os.environ.get('LD_LIBRARY_PATH') if ldlibpath is None: ldlibpath = "" - if os.path.exists(args[0]) is True: + if os.path.exists(args[0]): myelffile = args[0] else: myelffile = search_file( From patchwork Wed Nov 4 06:48:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83646 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5307AA04E7; Wed, 4 Nov 2020 07:50:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5F1ECC7FE; Wed, 4 Nov 2020 07:49:04 +0100 (CET) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 009D4C31B for ; Wed, 4 Nov 2020 07:48:58 +0100 (CET) Received: by mail-pg1-f196.google.com with SMTP id f38so15763890pgm.2 for ; Tue, 03 Nov 2020 22:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u0Zl7aTlxH6PPQr3Yc4gZXOG02VSgChCrFdALOmSecg=; b=Jq1yggCDYgF247/veM+ALDow9A3Oeu8G3Qg821mBY64qLHnVXUrNlFv5DUWiUTilgd WyeLDcvc6I+BGvoQZVKF8EUIM/bdX5yxzJ04UyzU5q8Dqzh0GflxHcGtgAqiSufnBrZv lHSjOpzqIYbeyiQocwj5jUNGe/Q8ZSMHkWt0tl20tQp7CEutfoEvcctviRYEReIggmEH KeErQSo+xsy/NHsXrl2FHFCtxlZ4vdbbPIq5Ajyfez3ENFfI7icvW5BTW6fJvjBkfmJz CGcZoUjatSehNrd9cUg2+Ji9WFo9+Xh+mleNZxnl7Q9Tog9btHTYea4cWyQrj8LFCzmg rJiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u0Zl7aTlxH6PPQr3Yc4gZXOG02VSgChCrFdALOmSecg=; b=lnDcYdPTs9s/jPVvhsJfo64ttezrYPxVj/mI/HNAQGrWwWAvKzhaiJdeVx/TjtrLwE KEL7QzapUvON4CtOyPJV4qmHLmbYd91dd6vGynPBhSLlReZWEx/ncAZ+pz4iqpqBqUHL hIBSkcxcsezgGwgC5/PH8UwKVXboF9XpFktoHw6AocVF4g/mpU5RAb91MQ5D1pTv6sZu H7TN+X+ua99SXFH6g2aMj0WdoWP9difv6xfMs3yeM0Tq1v71kG3RDceqifJeInFxbUHq IWrAp20DwfYETpDt6Y89rimSpzSB9ds90f9FdLDzQAwm4BP0fTIApAK1/PqzKCqXfLxy BIDQ== X-Gm-Message-State: AOAM530NcMw+xmp+4L11333AU0KZClBMGJ7KqMbdza6HAMNBFE604rZl KOCCdiV/I39eE2XMYWnPwJa8qA== X-Google-Smtp-Source: ABdhPJyC+mO1QwSvAnegl7yqDlaAU0k0/0iG6jZvYJAtxs5tjHWtKPGqTFS5rNTWUI0wA8AxzjdSjw== X-Received: by 2002:a63:7408:: with SMTP id p8mr19741777pgc.273.1604472537277; Tue, 03 Nov 2020 22:48:57 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm1144137pgi.14.2020.11.03.22.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:56 -0800 (PST) From: Stephen Hemminger To: nhorman@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 3 Nov 2020 22:48:40 -0800 Message-Id: <20201104064842.25832-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104064842.25832-1-stephen@networkplumber.org> References: <20200906013133.26360-3-stephen@networkplumber.org> <20201104064842.25832-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 5/7] dpdk-pmdinfo: fix indentation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This fixes indentation warnings from pylint. Signed-off-by: Stephen Hemminger --- usertools/dpdk-pmdinfo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index 8c4698063fb4..aec2abe9a683 100755 --- a/usertools/dpdk-pmdinfo.py +++ b/usertools/dpdk-pmdinfo.py @@ -331,7 +331,7 @@ def display_pmd_info_strings(self, section_spec): while dataptr < len(data): while (dataptr < len(data) and - not 32 <= byte2int(data[dataptr]) <= 127): + not 32 <= byte2int(data[dataptr]) <= 127): dataptr += 1 if dataptr >= len(data): @@ -397,7 +397,7 @@ def search_for_autoload_path(self): while dataptr < len(data): while (dataptr < len(data) and - not 32 <= byte2int(data[dataptr]) <= 127): + not 32 <= byte2int(data[dataptr]) <= 127): dataptr += 1 if dataptr >= len(data): From patchwork Wed Nov 4 06:48:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83647 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 34DDAA04E7; Wed, 4 Nov 2020 07:50:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 60E8CC81A; Wed, 4 Nov 2020 07:49:06 +0100 (CET) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by dpdk.org (Postfix) with ESMTP id 5BA26C7EE for ; Wed, 4 Nov 2020 07:49:00 +0100 (CET) Received: by mail-pf1-f172.google.com with SMTP id 13so16498968pfy.4 for ; Tue, 03 Nov 2020 22:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FPDr7Kb2Khy9Y/74GoOtT4R4l/v1zaneLBBc0M3usTs=; b=VKD7u5Tuknrw+soectNOFqPObu/kKfatrcY6L8GC8eZt4B80pcM8PLIt5lnRgA07ga tSpOqrUgJuXiGZVTvjGrlkSy3YF76l4BSuJTc8ly+Ajxz2BMwgGZ893PlmK49W8KG06W S2cIuSuBMY0xRAJCSspIKUmE/EI6mDw6HX3fONowK3HqQUXEo/STASPLVdIpj3H3+T5/ wOJJl7P379tkVxcMbxeO5Nek3TEnDFwF7GJw5D77PvrNd8YcfK8bsaRFKcXZF3ZrEcBK RqnVIb7ctUdzrAxRftftME/tp4vE/7E3fLPmxwIHqqPz4rNt+5JLhjt7iP6spvY27bfn fBzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FPDr7Kb2Khy9Y/74GoOtT4R4l/v1zaneLBBc0M3usTs=; b=JuCSfKpx4m2CH/ERLBonrl+fMwwVtp0yX6HRaXTAAcwzIUebOxibk5aT2Sewf9Ao2O mw3954wz3ymLOLmgIH8IKYoZb96doPM9Wczsj+uuf9c+FqVHND18yUHqK0eUiPU2nysW Xs+q7nKTH1A31+Ycbj6kkSQkthgRr8kw9S+tpcipoMvnJ+1X49OGZXW7vQm9PfWp9LIa tNgCHoSSw9m6z4zpfdK+TrJy15oafOtSEdaQfY1LlY3U9pIm2bmWmKkzRNE+TduXjKRj bNzABr4JTgOmuqtDRogLQ/+aCPzz0E+/ZpC31e4+9gbzZ4tslXDY7G/+Hdreefy97Ox2 AbJQ== X-Gm-Message-State: AOAM5322dOOZgouxS7vK5KKRnPoEFIkSErlbYDFoad1Y8vs3vHielGpG ITFuh2vGk100ycSVnsh+lM2RvXYrXJxSkO1N X-Google-Smtp-Source: ABdhPJx2KYK1nJBEStVQxAsIv2e+z2RyLJOTaiYRw6/F7ywtEuvd7dp1Y2ten6xmrIGgWlbeu6Migg== X-Received: by 2002:a17:90a:bc4c:: with SMTP id t12mr2878330pjv.163.1604472538663; Tue, 03 Nov 2020 22:48:58 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm1144137pgi.14.2020.11.03.22.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:57 -0800 (PST) From: Stephen Hemminger To: nhorman@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 3 Nov 2020 22:48:41 -0800 Message-Id: <20201104064842.25832-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104064842.25832-1-stephen@networkplumber.org> References: <20200906013133.26360-3-stephen@networkplumber.org> <20201104064842.25832-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 6/7] dpdk-pmdinfo: replace deprecated optparse with argparse X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The optparse module is deprecated and replaced with new argparse. The code now enforces the rule that only one of the output formats can be specified: raw or json. Signed-off-by: Stephen Hemminger --- usertools/dpdk-pmdinfo.py | 70 ++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index aec2abe9a683..1c2c3d05fea6 100755 --- a/usertools/dpdk-pmdinfo.py +++ b/usertools/dpdk-pmdinfo.py @@ -11,10 +11,11 @@ import os import platform import sys +import argparse from elftools.common.exceptions import ELFError from elftools.common.py3compat import byte2int from elftools.elf.elffile import ELFFile -from optparse import OptionParser + # For running from development directory. It should take precedence over the # installed pyelftools. @@ -563,56 +564,49 @@ def main(stream=None): if not os.path.exists(pcifile_default): pcifile_default = "/usr/share/misc/pci_vendors" - optparser = OptionParser( - usage='usage: %prog [-hrtp] [-d ', - description="Dump pmd hardware support info", - add_help_option=True) - optparser.add_option('-r', '--raw', - action='store_true', dest='raw_output', - help='Dump raw json strings') - optparser.add_option("-d", "--pcidb", dest="pcifile", - help="specify a pci database " - "to get vendor names from", - default=pcifile_default, metavar="FILE") - optparser.add_option("-t", "--table", dest="tblout", - help="output information on hw support as a " - "hex table", - action='store_true') - optparser.add_option("-p", "--plugindir", dest="pdir", - help="scan dpdk for autoload plugins", - action='store_true') - - options, args = optparser.parse_args() - - if options.raw_output: + parser = argparse.ArgumentParser( + usage='usage: %(prog)s [-hrtp] [-d ] elf_file', + description="Dump pmd hardware support info") + group = parser.add_mutually_exclusive_group() + group.add_argument('-r', '--raw', + action='store_true', dest='raw_output', + help='dump raw json strings') + group.add_argument("-t", "--table", dest="tblout", + help="output information on hw support as a hex table", + action='store_true') + parser.add_argument("-d", "--pcidb", dest="pcifile", + help="specify a pci database to get vendor names from", + default=pcifile_default, metavar="FILE") + parser.add_argument("-p", "--plugindir", dest="pdir", + help="scan dpdk for autoload plugins", + action='store_true') + parser.add_argument("elf_file", help="driver shared object file") + args = parser.parse_args() + + if args.raw_output: raw_output = True - if options.pcifile: - pcidb = PCIIds(options.pcifile) + if args.tblout: + args.pcifile = None + + if args.pcifile: + pcidb = PCIIds(args.pcifile) if pcidb is None: print("Pci DB file not found") exit(1) - if options.tblout: - options.pcifile = None - pcidb = None - - if len(args) == 0: - optparser.print_usage() - exit(1) - - if options.pdir: + if args.pdir: exit(scan_for_autoload_pmds(args[0])) ldlibpath = os.environ.get('LD_LIBRARY_PATH') if ldlibpath is None: ldlibpath = "" - if os.path.exists(args[0]): - myelffile = args[0] + if os.path.exists(args.elf_file): + myelffile = args.elf_file else: - myelffile = search_file( - args[0], ldlibpath + ":/usr/lib64:/lib64:/usr/lib:/lib") + myelffile = search_file(args.elf_file, + ldlibpath + ":/usr/lib64:/lib64:/usr/lib:/lib") if myelffile is None: print("File not found") From patchwork Wed Nov 4 06:48:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83648 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 863C9A04E7; Wed, 4 Nov 2020 07:51:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E0AD2C822; Wed, 4 Nov 2020 07:49:07 +0100 (CET) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by dpdk.org (Postfix) with ESMTP id BBA90C7EE for ; Wed, 4 Nov 2020 07:49:00 +0100 (CET) Received: by mail-pg1-f180.google.com with SMTP id r186so15773879pgr.0 for ; Tue, 03 Nov 2020 22:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IEzcrqI/FlE43beY/YsF9Yfkwk3Z0C6QBFws3VaLCcU=; b=AvZLBz3OykujgWvID1m8DblE2/bHLpr+QCs1hB0VxfpXphjJYVLyAWM6DR1lRjZULu uEcRgWvf+h4KXaNGLBnX4iPz8mYFh/H2Wyn6pb3BV8sljbql0c+pOjtKAq2YATPJdfkz Iz1mk089N4G9zb+1CT6wJWLkwzvyEUoQNYJpxerkf2PDmOo0a0GD9Rlywc7Pud6asit8 8Y1U888Sd05ZFTB9vOCUVjhCf+TfPUk7Ym1SdVzNiOc2qjes9+Lzcan72cTfeHg9yW7N YJz/iX8xMdTF5oo8xPtr6Q7oPqHZVSQpQV7MOdOdj6Micny2H9gpe0cw4jjgqGOD+3uj ok1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IEzcrqI/FlE43beY/YsF9Yfkwk3Z0C6QBFws3VaLCcU=; b=O3BSpETFpq4jwX0o6YAIaH9Ba5sj/kl94EZUt/9vQW6OsLN2B1T9JBltnX+WpbUZG1 QgDJhVCBgffKKbaEV7lc4XfayB+Dt9S2GAdqSt8WGI9wJ6roRUsu/OctGAIWPqmgEg3U EYuu0YpwniGL2Ch8tADVZMEUj5J7Fo+gCzB6flfykb1VWnlDP6iNfFnldOtR0htmxplH Y3MRCFJ4HcJNw/CvEjkXzGMttM1QUToiCqQF17Y0T0j+jJ2829i1mJW89gwO4Xwn3hH/ IrgM7EXkDabJghitz+6RP1/k4JRz6i/xBPa/XlfZX0gLftQh2M3+wbll7dO22//kOIPd XRWQ== X-Gm-Message-State: AOAM531erqebywLux9wINbG/lKGc5S7esGtsz6lysadxtYz59vxMMSY/ f54MG5noFak+EN6duue+dMtziA== X-Google-Smtp-Source: ABdhPJzmesxP1id0qf5JBDkJkQhR+T1JzGcNvdYXEOzd6RmIAeWqZv7ON7ZnT9EpngL8rFt2WGzl7g== X-Received: by 2002:a17:90a:d590:: with SMTP id v16mr3027899pju.88.1604472540094; Tue, 03 Nov 2020 22:49:00 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm1144137pgi.14.2020.11.03.22.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:59 -0800 (PST) From: Stephen Hemminger To: nhorman@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 3 Nov 2020 22:48:42 -0800 Message-Id: <20201104064842.25832-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104064842.25832-1-stephen@networkplumber.org> References: <20200906013133.26360-3-stephen@networkplumber.org> <20201104064842.25832-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 7/7] dpdk-pmdinfo: do not use len(x) to test for empty X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This fixes the following python lint warnings. usertools/dpdk-pmdinfo.py:188:11: C1801: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition) usertools/dpdk-pmdinfo.py:196:21: C1801: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition) usertools/dpdk-pmdinfo.py:302:11: C1801: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition) Signed-off-by: Stephen Hemminger --- usertools/dpdk-pmdinfo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index 1c2c3d05fea6..2bead75da238 100755 --- a/usertools/dpdk-pmdinfo.py +++ b/usertools/dpdk-pmdinfo.py @@ -185,7 +185,7 @@ def findDate(self, content): return None def parse(self): - if len(self.contents) < 1: + if not self.contents: print("data/%s-pci.ids not found" % self.date) else: vendorID = "" @@ -193,7 +193,7 @@ def parse(self): for l in self.contents: if l[0] == "#": continue - elif len(l.strip()) == 0: + elif not l.strip(): continue else: if l.find("\t\t") == 0: @@ -307,7 +307,7 @@ def parse_pmd_info_string(self, mystring): except KeyError: continue - if len(pmdinfo["pci_ids"]) != 0: + if pmdinfo["pci_ids"]: print("PMD HW SUPPORT:") if pcidb is not None: self.pretty_print_pmdinfo(pmdinfo)