commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 06/09: filter: replace OptionParser by Argu


From: git
Subject: [Commit-gnuradio] [gnuradio] 06/09: filter: replace OptionParser by ArgumentParser for gr-utils and gr-qtgui
Date: Sat, 6 Aug 2016 22:28:35 +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 4d2809c9a46ec5676f2a08457609f559d910785f
Author: Jiří Pinkava <address@hidden>
Date:   Sun Jun 26 13:04:39 2016 +0200

    filter: replace OptionParser by ArgumentParser for gr-utils and gr-qtgui
---
 gr-filter/examples/benchmark_filters.py | 32 +++++++-----------
 gr-qtgui/apps/gr_constellation_plot     | 31 ++++++++----------
 gr-qtgui/apps/gr_psd_plot_b             | 15 ++++-----
 gr-qtgui/apps/gr_psd_plot_c             | 15 ++++-----
 gr-qtgui/apps/gr_psd_plot_f             | 15 ++++-----
 gr-qtgui/apps/gr_psd_plot_i             | 15 ++++-----
 gr-qtgui/apps/gr_psd_plot_s             | 15 ++++-----
 gr-qtgui/apps/gr_spectrogram_plot       | 57 ++++++++++++++++-----------------
 gr-qtgui/apps/gr_spectrogram_plot_b     | 15 ++++-----
 gr-qtgui/apps/gr_spectrogram_plot_c     | 15 ++++-----
 gr-qtgui/apps/gr_spectrogram_plot_f     | 15 ++++-----
 gr-qtgui/apps/gr_spectrogram_plot_i     | 15 ++++-----
 gr-qtgui/apps/gr_spectrogram_plot_s     | 15 ++++-----
 gr-qtgui/apps/gr_time_plot_b            | 11 +++----
 gr-qtgui/apps/gr_time_plot_c            | 11 +++----
 gr-qtgui/apps/gr_time_plot_f            | 11 +++----
 gr-qtgui/apps/gr_time_plot_i            | 11 +++----
 gr-qtgui/apps/gr_time_plot_s            | 11 +++----
 gr-qtgui/apps/gr_time_raster_b          | 13 ++++----
 gr-qtgui/apps/gr_time_raster_f          | 13 ++++----
 gr-qtgui/apps/plot_psd_base.py          | 40 +++++++++++------------
 gr-qtgui/apps/plot_spectrogram_base.py  | 43 ++++++++++++-------------
 gr-qtgui/apps/plot_time_base.py         | 33 +++++++++----------
 gr-qtgui/apps/plot_time_raster_base.py  | 41 ++++++++++++------------
 gr-utils/python/utils/gr_plot_fft       |  8 ++---
 gr-utils/python/utils/gr_plot_fft_c     | 11 +++----
 gr-utils/python/utils/gr_plot_fft_f     | 12 +++----
 gr-utils/python/utils/gr_plot_float     | 27 +++++++---------
 gr-utils/python/utils/gr_plot_int       | 27 +++++++---------
 gr-utils/python/utils/gr_plot_iq        | 31 ++++++++----------
 gr-utils/python/utils/gr_plot_psd       |  8 ++---
 gr-utils/python/utils/gr_plot_psd_c     | 13 +++-----
 gr-utils/python/utils/gr_plot_psd_f     | 13 +++-----
 gr-utils/python/utils/gr_plot_short     | 27 +++++++---------
 gr-utils/python/utils/plot_fft_base.py  | 33 +++++++++----------
 gr-utils/python/utils/plot_psd_base.py  | 48 +++++++++++++--------------
 36 files changed, 346 insertions(+), 420 deletions(-)

diff --git a/gr-filter/examples/benchmark_filters.py 
b/gr-filter/examples/benchmark_filters.py
index 18380a7..4da6b9f 100755
--- a/gr-filter/examples/benchmark_filters.py
+++ b/gr-filter/examples/benchmark_filters.py
@@ -22,10 +22,10 @@
 
 import time
 import random
-from optparse import OptionParser
+from argparse import ArgumentParser
 from gnuradio import gr
 from gnuradio import blocks, filter
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_float, intx
 
 def make_random_complex_tuple(L):
     result = []
@@ -52,25 +52,17 @@ def benchmark(name, creator, dec, ntaps, total_test_size, 
block_size):
         name, ntaps, total_test_size, delta, ntaps*total_test_size/delta)
 
 def main():
-    parser = OptionParser(option_class=eng_option)
-    parser.add_option("-n", "--ntaps", type="int", default=256)
-    parser.add_option("-t", "--total-input-size", type="eng_float", 
default=40e6)
-    parser.add_option("-b", "--block-size", type="intx", default=50000)
-    parser.add_option("-d", "--decimation", type="int", default=1)
-    (options, args) = parser.parse_args()
-    if len(args) != 0:
-        parser.print_help()
-        sys.exit(1)
+    parser = ArgumentParser()
+    parser.add_argument("-n", "--ntaps", type=int, default=256)
+    parser.add_argument("-t", "--total-input-size", type=eng_float, 
default=40e6)
+    parser.add_argument("-b", "--block-size", type=intx, default=50000)
+    parser.add_argument("-d", "--decimation", type=int, default=1)
+    args = parser.parse_args()
 
-    ntaps = options.ntaps
-    total_input_size = options.total_input_size
-    block_size = options.block_size
-    dec = options.decimation
-
-    benchmark("filter.fir_filter_ccc", filter.fir_filter_ccc,
-              dec, ntaps, total_input_size, block_size)
-    benchmark("filter.fft_filter_ccc", filter.fft_filter_ccc,
-              dec, ntaps, total_input_size, block_size)
+    benchmark("filter.fir_filter_ccc", filter.fir_filter_ccc, args.decimation,
+              args.ntaps, args.total_input_size, args.block_size)
+    benchmark("filter.fft_filter_ccc", filter.fft_filter_ccc, args.decimation,
+              args.ntaps, args.total_input_size, args.block_size)
 
 if __name__ == '__main__':
     main()
diff --git a/gr-qtgui/apps/gr_constellation_plot 
b/gr-qtgui/apps/gr_constellation_plot
index 528bb97..ff5db1a 100755
--- a/gr-qtgui/apps/gr_constellation_plot
+++ b/gr-qtgui/apps/gr_constellation_plot
@@ -22,8 +22,8 @@
 
 from gnuradio import gr
 from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
 import os, sys
 
 try:
@@ -143,32 +143,27 @@ class my_top_block(gr.top_block):
 
 def main():
     description = "Plots the constellations of a list of files."
