commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 06/08: examples: run_synthetic.py use Argum


From: git
Subject: [Commit-gnuradio] [gnuradio] 06/08: examples: run_synthetic.py use ArgumentParser
Date: Wed, 11 May 2016 17:41:08 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch next
in repository gnuradio.

commit 63bfba6597152376c85003cc9a73c494f35d6d7a
Author: Jiří Pinkava <address@hidden>
Date:   Tue Nov 24 11:55:13 2015 +0100

    examples: run_synthetic.py use ArgumentParser
---
 .../examples/mp-sched/run_synthetic.py             | 39 ++++++++++------------
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/gnuradio-runtime/examples/mp-sched/run_synthetic.py 
b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
index 4896bca..802fb9f 100755
--- a/gnuradio-runtime/examples/mp-sched/run_synthetic.py
+++ b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
@@ -27,7 +27,7 @@ import re
 import sys
 import os
 import tempfile
-from optparse import OptionParser
+from argparse import ArgumentParser
 
 
 def write_shell_script(f, data_filename, description, ncores, gflops, 
max_pipes_and_stages):
@@ -70,31 +70,26 @@ total runtime of about 43 minutes, assuming that your 
values for -n and -f are r
 For x86 machines, assume 3 FLOPS per processor Hz. E.g., 3 GHz machine -> 9 
GFLOPS.
 plot_flops.py will make pretty graphs from the output data generated by %prog.
 """
-    usage = "usage: %prog [options] output.dat"
-    parser = OptionParser(usage=usage, description=description)
-    parser.add_option("-d", "--description", metavar="DESC",
-                      help="machine description, e.g., \"Dual quad-core Xeon 3 
GHz\"", default=None)
-    parser.add_option("-n", "--ncores", type="int", default=1,
-                      help="number of processor cores [default=%default]")
-    parser.add_option("-g", "--gflops", metavar="GFLOPS", type="float", 
default=3.0,
-                      help="estimated GFLOPS per core [default=%default]")
-    parser.add_option("-m", "--max-pipes-and-stages", metavar="MAX", 
type="int", default=16,
-                      help="maximum number of pipes and stages to use 
[default=%default]")
-    (options, args) = parser.parse_args()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-
-    output_filename = args[0]
+    parser = ArgumentParser(description=description)
+    parser.add_argument("-d", "--description", metavar="DESC",
+            help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"")
+    parser.add_argument("-n", "--ncores", type=int, default=1,
+            help="number of processor cores [default=%(default)s]")
+    parser.add_argument("-g", "--gflops", metavar="GFLOPS", type=float, 
default=3.0,
+            help="estimated GFLOPS per core [default=%(default)s]")
+    parser.add_argument("-m", "--max-pipes-and-stages", metavar="MAX", 
type=int, default=16,
+            help="maximum number of pipes and stages to use 
[default=%(default)s]")
+    parser.add_argument("output_file_name", metavar="FILE", help="output file 
name")
+    args = parser.parse_args()
 
     shell = os.popen("/bin/sh", "w")
 
     write_shell_script(shell,
-                       output_filename,
-                       options.description,
-                       options.ncores,
-                       options.gflops,
-                       options.max_pipes_and_stages)
+                       args.output_file_name,
+                       args.description,
+                       args.ncores,
+                       args.gflops,
+                       args.max_pipes_and_stages)
 
 if __name__ == '__main__':
     main()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]