summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
authorBrennan Ashton <bashton@brennanashton.com>2018-11-14 18:06:11 -0800
committerMartin Braun <martin.braun@ettus.com>2018-11-15 15:44:05 -0800
commit7a8cab2809e613af811bdb86d6a1021eacf58e19 (patch)
tree20a53066685146ac59f1b4d097fe3abcf7488d32 /gr-uhd
parentb0f69ff0e38b8a8a5729e2131e90c55be77bb12a (diff)
gr-uhd: Improve input parameter exception handling for uhd_app
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/apps/uhd_app.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/gr-uhd/apps/uhd_app.py b/gr-uhd/apps/uhd_app.py
index 4151fd294d..75ae37e7fb 100644
--- a/gr-uhd/apps/uhd_app.py
+++ b/gr-uhd/apps/uhd_app.py
@@ -85,7 +85,9 @@ class UHDApp(object):
"""
Return a nice textual description of the USRP we're using.
"""
- assert tx_or_rx == 'rx' or tx_or_rx == 'tx'
+ if tx_or_rx not in ['rx', 'tx']:
+ raise ValueError("tx_or_rx argument must be one of ['rx', 'tx']")
+
try:
info_pp = {}
if self.prefix is None:
@@ -110,7 +112,7 @@ class UHDApp(object):
if compact:
tpl = COMPACT_TPL
return tpl.format(**info_pp)
- except:
+ except Exception:
return "Can't establish USRP info."
def normalize_sel(self, num_name, arg_name, num, arg):
@@ -351,7 +353,7 @@ class UHDApp(object):
"""
try:
return [int(x.strip()) for x in string.split(",")]
- except:
+ except ValueError:
raise argparse.ArgumentTypeError("Not a comma-separated list: {string}".format(string=string))
if parser is None:
parser = argparse.ArgumentParser(