[dpdk-dev] bug: Use correct arguments in run.py

Message ID 942AD08E4186F644A54168E4F84117C9317C60@SAUSMAILMBX1.ad.tri.sbc.com (mailing list archive)
State Not Applicable, archived
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

McCullough, Harrison June 28, 2017, 2:54 p.m. UTC
  When using run.py it would occasionally ignore the given command line
arguments because the wrong variable was used.  Fixed this, along with
minor changes to reflect more idiomatic Python usage.

Signed-off-by: Harrison McCullough <harrison_mccullough@labs.att.com>
---
 tools/run.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
  

Comments

Wiles, Keith June 28, 2017, 3:53 p.m. UTC | #1
> On Jun 28, 2017, at 7:54 AM, McCullough, Harrison <harrison_mccullough@labs.att.com> wrote:
> 
> When using run.py it would occasionally ignore the given command line
> arguments because the wrong variable was used.  Fixed this, along with
> minor changes to reflect more idiomatic Python usage.

Thanks I will integrate these changes into the next version of Pktgen.

> 
> Signed-off-by: Harrison McCullough <harrison_mccullough@labs.att.com>
> ---
> tools/run.py | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/run.py b/tools/run.py
> index ec6f45d..f5ec22c 100755
> --- a/tools/run.py
> +++ b/tools/run.py
> @@ -96,7 +96,7 @@ def find_file(arg, t):
>     for f in file_list('.', t):
>         if os.path.basename(f) == fn:
>             return f
> -    return "" 
> +    return None
> 
> def parse_args():
>     ''' Parse the command arguments '''
> @@ -118,7 +118,7 @@ def parse_args():
>         print("Run '%s --usage' for further information" % sys.argv[0])
>         sys.exit(1)
> 
> -    for opt, arg in opts:
> +    for opt, _ in opts:
>         if opt == "--help" or opt == "-h" or opt == "--usage" or opt == "-u":
>             usage()
>             sys.exit(0)
> @@ -128,13 +128,12 @@ def parse_args():
>         if opt == "--setup" or opt == "-s":
>             run_flag = False
> 
> -    arg = sys.argv[1:]
> -    if arg == "":
> +    if not args or len(args) > 1:
>         usage()
>         sys.exit(1)
> 
> -    fn = find_file(arg[0], cfg_ext)
> -    if fn != "":
> +    fn = find_file(args[0], cfg_ext)
> +    if fn:
>         cfg_file = fn
> 
> def load_cfg():
> -- 
> 1.9.1
> 

Regards,
Keith
  

Patch

diff --git a/tools/run.py b/tools/run.py
index ec6f45d..f5ec22c 100755
--- a/tools/run.py
+++ b/tools/run.py
@@ -96,7 +96,7 @@  def find_file(arg, t):
     for f in file_list('.', t):
         if os.path.basename(f) == fn:
             return f
-    return "" 
+    return None
 
 def parse_args():
     ''' Parse the command arguments '''
@@ -118,7 +118,7 @@  def parse_args():
         print("Run '%s --usage' for further information" % sys.argv[0])
         sys.exit(1)
 
-    for opt, arg in opts:
+    for opt, _ in opts:
         if opt == "--help" or opt == "-h" or opt == "--usage" or opt == "-u":
             usage()
             sys.exit(0)
@@ -128,13 +128,12 @@  def parse_args():
         if opt == "--setup" or opt == "-s":
             run_flag = False
     
-    arg = sys.argv[1:]
-    if arg == "":
+    if not args or len(args) > 1:
         usage()
         sys.exit(1)
 
-    fn = find_file(arg[0], cfg_ext)
-    if fn != "":
+    fn = find_file(args[0], cfg_ext)
+    if fn:
         cfg_file = fn
 
 def load_cfg():