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 8CCAA4237F; Mon, 9 Jan 2023 15:33:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35A3E40687; Mon, 9 Jan 2023 15:33:05 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 51DD94067C for ; Mon, 9 Jan 2023 15:33:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673274783; x=1704810783; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=PiUwqrpABX99U4v6zUHILjmfApMjTnjnXgeESUVn8jQ=; b=G92KNvCRK4f5VyrBInfyUFPzpN2ljca9jkSdqR2Jj34ReQNKEoY6CYud w5HrCJTNrfSk172T/UdUccIkw+7cVNYxRd4bhP3DkP3LkqAoiK69kddNC I1PBbRuCIODx0+3oy4GFawqjzzNcVyTL7CODF4BPrjdCjgRtTtYG0HSCg /UuSw6w+Yr+4n7Uc8HHkOxx8HhMqn/53k955fuvy1gb+BQXym9Fsip38G ajL7BVMf8nWjNt3GBqLpJkU4p9jP7j4034WOG3Zh5wmDrSZNSRGsbRb2z SFemLv6CycaxJlkjzr7ZhNMGTgAgKftGyjmYHM8AQ2uMA6JEdTTNZBF7i g==; X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="324890592" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="324890592" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 06:33:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="745395766" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="745395766" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by FMSMGA003.fm.intel.com with ESMTP; 09 Jan 2023 06:33:02 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 9 Jan 2023 06:33:01 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 06:33:01 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Mon, 9 Jan 2023 06:33:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M1PQyuk1ZmUEeELzndt9cNASj9yTvXR9MyBGSrbzWb9zJCn+dD2d5zHAsW90loJYKAndg6lIGKGN3dtWCL/2KYR7YsSh0FqkYlGvHhtZ0RmZyUYTFsqraefeeBa+YnRIvk/Fnkps3NZvAa/mTA4jVTWqhMUVrG+Zc2e5dMigyHvonQu2NaIh2dop/uGqYcimJWCakWcS8+1GMpOCylCyIC8tij+bMlC0rh07LGT/VReNRPx4FTeQ1vcwNFLqQ02MGYeiMO+Q/hXYVPSqPS+3G6cKeeuc4z9Ixs75Tm1zic3tgJaAy6n3c+bj/vJ+/aQuTWjzZHb9m7+EYEwNwHiHrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/OIKl7NYC/uzuLfbr9bS/YwpChH+5Wjg0H5O4532BPo=; b=QrgUAe9OeKVwxczwkLBMXDeR5chGglwQj6Z+KVcqLbmrNKYqQx1xpXGBhbkYSciraWbj8LWlBQKaRvdcBkkdM6SFI8IqkTfa37UdUULJ5IkQA0rthQIfgbCr98YH4ipDjYd6eQy9ACgrChn5qKWmLW9zxvXycErfZU6vK0wuS9yHOdwrlRR4usRYGiTR6u9vHh1V2B1J1pv//OLQVqDrBfUAJqrlhvgoXb/tEONrTNwmcEB3gfwnelh5OET1Q0QrYg11CZ9Dy0obhwEVd6e83HEJgWB3lHZ77WBh6mFfYF/uYUxuIigovMu5jOFAn3ChyM49bNNp+hcuM/xyixbeCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by IA0PR11MB7934.namprd11.prod.outlook.com (2603:10b6:208:40d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Mon, 9 Jan 2023 14:32:58 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::4d9f:6867:2d53:9ee]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::4d9f:6867:2d53:9ee%8]) with mapi id 15.20.5986.018; Mon, 9 Jan 2023 14:32:58 +0000 Date: Mon, 9 Jan 2023 14:32:51 +0000 From: Bruce Richardson To: "lihuisong (C)" CC: , , , , , Subject: Re: [PATCH 1/2] usertools: use argparse module to get input parameter Message-ID: References: <20230109065547.8819-1-lihuisong@huawei.com> <20230109065547.8819-2-lihuisong@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: LO4P123CA0055.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::6) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|IA0PR11MB7934:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e74e98c-b3e0-45b3-2ca1-08daf24e6733 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xfkQvYV762oKjwi0z/rYAUYbEGaGHI1kyOHNyTSDITFVi/lxSTJTBSf3/XxwfA6hJVi6kjWBVYFYm1YYvzeqUcux8w8IUr9IrgeOwOIiEO6+6zPP50EdTuMxilQl/5gn8sf8kYHUeNTiThELRcMHNB92dwwYjAshnJB/NsQgZW9UdtP5urdhAyUMU51tVbYWDdJwBZXaspc/uR9Wbe6SM5eOw9+Em3banqhSDBPstPQ3t6Ndp+V+sv9IFW2mRr9vKWe1c0CAmFxvXfVHORiFmDctx/OiPpjW1Zcx0BEkCR/CaZ2sMGd56kbxh461SZc96tPoRS4Xvhnf8H5EPIMUzwTCzKd7mygyLUfykSzRFtzLvttP4ydKIOm+ORdWwCTapKwMS8Sb3Lz2adJR+pq0QxiWXHrD6lizWUpTtTLPpEBd45NDYbVeWuEn5zvm3n1c0iiXixK+noNtk1x67NmcJ7RL721YhqsYobJU1dkSOxT+cJaILWe8gDxUVI5qLLMDq4Tt6chLWi/xQFfarAEQ7ehNdDlTnTCvOeVpJAe9QuSklMIRs5RvKzTmOkduptAUZJqYtH5W70ctf3n0D6ku4gZ7CSsldqMEfnxxisuj48Nqbbo6pFwqNFrt8IPileJlZRFYA9Xl3ZbX3/gKTA81NA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(366004)(396003)(136003)(346002)(376002)(39860400002)(451199015)(82960400001)(8936002)(66946007)(66476007)(44832011)(4326008)(66556008)(8676002)(5660300002)(2906002)(83380400001)(38100700002)(86362001)(316002)(6486002)(6916009)(6666004)(478600001)(41300700001)(6512007)(26005)(6506007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?V3lUN29wbXEwdWxWcWJxZmZsLzRnMXNOZWxXNWdDaUQrU1MxaytoOXcrc1Vy?= =?utf-8?B?UVVIakxxNjF0K0lXLyszclhEcWZ2cGV4QXlJQWFYN1lUdHA0QWxSUTNQbXJH?= =?utf-8?B?NERkTWkyUm5jN00xQVBJOFBBcVN0Z2FGZi9jS3U1TVRkTkFnQ1ZoeVhmVTgr?= =?utf-8?B?S3ZEc1ZUdWJ4S2dYWlNZTml3MXRKU0VtdEVKOTZRc3ljdHNXMXR0NjRzYlh2?= =?utf-8?B?NlBEZS90dVgyM3AzM0xCbW95cFh2V2szd21zT1N4NkFLaFhmYnJxYXZIcllk?= =?utf-8?B?WW1tYVZlOEJMZDBiSkhQaTNYelNCQSsxaUMvYjd1L2RGajJhdHZPTHcvTEtF?= =?utf-8?B?RG10ckZlT0FDRGE3aU5ZR0JEOWptazJzTDdNOWIwbDFoSm82TTdxVEJKVHMz?= =?utf-8?B?QnhEN0hsZFpubE45V1YvdDZ0RkNnUEpRZ1Vma3ptRnVPcG83Y2s3NTJLR0F3?= =?utf-8?B?dlVLZWlrSkFEWmFSUG83VFZBYWtvL2tJNDNMVUU0SEY3ZmI0N0VYWXAyNG52?= =?utf-8?B?NVpDVjlReWhUZlB6cFFqNGdkNVdiOXNUUlV0UHFtNnVmbXVWb0J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JPV2JtL21YSHJpM1pCMjdV?= =?utf-8?B?bjdNQlo2VllEYzVPYVBPeW5jQVVpbFZGRDNSd2dUeXgxalJoZFNFZ3Eyc2M0?= =?utf-8?B?QVR2bTZkM0hZTGQ4UHZjdkYxb1JIUUYxUUlGcmtKWFY5YUxHUXpQcUVPbnk4?= =?utf-8?B?bThjckJOdW9PcUhDSUVuRVJhVTF5b0d1N1BqQUNRUERIU09XVEJObWk4SXFY?= =?utf-8?B?eHFIKzBBNG9sOVV1cjZ1L0ZUTEtKcTh4ank1M1BGVngzdmlNVG93ajNrV0t4?= =?utf-8?B?ZExpYUtJTkJhTU1OenQ0NURPRkxZYUpRaUlHUWloYXlqV2cxQThQZnJXRzR6?= =?utf-8?B?MFdsUjVWdjFCRFQvTVdBTU96VVBLdTJERGt4R0RNRW5LeFBXa3NiQ2lUYm9W?= =?utf-8?B?cjQvWXE2NUlYS282WS9SVzhiVWhnblN4ckQyeXY5ME9oWWdxYUx5UytkVzFo?= =?utf-8?B?NHdBQ0tuT3dXVnA2US9nZTlqUDBPM3hzeUhwMFZ1RitxcXkxNlRwNVRQWC9X?= =?utf-8?B?Z3lPV0JYaGZheXZHTk4zck1UZmtwRFUzTTZoN1FMSWdBMC9kR0x6RHpNVGlU?= =?utf-8?B?Y2FqQmF0bDJZYzBOSUdWeWpWWkIxOTdsQTJsWlpGVSt0ZWt5b3h6NHA1cHkr?= =?utf-8?B?Njk1WDhiOWZEbzRtQnRrL0FrMG0ydmJidDI4eFBmMW1EQU50N1RUalMyOWV4?= =?utf-8?B?S2c9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4e74e98c-b3e0-45b3-2ca1-08daf24e6733 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2023 14:32:58.1155 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PHqN+tdyGyNcxZesvwJc2RKmuzz+rAN7sXgt0paZRGO3FXULZNqFrdQNfbUikN5Lo50T5bAi/wMc3vBifOV4GW0evb2YiDh8Kd3INOwyaRc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7934 X-OriginatorOrg: intel.com 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 On Mon, Jan 09, 2023 at 08:26:37PM +0800, lihuisong (C) wrote: > > 在 2023/1/9 17:14, Bruce Richardson 写道: > > On Mon, Jan 09, 2023 at 02:55:46PM +0800, Huisong Li wrote: > > > The telemetry client script uses argparse module to get input parameter. > > > > > > Signed-off-by: Huisong Li > > > --- > > > usertools/dpdk-telemetry-client.py | 14 +++++++------- > > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > > This is an old script using the older telemetry V1 interface, so I'd > > generally recommend users switch to using scripts for the v2 interface. > > That said, no reason not to improve the script while we have it. > Yes. After all, the telemetry v1 interface and this script are still exist. > > > > > diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py > > > index df41d04fbe..fd69955b32 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('-s', '--sock_path', default=DEFAULT_FP, > > > + help='Provide socket file path connected by legacy client') > > > + args = parser.parse_args() > > > + > > While I like using argparse rather than handling args directly, this breaks > > compatibility. For anyone already using this script via automation, this > > would break things, as the path needs to be provided via a "-s" parameter, > > rather than just tacked on as argv[1]. > If there isn't the modification patch 2/2 mentioned, this script cannot be > directly used in most scenarios. From the first commit of this script, it's > just used as a demo client example. See > commit d1b94da4a4e0 ("usertools: add client script for telemetry") > From this point of view, can this compatibility issue be ignored? Agree with you that patch 2/2 is necessary to make script useful for most cases, and also agree that argparse is the better way to do argument handling. However, I also think that we can keep compatibility in this matter - you can add optional positional arguments in argparse to support backward compatibility. parser.add_argument('sock_path', nargs='?', default=...) should work, I believe, for this case. /Bruce