-    parser = OptionParser(option_class=eng_option, description=description,
+    parser = ArgumentParser(description=description,
                           conflict_handler="resolve")
-    parser.add_option("-N", "--nsamples", type="int", default=1000000,
-                      help="Set the number of samples to display 
[default=%default]")
-    parser.add_option("-S", "--start", type="int", default=0,
-                      help="Starting sample number [default=%default]")
-    (options, args) = parser.parse_args()
+    parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+                      help="Set the number of samples to display 
[default=%(default)r]")
+    parser.add_argument("-S", "--start", type=int, default=0,
+                      help="Starting sample number [default=%(default)r]")
+    parser.add_argument("files", nargs="+", metavar='FILE')
+    args = parser.parse_args()
 
-    if(len(args) < 1):
-        parser.print_help()
-        sys.exit(0)
-
-    filelist = list(args)
-
-    nsamples = options.nsamples
+    filelist = args.files
+    nsamples = args.nsamples
 
     # Find the smallest number of samples in all files and use that as
     # a maximum value possible.
     filesizes = []
     for f in filelist:
         if(os.path.exists(f)):
-            filesizes.append(os.path.getsize(f) / gr.sizeof_gr_complex)
+            filesizes.append(os.path.getsize(f) // gr.sizeof_gr_complex)
     max_nsamples = min(filesizes)
 
-    tb = my_top_block(filelist,
-                      options.start, nsamples, max_nsamples);
+    tb = my_top_block(filelist, args.start, nsamples, max_nsamples);
 
     main_box = plot_constellation_form(tb, 'GNU Radio Constellation Plot', 
10000.0)
     for n in xrange(tb._nsigs):
diff --git a/gr-qtgui/apps/gr_psd_plot_b b/gr-qtgui/apps/gr_psd_plot_b
index 606311a..2626311 100755
--- a/gr-qtgui/apps/gr_psd_plot_b
+++ b/gr-qtgui/apps/gr_psd_plot_b
@@ -54,16 +54,15 @@ class psd_plot_b(plot_base.plot_base):
 
 def main():
     description = "Plots the PSDs of a list of files. Files are a binary list 
of bytes."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = psd_plot_b(filelist,
-                    options.center_frequency, options.sample_rate,
-                    options.psd_size,
-                    options.start, options.nsamples, max_nsamples,
-                    options.average)
+    tb = psd_plot_b(args.files,
+                    args.center_frequency, args.sample_rate,
+                    args.psd_size,
+                    args.start, args.nsamples, max_nsamples,
+                    args.average)
 
     main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_c b/gr-qtgui/apps/gr_psd_plot_c
index 6df9fae..1bd847b 100755
--- a/gr-qtgui/apps/gr_psd_plot_c
+++ b/gr-qtgui/apps/gr_psd_plot_c
@@ -55,16 +55,15 @@ class psd_plot_c(plot_base.plot_base):
 
 def main():
     description = "Plots the PSDs of a list of files. Files are a binary list 
of complex floats."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = psd_plot_c(filelist,
-                    options.center_frequency, options.sample_rate,
-                    options.psd_size,
-                    options.start, options.nsamples, max_nsamples,
-                    options.average)
+    tb = psd_plot_c(args.files,
+                    args.center_frequency, args.sample_rate,
+                    args.psd_size,
+                    args.start, args.nsamples, max_nsamples,
+                    args.average)
 
     main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_f b/gr-qtgui/apps/gr_psd_plot_f
index f07e3e8..04f1b03 100755
--- a/gr-qtgui/apps/gr_psd_plot_f
+++ b/gr-qtgui/apps/gr_psd_plot_f
@@ -55,16 +55,15 @@ class psd_plot_f(plot_base.plot_base):
 
 def main():
     description = "Plots the PSDs of a list of files. Files are a binary list 
of floats."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = psd_plot_f(filelist,
-                    options.center_frequency, options.sample_rate,
-                    options.psd_size,
-                    options.start, options.nsamples, max_nsamples,
-                    options.average)
+    tb = psd_plot_f(args.files,
+                    args.center_frequency, args.sample_rate,
+                    args.psd_size,
+                    args.start, args.nsamples, max_nsamples,
+                    args.average)
 
     main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_i b/gr-qtgui/apps/gr_psd_plot_i
index 1852345..46bdd7b 100755
--- a/gr-qtgui/apps/gr_psd_plot_i
+++ b/gr-qtgui/apps/gr_psd_plot_i
@@ -54,16 +54,15 @@ class psd_plot_i(plot_base.plot_base):
 
 def main():
     description = "Plots the PSDs of a list of files. Files are a binary list 
of integers."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = psd_plot_i(filelist,
-                    options.center_frequency, options.sample_rate,
-                    options.psd_size,
-                    options.start, options.nsamples, max_nsamples,
-                    options.average)
+    tb = psd_plot_i(args.files,
+                    args.center_frequency, args.sample_rate,
+                    args.psd_size,
+                    args.start, args.nsamples, max_nsamples,
+                    args.average)
 
     main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_s b/gr-qtgui/apps/gr_psd_plot_s
index c06076f..8dc4a05 100755
--- a/gr-qtgui/apps/gr_psd_plot_s
+++ b/gr-qtgui/apps/gr_psd_plot_s
@@ -54,16 +54,15 @@ class psd_plot_s(plot_base.plot_base):
 
 def main():
     description = "Plots the PSDs of a list of files. Files are a binary list 
of shorts."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = psd_plot_s(filelist,
-                    options.center_frequency, options.sample_rate,
-                    options.psd_size,
-                    options.start, options.nsamples, max_nsamples,
-                    options.average)
+    tb = psd_plot_s(args.files,
+                    args.center_frequency, args.sample_rate,
+                    args.psd_size,
+                    args.start, args.nsamples, max_nsamples,
+                    args.average)
 
     main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot 
b/gr-qtgui/apps/gr_spectrogram_plot
index db79f9d..8e8ba86 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot
+++ b/gr-qtgui/apps/gr_spectrogram_plot
@@ -142,55 +142,54 @@ def read_header(filelist):
 def main():
    description = 'Plots the spectrogram (waterfall) of a file with detached 
header.'
    description += ' Assumes header is <input_filename>.hdr'
-   (options, args) = plot_base.setup_options(description)
-   filelist = list(args)
+   args = plot_base.setup_options(description)
    # Attempt to read the header information
-   info = read_header(filelist)
+   info = read_header(args.files)
    # If no header, quit
    if not info:
       sys.stderr.write('Header not found\n')
       sys.exit(1)
 
