DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Huisong Li <lihuisong@huawei.com>
Cc: <dev@dpdk.org>, <mb@smartsharesystems.com>,
	<andrew.rybchenko@oktetlabs.ru>, <huangdaode@huawei.com>,
	<liudongdong3@huawei.com>, <fengchengwen@huawei.com>
Subject: Re: [PATCH 1/2] usertools: use argparse module to get input parameter
Date: Mon, 9 Jan 2023 09:14:46 +0000	[thread overview]
Message-ID: <Y7vbBq4l0NuchcLL@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <20230109065547.8819-2-lihuisong@huawei.com>

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 <lihuisong@huawei.com>
> ---
>  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.

> 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].

>      client = Client()
> -    client.getFilepath(file_path)
> +    client.getFilepath(args.sock_path)
>      client.register()
>      client.interactiveMenu(sleep_time)
> -- 
> 2.22.0
> 

  reply	other threads:[~2023-01-09  9:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09  6:55 [PATCH 0/2] usertools: use argparse module to get input and add an argment Huisong Li
2023-01-09  6:55 ` [PATCH 1/2] usertools: use argparse module to get input parameter Huisong Li
2023-01-09  9:14   ` Bruce Richardson [this message]
2023-01-09 12:26     ` lihuisong (C)
2023-01-09 14:32       ` Bruce Richardson
2023-01-10  6:24         ` lihuisong (C)
2023-01-09  6:55 ` [PATCH 2/2] usertools: add an argment for file prefix Huisong Li
2023-01-09  9:16   ` Bruce Richardson
2023-01-09 17:07 ` [PATCH] usertools: fix python warnings Stephen Hemminger
2023-02-06  7:47   ` Thomas Monjalon
2023-01-10  7:31 ` [PATCH v2 0/2] usertools: usertools: use argparse to get input and add an argument Huisong Li
2023-01-10  7:31   ` [PATCH v2 1/2] usertools: use argparse module to get input parameter Huisong Li
2023-01-10  9:12     ` Bruce Richardson
2023-01-10  7:31   ` [PATCH v2 2/2] usertools: add an argument for file prefix Huisong Li
2023-02-06  8:30   ` [PATCH v2 0/2] usertools: usertools: use argparse to get input and add an argument Thomas Monjalon

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=Y7vbBq4l0NuchcLL@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=huangdaode@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=liudongdong3@huawei.com \
    --cc=mb@smartsharesystems.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).