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 E1568423A1; Tue, 10 Jan 2023 08:32:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1158E40E25; Tue, 10 Jan 2023 08:32:02 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 8F47040693 for ; Tue, 10 Jan 2023 08:31:59 +0100 (CET) Received: from kwepemm600004.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NrjC348Yxz16LyY; Tue, 10 Jan 2023 15:30:23 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 10 Jan 2023 15:31:56 +0800 From: Huisong Li To: CC: , , , , , , Subject: [PATCH v2 1/2] usertools: use argparse module to get input parameter Date: Tue, 10 Jan 2023 15:31:45 +0800 Message-ID: <20230110073146.8221-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230110073146.8221-1-lihuisong@huawei.com> References: <20230109065547.8819-1-lihuisong@huawei.com> <20230110073146.8221-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The telemetry client script uses argparse module to get input parameter. argparse uses an optional positional arguments for local socket path to keep backward compatibility. Signed-off-by: Huisong Li --- usertools/dpdk-telemetry-client.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py index df41d04fbe..144a8fb5e0 100755 --- a/usertools/dpdk-telemetry-client.py +++ b/usertools/dpdk-telemetry-client.py @@ -6,6 +6,7 @@ import os import sys import time +import argparse BUFFER_SIZE = 200000 @@ -115,13 +116,12 @@ def interactiveMenu(self, sleep_time): # Creates Interactive menu within the scr if __name__ == "__main__": sleep_time = 1 - file_path = "" - if len(sys.argv) == 2: - file_path = sys.argv[1] - else: - print("Warning - No filepath passed, using default (" + DEFAULT_FP + ").") - file_path = DEFAULT_FP + parser = argparse.ArgumentParser() + parser.add_argument('sock_path', nargs='?', default=DEFAULT_FP, + help='Provide socket file path connected by legacy client') + args = parser.parse_args() + client = Client() - client.getFilepath(file_path) + client.getFilepath(args.sock_path) client.register() client.interactiveMenu(sleep_time) -- 2.22.0