-   max_nsamples = plot_base.find_max_nsamples(filelist)
+   max_nsamples = plot_base.find_max_nsamples(args.files)
    srate = info["rx_rate"]
 
    # Dispatch the proper function
    # Complex Types
    if(info["cplx"] == True):
       if( info["type"] == "float" ):
-         tb = spectrogram_plot_c(filelist,
-                            options.center_frequency,srate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+         tb = spectrogram_plot_c(args.files,
+                            args.center_frequency,srate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
       else:
          sys.stderr.write("Complex File Type " + info["type"]+ " not 
supported.\n")
    # Real Types
    else:
       if( info["type"] == "bytes" ):
-         tb = spectrogram_plot_b(filelist,
-                            options.center_frequency,srate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+         tb = spectrogram_plot_b(args.files,
+                            args.center_frequency,srate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
       elif( info["type"] == "int" ):
-         tb = spectrogram_plot_i(filelist,
-                            options.center_frequency,srate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+         tb = spectrogram_plot_i(args.files,
+                            args.center_frequency,srate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
       elif( info["type"] == "float" ):
-         tb = spectrogram_plot_f(filelist,
-                            options.center_frequency,srate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+         tb = spectrogram_plot_f(args.files,
+                            args.center_frequency,srate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
       elif( info["type"] == "short" ):
-         tb = spectrogram_plot_s(filelist,
-                            options.center_frequency,srate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+         tb = spectrogram_plot_s(args.files,
+                            args.center_frequency,srate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
       else:
         sys.stderr.write("Real File Type " + info["type"] + " not supported\n")
    main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Spectrogram Plot')
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_b 
b/gr-qtgui/apps/gr_spectrogram_plot_b
index 0d7a16e..6045ebf 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_b
+++ b/gr-qtgui/apps/gr_spectrogram_plot_b
@@ -54,16 +54,15 @@ class spectrogram_plot_b(plot_base.plot_base):
 
 def main():
     description = "Plots the spectrogram (waterfall) of a list of files. Files 
are a binary list of chars."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = spectrogram_plot_b(filelist,
-                            options.center_frequency, options.sample_rate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+    tb = spectrogram_plot_b(args.files,
+                            args.center_frequency, args.sample_rate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
 
     main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_c 
b/gr-qtgui/apps/gr_spectrogram_plot_c
index 52b0d4d..a2e63d0 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_c
+++ b/gr-qtgui/apps/gr_spectrogram_plot_c
@@ -55,16 +55,15 @@ class spectrogram_plot_c(plot_base.plot_base):
 
 def main():
     description = "Plots the spectrogram (waterfall) of a list of files. Files 
are a binary list of complex floats."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = spectrogram_plot_c(filelist,
-                            options.center_frequency, options.sample_rate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+    tb = spectrogram_plot_c(args.files,
+                            args.center_frequency, args.sample_rate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
 
     main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Spectrogram 
Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_f 
b/gr-qtgui/apps/gr_spectrogram_plot_f
index 6ea5afc..d131747 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_f
+++ b/gr-qtgui/apps/gr_spectrogram_plot_f
@@ -55,16 +55,15 @@ class spectrogram_plot_f(plot_base.plot_base):
 
 def main():
     description = "Plots the spectrogram (waterfall) of a list of files. Files 
are a binary list of floats."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = spectrogram_plot_f(filelist,
-                            options.center_frequency, options.sample_rate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+    tb = spectrogram_plot_f(args.files,
+                            args.center_frequency, args.sample_rate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
 
     main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_i 
b/gr-qtgui/apps/gr_spectrogram_plot_i
index 893df2a..723291d 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_i
+++ b/gr-qtgui/apps/gr_spectrogram_plot_i
@@ -54,16 +54,15 @@ class spectrogram_plot_i(plot_base.plot_base):
 
 def main():
     description = "Plots the spectrogram (waterfall) of a list of files. Files 
are a binary list of ints."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = spectrogram_plot_i(filelist,
-                            options.center_frequency, options.sample_rate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+    tb = spectrogram_plot_i(args.files,
+                            args.center_frequency, args.sample_rate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
 
     main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_s 
b/gr-qtgui/apps/gr_spectrogram_plot_s
index 82a22f7..606fbf9 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_s
+++ b/gr-qtgui/apps/gr_spectrogram_plot_s
@@ -54,16 +54,15 @@ class spectrogram_plot_s(plot_base.plot_base):
 
 def main():
     description = "Plots the spectrogram (waterfall) of a list of files. Files 
are a binary list of shorts."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = spectrogram_plot_s(filelist,
-                            options.center_frequency, options.sample_rate,
-                            options.psd_size,
-                            options.start, options.nsamples, max_nsamples,
-                            options.average);
+    tb = spectrogram_plot_s(args.files,
+                            args.center_frequency, args.sample_rate,
+                            args.psd_size,
+                            args.start, args.nsamples, max_nsamples,
+                            args.average);
 
     main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_b b/gr-qtgui/apps/gr_time_plot_b
index d822557..a2f63cc 100755
--- a/gr-qtgui/apps/gr_time_plot_b
+++ b/gr-qtgui/apps/gr_time_plot_b
@@ -52,14 +52,13 @@ class plot_time_b(plot_base.plot_base):
 
 def main():
     description = "Plots a list of files on a scope plot. Files are a binary 
list of chars."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = plot_time_b(filelist, options.sample_rate,
-                     options.start, options.nsamples, max_nsamples,
-                     not options.no_auto_scale)
+    tb = plot_time_b(args.files, args.sample_rate,
+                     args.start, args.nsamples, max_nsamples,
+                     not args.no_auto_scale)
 
     main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_c b/gr-qtgui/apps/gr_time_plot_c
index 202e0f8..3dfccad 100755
--- a/gr-qtgui/apps/gr_time_plot_c
+++ b/gr-qtgui/apps/gr_time_plot_c
@@ -54,14 +54,13 @@ class plot_time_c(plot_base.plot_base):
 
 def main():
     description = "Plots a list of files on a scope plot. Files are a binary 
list of complex floats."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = plot_time_c(filelist, options.sample_rate,
-                     options.start, options.nsamples, max_nsamples,
-                     not options.no_auto_scale)
+    tb = plot_time_c(args.files, args.sample_rate,
+                     args.start, args.nsamples, max_nsamples,
+                     not args.no_auto_scale)
 
     main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot', 10000.0)
     main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_f b/gr-qtgui/apps/gr_time_plot_f
index 8f5ad9f..59b340d 100755
--- a/gr-qtgui/apps/gr_time_plot_f
+++ b/gr-qtgui/apps/gr_time_plot_f
@@ -53,14 +53,13 @@ class plot_time_f(plot_base.plot_base):
 
 def main():
     description = "Plots a list of files on a scope plot. Files are a binary 
list of floats."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = plot_time_f(filelist, options.sample_rate,
-                     options.start, options.nsamples, max_nsamples,
-                     not options.no_auto_scale)
+    tb = plot_time_f(args.files, args.sample_rate,
+                     args.start, args.nsamples, max_nsamples,
+                     not args.no_auto_scale)
 
     main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot', 10000.0)
     main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_i b/gr-qtgui/apps/gr_time_plot_i
index 8a7888b..66c0a7f 100755
--- a/gr-qtgui/apps/gr_time_plot_i
+++ b/gr-qtgui/apps/gr_time_plot_i
@@ -52,14 +52,13 @@ class plot_time_i(plot_base.plot_base):
 
 def main():
     description = "Plots a list of files on a scope plot. Files are a binary 
list of integers."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = plot_time_i(filelist, options.sample_rate,
-                     options.start, options.nsamples, max_nsamples,
-                     not options.no_auto_scale)
+    tb = plot_time_i(args.files, args.sample_rate,
+                     args.start, args.nsamples, max_nsamples,
+                     not args.no_auto_scale)
 
     main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_s b/gr-qtgui/apps/gr_time_plot_s
index 7cee262..b2e4232 100755
--- a/gr-qtgui/apps/gr_time_plot_s
+++ b/gr-qtgui/apps/gr_time_plot_s
@@ -52,14 +52,13 @@ class plot_time_s(plot_base.plot_base):
 
 def main():
     description = "Plots a list of files on a scope plot. Files are a binary 
list of shorts."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = plot_time_s(filelist, options.sample_rate,
-                     options.start, options.nsamples, max_nsamples,
-                     not options.no_auto_scale)
+    tb = plot_time_s(args.files, args.sample_rate,
+                     args.start, args.nsamples, max_nsamples,
+                     not args.no_auto_scale)
 
     main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_time_raster_b b/gr-qtgui/apps/gr_time_raster_b
index ad86914..6cd93b0 100755
--- a/gr-qtgui/apps/gr_time_raster_b
+++ b/gr-qtgui/apps/gr_time_raster_b
@@ -56,15 +56,14 @@ class plot_time_raster_b(plot_base.plot_base):
 
 def main():
     description = "Plots a list of files on a scope plot. Files are a binary 
list of chars."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = plot_time_raster_b(filelist, options.sample_rate,
-                            options.start, options.nsamples, max_nsamples,
-                            options.nrows, options.ncols,
-                            not options.no_auto_scale)
+    tb = plot_time_raster_b(args.files, args.sample_rate,
+                            args.start, args.nsamples, max_nsamples,
+                            args.nrows, args.ncols,
+                            not args.no_auto_scale)
 
     main_box = plot_base.plot_time_raster_form(tb, 'GNU Radio Time Plot')
     main_box.show()
diff --git a/gr-qtgui/apps/gr_time_raster_f b/gr-qtgui/apps/gr_time_raster_f
index 5d6a838..944d739 100755
--- a/gr-qtgui/apps/gr_time_raster_f
+++ b/gr-qtgui/apps/gr_time_raster_f
@@ -56,15 +56,14 @@ class plot_time_raster_f(plot_base.plot_base):
 
 def main():
     description = "Plots a list of files on a scope plot. Files are a binary 
list of floats."
-    (options, args) = plot_base.setup_options(description)
+    args = plot_base.setup_options(description)
 
-    filelist = list(args)
-    max_nsamples = plot_base.find_max_nsamples(filelist)
+    max_nsamples = plot_base.find_max_nsamples(args.files)
 
-    tb = plot_time_raster_f(filelist, options.sample_rate,
-                            options.start, options.nsamples, max_nsamples,
-                            options.nrows, options.ncols,
-                            not options.no_auto_scale)
+    tb = plot_time_raster_f(args.files, args.sample_rate,
+                            args.start, args.nsamples, max_nsamples,
+                            args.nrows, args.ncols,
+                            not args.no_auto_scale)
 
     main_box = plot_base.plot_time_raster_form(tb, 'GNU Radio Time Plot', 
10000.0)
     main_box.show()
diff --git a/gr-qtgui/apps/plot_psd_base.py b/gr-qtgui/apps/plot_psd_base.py
index 46f903e..c3c03ec 100644
--- a/gr-qtgui/apps/plot_psd_base.py
+++ b/gr-qtgui/apps/plot_psd_base.py
@@ -21,8 +21,8 @@
 #
 
 from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
 import os, sys
 
 try:
@@ -141,23 +141,21 @@ class plot_base(gr.top_block):
         self.start()
 
 def setup_options(desc):
-    parser = OptionParser(option_class=eng_option, description=desc,
-                          conflict_handler="resolve")
-    parser.add_option("-N", "--nsamples", type="int", default=1000000,
+    parser = ArgumentParser(description=desc, conflict_handler="resolve")
+    parser.add_argument("-N", "--nsamples", type=int, default=1000000,
                       help="Set the number of samples to display 
[default=prints entire file]")
-    parser.add_option("-S", "--start", type="int", default=0,
-                      help="Starting sample number [default=%default]")
-    parser.add_option("-L", "--psd-size", type="int", default=2048,
-                      help="Set the FFT size of the PSD [default=%default]")
-    parser.add_option("-f", "--center-frequency", type="eng_float", 
default=0.0,
-                      help="Set the center frequency of the signal 
[default=%default]")
-    parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
-                      help="Set the sample rate of the signal 
[default=%default]")
-    parser.add_option("-a", "--average", type="float", default=1.0,
-                      help="Set amount of averaging (smaller=more averaging) 
[default=%default]")
-    (options, args) = parser.parse_args()
-
-    if(len(args) < 1):
-        parser.print_help()
-        sys.exit(0)
-    return (options,args)
+    parser.add_argument("-S", "--start", type=int, default=0,
+                      help="Starting sample number [default=%(default)r]")
+    parser.add_argument("-L", "--psd-size", type=int, default=2048,
+                      help="Set the FFT size of the PSD [default=%(default)r]")
+    parser.add_argument("-f", "--center-frequency", type=eng_float, 
default=0.0,
+                      help="Set the center frequency of the signal 
[default=%(default)r]")
+    parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+                      help="Set the sample rate of the signal 
[default=%(default)r]")
+    parser.add_argument("-a", "--average", type=float, default=1.0,
+                      help="Set amount of averaging (smaller=more averaging) 
[default=%(default)r]")
+    parser.add_argument("files", nargs='+', metavar='FILE',
+                      help="Complex samples")
+    args = parser.parse_args()
+
+    return args
diff --git a/gr-qtgui/apps/plot_spectrogram_base.py 
b/gr-qtgui/apps/plot_spectrogram_base.py
index b252bb8..f568100 100644
--- a/gr-qtgui/apps/plot_spectrogram_base.py
+++ b/gr-qtgui/apps/plot_spectrogram_base.py
@@ -21,8 +21,8 @@
 #
 
 from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
 import os, sys
 
 try:
@@ -146,25 +146,22 @@ class plot_base(gr.top_block):
         self.start()
 
 def setup_options(desc):
-    parser = OptionParser(option_class=eng_option, description=desc,
-                          conflict_handler="resolve")
-    parser.add_option("-N", "--nsamples", type="int", default=1000000,
-                      help="Set the number of samples to display 
[default=%default]")
-    parser.add_option("-S", "--start", type="int", default=0,
-                      help="Starting sample number [default=%default]")
-    parser.add_option("-L", "--psd-size", type="int", default=2048,
-                      help="Set the FFT size of the PSD [default=%default]")
-    parser.add_option("-f", "--center-frequency", type="eng_float", 
default=0.0,
-                      help="Set the center frequency of the signal 
[default=%default]")
-    parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
-                      help="Set the sample rate of the signal 
[default=%default]")
-    parser.add_option("-a", "--average", type="float", default=1.0,
-                      help="Set amount of averaging (smaller=more averaging) 
[default=%default]")
-    (options, args) = parser.parse_args()
-
-    if(len(args) < 1):
-        parser.print_help()
-        sys.exit(0)
-
-    return (options, args)
+    parser = ArgumentParser(description=desc, conflict_handler="resolve")
+    parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+                      help="Set the number of samples to display 
[default=%(default)r]")
+    parser.add_argument("-S", "--start", type=int, default=0,
+                      help="Starting sample number [default=%(default)r]")
+    parser.add_argument("-L", "--psd-size", type=int, default=2048,
+                      help="Set the FFT size of the PSD [default=%(default)r]")
+    parser.add_argument("-f", "--center-frequency", type=eng_float, 
default=0.0,
+                      help="Set the center frequency of the signal 
[default=%(default)r]")
+    parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+                      help="Set the sample rate of the signal 
[default=%(default)r]")
+    parser.add_argument("-a", "--average", type=float, default=1.0,
+                      help="Set amount of averaging (smaller=more averaging) 
[default=%(default)r]")
+    parser.add_argument('files', nargs='+', metavar='FILE',
+                      help="File with complex samples")
+    args = parser.parse_args()
+
+    return args
 
diff --git a/gr-qtgui/apps/plot_time_base.py b/gr-qtgui/apps/plot_time_base.py
index 007c94d..cfbe5dc 100644
--- a/gr-qtgui/apps/plot_time_base.py
+++ b/gr-qtgui/apps/plot_time_base.py
@@ -21,8 +21,8 @@
 #
 
 from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
 import os, sys
 
 try:
@@ -166,19 +166,18 @@ class plot_base(gr.top_block):
             self._auto_scale = False
 
 def setup_options(desc):
-    parser = OptionParser(option_class=eng_option, description=desc,
-                          conflict_handler="resolve")
-    parser.add_option("-N", "--nsamples", type="int", default=1000000,
-                      help="Set the number of samples to display 
[default=%default]")
-    parser.add_option("-S", "--start", type="int", default=0,
-                      help="Starting sample number [default=%default]")
-    parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
-                      help="Set the sample rate of the signal 
[default=%default]")
-    parser.add_option("", "--no-auto-scale", action="store_true", 
default=False,
-                      help="Do not auto-scale the plot [default=%default]")
-    (options,args) = parser.parse_args()
-    if(len(args) < 1):
-        parser.print_help()
-        sys.exit(0)
-    return (options,args)
+    parser = ArgumentParser(description=desc, conflict_handler="resolve")
+    parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+                      help="Set the number of samples to display 
[default=%(default)r]")
+    parser.add_argument("-S", "--start", type=int, default=0,
+                      help="Starting sample number [default=%(default)r]")
+    parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+                      help="Set the sample rate of the signal 
[default=%(default)r]")
+    parser.add_argument("--no-auto-scale", action="store_true",
+                      help="Do not auto-scale the plot [default=%(default)r]")
+    parser.add_argument("files", nargs='+', metavar="FILE",
+                      help="File with complex samples")
+    args = parser.parse_args()
+
+    return args
 
diff --git a/gr-qtgui/apps/plot_time_raster_base.py 
b/gr-qtgui/apps/plot_time_raster_base.py
index 856c8c8..e84b84c 100644
--- a/gr-qtgui/apps/plot_time_raster_base.py
+++ b/gr-qtgui/apps/plot_time_raster_base.py
@@ -21,8 +21,8 @@
 #
 
 from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
 import os, sys
 
 try:
@@ -161,23 +161,22 @@ class plot_base(gr.top_block):
             self._auto_scale = False
 
 def setup_options(desc):
-    parser = OptionParser(option_class=eng_option, description=desc,
-                          conflict_handler="resolve")
-    parser.add_option("-N", "--nsamples", type="int", default=1000000,
-                      help="Set the number of samples to display 
[default=%default]")
-    parser.add_option("-S", "--start", type="int", default=0,
-                      help="Starting sample number [default=%default]")
-    parser.add_option("-C", "--ncols", type="int", default=100,
-                      help="Number of columns [default=%default]")
-    parser.add_option("-R", "--nrows", type="int", default=100,
-                      help="Number of rows [default=%default]")
-    parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
-                      help="Set the sample rate of the signal 
[default=%default]")
-    parser.add_option("", "--no-auto-scale", action="store_true", 
default=False,
-                      help="Do not auto-scale the plot [default=%default]")
-    (options,args) = parser.parse_args()
-    if(len(args) < 1):
-        parser.print_help()
-        sys.exit(0)
-    return (options,args)
+    parser = ArgumentParser(description=desc, conflict_handler="resolve")
+    parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+                      help="Set the number of samples to display 
[default=%(default)r]")
+    parser.add_argument("-S", "--start", type=int, default=0,
+                      help="Starting sample number [default=%(default)r]")
+    parser.add_argument("-C", "--ncols", type=int, default=100,
+                      help="Number of columns [default=%(default)r]")
+    parser.add_argument("-R", "--nrows", type=int, default=100,
+                      help="Number of rows [default=%(default)r]")
+    parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+                      help="Set the sample rate of the signal 
[default=%(default)r]")
+    parser.add_argument("--no-auto-scale", action="store_true",
+                      help="Do not auto-scale the plot [default=%(default)r]")
+    parser.add_argument("files", nargs="+", metavar="FILE",
+                      help="Input files with complex samples")
+    args = parser.parse_args()
+
+    return args
 
diff --git a/gr-utils/python/utils/gr_plot_fft 
b/gr-utils/python/utils/gr_plot_fft
index 4343481..59fc88b 100644
--- a/gr-utils/python/utils/gr_plot_fft
+++ b/gr-utils/python/utils/gr_plot_fft
@@ -27,13 +27,9 @@ from gnuradio.plot_fft_base import plot_fft_base
 
 def main():
     parser = plot_fft_base.setup_options()
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
+    args = parser.parse_args()
 
-    dc = plot_fft_base(options.data_type, filename, options)
+    dc = plot_fft_base(args.data_type, args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_fft_c 
b/gr-utils/python/utils/gr_plot_fft_c
index 43e808d..48d3218 100755
--- a/gr-utils/python/utils/gr_plot_fft_c
+++ b/gr-utils/python/utils/gr_plot_fft_c
@@ -26,15 +26,12 @@ from gnuradio.plot_fft_base import plot_fft_base
 
 def main():
     parser = plot_fft_base.setup_options()
-    parser.remove_option("--data-type")
+    parser.add_argument("-d", "--data-type", default="complex64",
+            choices=("complex64", ))
 
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
+    args = parser.parse_args()
 
-    dc = plot_fft_base("complex64", filename, options)
+    dc = plot_fft_base("complex64", args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_fft_f 
b/gr-utils/python/utils/gr_plot_fft_f
index dee9b17..d179141 100755
--- a/gr-utils/python/utils/gr_plot_fft_f
+++ b/gr-utils/python/utils/gr_plot_fft_f
@@ -26,15 +26,11 @@ from gnuradio.plot_fft_base import plot_fft_base
 
 def main():
     parser = plot_fft_base.setup_options()
-    parser.remove_option("--data-type")
+    parser.add_argument("-d", "--data-type", default="float32",
+            choices=("float32", ))
+    args = parser.parse_args()
 
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
-
-    dc = plot_fft_base("float32", filename, options)
+    dc = plot_fft_base("float32", args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_float 
b/gr-utils/python/utils/gr_plot_float
index 22806e4..faf8106 100755
--- a/gr-utils/python/utils/gr_plot_float
+++ b/gr-utils/python/utils/gr_plot_float
@@ -26,29 +26,26 @@ except ImportError:
     print "Please install SciPy to run this script (http://www.scipy.org/)"
     raise SystemExit, 1
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
 
 def main():
-    usage="%prog: [options] input_filenames"
     description = "Takes a GNU Radio floating point binary file and displays 
the samples versus time. You can set the block size to specify how many points 
to read in at a time and the start position in the file. By default, the system 
assumes a sample rate of 1, so in time, each sample is plotted versus the 
sample number. To set a true time axis, set the sample rate (-R or 
--sample-rate) to the sample rate used when capturing the samples."
 
-    parser = OptionParser(conflict_handler="resolve", usage=usage, 
description=description)
-    parser.add_option("-B", "--block", type="int", default=1000,
-                      help="Specify the block size [default=%default]")
-    parser.add_option("-s", "--start", type="int", default=0,
-                      help="Specify where to start in the file 
[default=%default]")
-    parser.add_option("-R", "--sample-rate", type="float", default=1.0,
-                      help="Set the sampler rate of the data 
[default=%default]")
+    parser = ArgumentParser(conflict_handler="resolve", 
description=description)
+    parser.add_argument("-B", "--block", type=int, default=1000,
+            help="Specify the block size [default=%(default)r]")
+    parser.add_argument("-s", "--start", type=int, default=0,
+            help="Specify where to start in the file [default=%(default)r]")
+    parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+            help="Set the sampler rate of the data [default=%(default)r]")
+    parser.add_argument("file", metavar="FILE", nargs='+',
+            help="Input file with samples")
 
-    (options, args) = parser.parse_args ()
-    if len(args) < 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filenames = args
+    args = parser.parse_args()
 
     datatype=scipy.float32
-    dc = plot_data(datatype, filenames, options)
+    dc = plot_data(datatype, args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_int 
b/gr-utils/python/utils/gr_plot_int
index 355ddf0..c687f13 100755
--- a/gr-utils/python/utils/gr_plot_int
+++ b/gr-utils/python/utils/gr_plot_int
@@ -26,29 +26,26 @@ except ImportError:
     print "Please install SciPy to run this script (http://www.scipy.org/)"
     raise SystemExit, 1
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
 
 def main():
-    usage="%prog: [options] input_filenames"
     description = "Takes a GNU Radio integer binary file and displays the 
samples versus time. You can set the block size to specify how many points to 
read in at a time and the start position in the file. By default, the system 
assumes a sample rate of 1, so in time, each sample is plotted versus the 
sample number. To set a true time axis, set the sample rate (-R or 
--sample-rate) to the sample rate used when capturing the samples."
 
-    parser = OptionParser(conflict_handler="resolve", usage=usage, 
description=description)
-    parser.add_option("-B", "--block", type="int", default=1000,
-                      help="Specify the block size [default=%default]")
-    parser.add_option("-s", "--start", type="int", default=0,
-                      help="Specify where to start in the file 
[default=%default]")
-    parser.add_option("-R", "--sample-rate", type="float", default=1.0,
-                      help="Set the sampler rate of the data 
[default=%default]")
+    parser = ArgumentParser(conflict_handler="resolve", 
description=description)
+    parser.add_argument("-B", "--block", type=int, default=1000,
+            help="Specify the block size [default=%(default)r]")
+    parser.add_argument("-s", "--start", type=int, default=0,
+            help="Specify where to start in the file [default=%(default)r]")
+    parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+            help="Set the sampler rate of the data [default=%(default)r]")
+    parser.add_argument("file", metavar="FILE", nargs='+',
+            help="Input file");
 
-    (options, args) = parser.parse_args ()
-    if len(args) < 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filenames = args
+    args = parser.parse_args()
 
     datatype=scipy.int32
-    dc = plot_data(datatype, filenames, options)
+    dc = plot_data(datatype, args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_iq b/gr-utils/python/utils/gr_plot_iq
index bf8077b..7409b73 100755
--- a/gr-utils/python/utils/gr_plot_iq
+++ b/gr-utils/python/utils/gr_plot_iq
@@ -32,7 +32,7 @@ except ImportError:
     print "Please install Matplotlib to run this script 
(http://matplotlib.sourceforge.net/)"
     raise SystemExit, 1
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 
 class draw_iq:
     def __init__(self, filename, options):
@@ -149,24 +149,21 @@ def find(item_in, list_search):
        return False
 
 def main():
-    usage="%prog: [options] input_filename"
     description = "Takes a GNU Radio complex binary file and displays the I&Q 
data versus time. You can set the block size to specify how many points to read 
in at a time and the start position in the file. By default, the system assumes 
a sample rate of 1, so in time, each sample is plotted versus the sample 
number. To set a true time axis, set the sample rate (-R or --sample-rate) to 
the sample rate used when capturing the samples."
 
-    parser = OptionParser(conflict_handler="resolve", usage=usage, 
description=description)
-    parser.add_option("-B", "--block", type="int", default=1000,
-                      help="Specify the block size [default=%default]")
-    parser.add_option("-s", "--start", type="int", default=0,
-                      help="Specify where to start in the file 
[default=%default]")
-    parser.add_option("-R", "--sample-rate", type="float", default=1.0,
-                      help="Set the sampler rate of the data 
[default=%default]")
-
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
-
-    dc = draw_iq(filename, options)
+    parser = ArgumentParser(conflict_handler="resolve", 
description=description)
+    parser.add_argument("-B", "--block", type=int, default=1000,
+            help="Specify the block size [default=%(default)r]")
+    parser.add_argument("-s", "--start", type=int, default=0,
+            help="Specify where to start in the file [default=%(default)r]")
+    parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+            help="Set the sampler rate of the data [default=%(default)r]")
+    parser.add_argument("file", metavar="FILE",
+            help="Input file with complex samples")
+
+    args = parser.parse_args()
+
+    dc = draw_iq(args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_psd 
b/gr-utils/python/utils/gr_plot_psd
index 059ca6b..b052cbf 100644
--- a/gr-utils/python/utils/gr_plot_psd
+++ b/gr-utils/python/utils/gr_plot_psd
@@ -27,13 +27,9 @@ from gnuradio.plot_psd_base import plot_psd_base
 
 def main():
     parser = plot_psd_base.setup_options()
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
+    args = parser.parse_args()
 
-    dc = plot_psd_base(options.data_type, filename, options)
+    dc = plot_psd_base(args.data_type, args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_psd_c 
b/gr-utils/python/utils/gr_plot_psd_c
index fff2bff..352a838 100755
--- a/gr-utils/python/utils/gr_plot_psd_c
+++ b/gr-utils/python/utils/gr_plot_psd_c
@@ -20,22 +20,19 @@
 # Boston, MA 02110-1301, USA.
 #
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 from gnuradio.plot_psd_base import plot_psd_base
 
 # This is a wrapper program for plot_psd_base specifically for complex data
 
 def main():
     parser = plot_psd_base.setup_options()
-    parser.remove_option("--data-type")
+    parser.add_argument("-d", "--data-type", default="complex64",
+            choices=("complex64", ))
 
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
+    args = parser.parse_args()
 
-    dc = plot_psd_base("complex64", filename, options)
+    dc = plot_psd_base("complex64", args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_psd_f 
b/gr-utils/python/utils/gr_plot_psd_f
index ec67994..ab860e3 100755
--- a/gr-utils/python/utils/gr_plot_psd_f
+++ b/gr-utils/python/utils/gr_plot_psd_f
@@ -20,22 +20,19 @@
 # Boston, MA 02110-1301, USA.
 #
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 from gnuradio.plot_psd_base import plot_psd_base
 
 # This is a wrapper program for gr_plot_psd specifically for floating point 
data
 
 def main():
     parser = plot_psd_base.setup_options()
-    parser.remove_option("--data-type")
+    parser.add_argument("-d", "--data-type", default="complex64",
+            choices=("float32", ))
 
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
+    args = parser.parse_args()
 
-    dc = plot_psd_base("float32", filename, options)
+    dc = plot_psd_base("float32", args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/gr_plot_short 
b/gr-utils/python/utils/gr_plot_short
index 702a2a9..f900af1 100755
--- a/gr-utils/python/utils/gr_plot_short
+++ b/gr-utils/python/utils/gr_plot_short
@@ -26,29 +26,26 @@ except ImportError:
     print "Please install SciPy to run this script (http://www.scipy.org/)"
     raise SystemExit, 1
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
 
 def main():
-    usage="%prog: [options] input_filenames"
     description = "Takes a GNU Radio short integer binary file and displays 
the samples versus time. You can set the block size to specify how many points 
to read in at a time and the start position in the file. By default, the system 
assumes a sample rate of 1, so in time, each sample is plotted versus the 
sample number. To set a true time axis, set the sample rate (-R or 
--sample-rate) to the sample rate used when capturing the samples."
 
-    parser = OptionParser(conflict_handler="resolve", usage=usage, 
description=description)
-    parser.add_option("-B", "--block", type="int", default=1000,
-                      help="Specify the block size [default=%default]")
-    parser.add_option("-s", "--start", type="int", default=0,
-                      help="Specify where to start in the file 
[default=%default]")
-    parser.add_option("-R", "--sample-rate", type="float", default=1.0,
-                      help="Set the sampler rate of the data 
[default=%default]")
+    parser = ArgumentParser(conflict_handler="resolve", 
description=description)
+    parser.add_argument("-B", "--block", type=int, default=1000,
+            help="Specify the block size [default=%(default)r]")
+    parser.add_argument("-s", "--start", type=int, default=0,
+            help="Specify where to start in the file [default=%(default)r]")
+    parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+            help="Set the sampler rate of the data [default=%(default)r]")
+    parser.add_argument("files", metavar="FILE", nargs="+",
+            help="Input file with data (int16_t)")
 
-    (options, args) = parser.parse_args ()
-    if len(args) < 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filenames = args
+    args = parser.parse_args()
 
     datatype=scipy.int16
-    dc = plot_data(datatype, filenames, options)
+    dc = plot_data(datatype, args.files, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/plot_fft_base.py 
b/gr-utils/python/utils/plot_fft_base.py
index c4bc484..c994621 100755
--- a/gr-utils/python/utils/plot_fft_base.py
+++ b/gr-utils/python/utils/plot_fft_base.py
@@ -33,7 +33,7 @@ except ImportError:
     print "Please install Python Matplotlib 
(http://matplotlib.sourceforge.net/) and Python TkInter 
https://wiki.python.org/moin/TkInter to run this script"
     raise SystemExit, 1
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 
 class plot_fft_base:
     def __init__(self, datatype, filename, options):
@@ -209,18 +209,21 @@ class plot_fft_base:
 
     @staticmethod
     def setup_options():
-        usage="%prog: [options] input_filename"
         description = "Takes a GNU Radio complex binary file and displays the 
I&Q data versus time as well as the frequency domain (FFT) plot. The y-axis 
values are plotted assuming volts as the amplitude of the I&Q streams and 
converted into dBm in the frequency domain (the 1/N power adjustment out of the 
FFT is performed internally). The script plots a certain block of data at a 
time, specified on the command line as -B or --block. This value defaults to 
1000. The start position in the [...]
 
-        parser = OptionParser(conflict_handler="resolve", usage=usage, 
description=description)
-        parser.add_option("-d", "--data-type", type="string", 
default="complex64",
-                          help="Specify the data type (complex64, float32, 
(u)int32, (u)int16, (u)int8) [default=%default]")
-        parser.add_option("-B", "--block", type="int", default=1000,
-                          help="Specify the block size [default=%default]")
-        parser.add_option("-s", "--start", type="int", default=0,
-                          help="Specify where to start in the file 
[default=%default]")
-        parser.add_option("-R", "--sample-rate", type="float", default=1.0,
-                          help="Set the sampler rate of the data 
[default=%default]")
+        parser = ArgumentParser(conflict_handler="resolve", 
description=description)
+        parser.add_argument("-d", "--data-type", default="complex64",
+                choices=("complex64", "float32", "uint32", "int32", "uint16",
+                    "int16", "uint8", "int8"),
+                help="Specify the data type [default=%(default)r]")
+        parser.add_argument("-B", "--block", type=int, default=1000,
+                help="Specify the block size [default=%(default)r]")
+        parser.add_argument("-s", "--start", type=int, default=0,
+                help="Specify where to start in the file 
[default=%(default)r]")
+        parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+                help="Set the sampler rate of the data [default=%(default)r]")
+        parser.add_argument("file", metavar="FILE",
+                help="Input file with samples")
         return parser
 
 def find(item_in, list_search):
@@ -231,13 +234,9 @@ def find(item_in, list_search):
 
 def main():
     parser = plot_fft_base.setup_options()
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
+    args = parser.parse_args()
 
-    dc = plot_fft_base(options.data_type, filename, options)
+    dc = plot_fft_base(args.data_type, args.file, args)
 
 if __name__ == "__main__":
     try:
diff --git a/gr-utils/python/utils/plot_psd_base.py 
b/gr-utils/python/utils/plot_psd_base.py
index fe3c9e1..2611ed4 100755
--- a/gr-utils/python/utils/plot_psd_base.py
+++ b/gr-utils/python/utils/plot_psd_base.py
@@ -33,9 +33,9 @@ except ImportError:
     print "Please install Matplotlib to run this script 
(http://matplotlib.sourceforge.net/)"
     raise SystemExit, 1
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 from scipy import log10
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_float, intx
 
 class plot_psd_base:
     def __init__(self, datatype, filename, options):
@@ -244,25 +244,27 @@ class plot_psd_base:
 
     @staticmethod
     def setup_options():
-        usage="%prog: [options] input_filename"
         description = "Takes a GNU Radio binary file (with specified data type 
using --data-type) and displays the I&Q data versus time as well as the power 
spectral density (PSD) plot. The y-axis values are plotted assuming volts as 
the amplitude of the I&Q streams and converted into dBm in the frequency domain 
(the 1/N power adjustment out of the FFT is performed internally). The script 
plots a certain block of data at a time, specified on the command line as -B or 
--block. The start p [...]
 
-        parser = OptionParser(option_class=eng_option, 
conflict_handler="resolve",
-                              usage=usage, description=description)
-        parser.add_option("-d", "--data-type", type="string", 
default="complex64",
-                          help="Specify the data type (complex64, float32, 
(u)int32, (u)int16, (u)int8) [default=%default]")
-        parser.add_option("-B", "--block", type="int", default=8192,
-                          help="Specify the block size [default=%default]")
-        parser.add_option("-s", "--start", type="int", default=0,
-                          help="Specify where to start in the file 
[default=%default]")
-        parser.add_option("-R", "--sample-rate", type="eng_float", default=1.0,
-                          help="Set the sampler rate of the data 
[default=%default]")
-        parser.add_option("", "--psd-size", type="int", default=1024,
-                          help="Set the size of the PSD FFT 
[default=%default]")
-        parser.add_option("", "--spec-size", type="int", default=256,
-                          help="Set the size of the spectrogram FFT 
[default=%default]")
-        parser.add_option("-S", "--enable-spec", action="store_true", 
default=False,
-                          help="Turn on plotting the spectrogram 
[default=%default]")
+        parser = ArgumentParser(conflict_handler="resolve", 
description=description)
+        parser.add_argument("-d", "--data-type", default="complex64",
+                choices=("complex64", "float32", "int32", "uint32", "int16",
+                    "uint16", "int8", "uint8" ),
+                help="Specify the data type [default=%(default)r]")
+        parser.add_argument("-B", "--block", type=int, default=8192,
+                help="Specify the block size [default=%(default)r]")
+        parser.add_argument("-s", "--start", type=int, default=0,
+                help="Specify where to start in the file 
[default=%(default)r]")
+        parser.add_argument("-R", "--sample-rate", type=eng_float, default=1.0,
+                help="Set the sampler rate of the data [default=%(default)r]")
+        parser.add_argument("--psd-size", type=int, default=1024,
+                help="Set the size of the PSD FFT [default=%(default)r]")
+        parser.add_argument("--spec-size", type=int, default=256,
+                help="Set the size of the spectrogram FFT 
[default=%(default)r]")
+        parser.add_argument("-S", "--enable-spec", action="store_true",
+                help="Turn on plotting the spectrogram [default=%(default)r]")
+        parser.add_argument("file", metavar="FILE",
+                help="Input file with samples")
 
         return parser
 
@@ -274,13 +276,9 @@ def find(item_in, list_search):
 
 def main():
     parser = plot_psd_base.setup_options()
-    (options, args) = parser.parse_args ()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filename = args[0]
+    args = parser.parse_args()
 
-    dc = plot_psd_base(options.data_type, filename, options)
+    dc = plot_psd_base(args.data_type, args.file, args)
 
 if __name__ == "__main__":
     try:



reply via email to

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