From c2c1ba21350d588adb4ec8f2f815f50df81927f8 Mon Sep 17 00:00:00 2001
From: trondeau <trondeau@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Wed, 30 Jan 2008 22:28:15 +0000
Subject: Catching ImportError exception and giving (hopefully) useful error
 message to install the necessary packages.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@7529 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gnuradio-core/src/utils/gr_plot_char.py  |  7 ++++++-
 gnuradio-core/src/utils/gr_plot_const.py | 18 ++++++++++++++----
 gnuradio-core/src/utils/gr_plot_data.py  | 14 ++++++++++++--
 gnuradio-core/src/utils/gr_plot_fft_c.py | 18 ++++++++++++++----
 gnuradio-core/src/utils/gr_plot_fft_f.py | 18 ++++++++++++++----
 gnuradio-core/src/utils/gr_plot_float.py |  7 ++++++-
 gnuradio-core/src/utils/gr_plot_int.py   |  7 ++++++-
 gnuradio-core/src/utils/gr_plot_iq.py    | 16 +++++++++++++---
 gnuradio-core/src/utils/gr_plot_short.py |  7 ++++++-
 9 files changed, 91 insertions(+), 21 deletions(-)

(limited to 'gnuradio-core/src')

diff --git a/gnuradio-core/src/utils/gr_plot_char.py b/gnuradio-core/src/utils/gr_plot_char.py
index d7bde8d00b..71ff4499ae 100755
--- a/gnuradio-core/src/utils/gr_plot_char.py
+++ b/gnuradio-core/src/utils/gr_plot_char.py
@@ -20,7 +20,12 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
+try:
+    import scipy
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
 from gr_plot_data import plot_data
 
diff --git a/gnuradio-core/src/utils/gr_plot_const.py b/gnuradio-core/src/utils/gr_plot_const.py
index 9ec75ddb9a..1503363bd5 100755
--- a/gnuradio-core/src/utils/gr_plot_const.py
+++ b/gnuradio-core/src/utils/gr_plot_const.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -20,9 +20,19 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
-from pylab import *
-from matplotlib.font_manager import fontManager, FontProperties
+try:
+    import scipy
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
+try:
+    from pylab import *
+    from matplotlib.font_manager import fontManager, FontProperties
+except ImportError:
+    print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
 
 matplotlib.interactive(True)
diff --git a/gnuradio-core/src/utils/gr_plot_data.py b/gnuradio-core/src/utils/gr_plot_data.py
index f0c2436bdf..abc210c08a 100755
--- a/gnuradio-core/src/utils/gr_plot_data.py
+++ b/gnuradio-core/src/utils/gr_plot_data.py
@@ -20,8 +20,18 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
-from pylab import *
+try:
+    import scipy
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
+try:
+    from pylab import *
+except ImportError:
+    print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
 
 matplotlib.interactive(True)
diff --git a/gnuradio-core/src/utils/gr_plot_fft_c.py b/gnuradio-core/src/utils/gr_plot_fft_c.py
index af21a8fea1..702840401c 100755
--- a/gnuradio-core/src/utils/gr_plot_fft_c.py
+++ b/gnuradio-core/src/utils/gr_plot_fft_c.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -20,10 +20,20 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
-from pylab import *
+try:
+    import scipy
+    from scipy import fftpack
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
+try:
+    from pylab import *
+except ImportError:
+    print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
-from scipy import fftpack
 from math import log10
 
 matplotlib.interactive(True)
diff --git a/gnuradio-core/src/utils/gr_plot_fft_f.py b/gnuradio-core/src/utils/gr_plot_fft_f.py
index 5825c4ebcf..bb16529140 100755
--- a/gnuradio-core/src/utils/gr_plot_fft_f.py
+++ b/gnuradio-core/src/utils/gr_plot_fft_f.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -20,10 +20,20 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
-from pylab import *
+try:
+    import scipy
+    from scipy import fftpack
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
+try:
+    from pylab import *
+except ImportError:
+    print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
-from scipy import fftpack
 from math import log10
 
 matplotlib.interactive(True)
diff --git a/gnuradio-core/src/utils/gr_plot_float.py b/gnuradio-core/src/utils/gr_plot_float.py
index d49a00594f..248a84b85a 100755
--- a/gnuradio-core/src/utils/gr_plot_float.py
+++ b/gnuradio-core/src/utils/gr_plot_float.py
@@ -20,7 +20,12 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
+try:
+    import scipy
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
 from gr_plot_data import plot_data
 
diff --git a/gnuradio-core/src/utils/gr_plot_int.py b/gnuradio-core/src/utils/gr_plot_int.py
index 3eb36011df..86ecbce7d7 100755
--- a/gnuradio-core/src/utils/gr_plot_int.py
+++ b/gnuradio-core/src/utils/gr_plot_int.py
@@ -20,7 +20,12 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
+try:
+    import scipy
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
 from gr_plot_data import plot_data
 
diff --git a/gnuradio-core/src/utils/gr_plot_iq.py b/gnuradio-core/src/utils/gr_plot_iq.py
index 1752615618..f1f1c10526 100755
--- a/gnuradio-core/src/utils/gr_plot_iq.py
+++ b/gnuradio-core/src/utils/gr_plot_iq.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -20,8 +20,18 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
-from pylab import *
+try:
+    import scipy
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
+try:
+    from pylab import *
+except ImportError:
+    print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
 
 matplotlib.interactive(True)
diff --git a/gnuradio-core/src/utils/gr_plot_short.py b/gnuradio-core/src/utils/gr_plot_short.py
index ea7092b10a..399c0aab9c 100755
--- a/gnuradio-core/src/utils/gr_plot_short.py
+++ b/gnuradio-core/src/utils/gr_plot_short.py
@@ -20,7 +20,12 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-import scipy
+try:
+    import scipy
+except ImportError:
+    print "Please install SciPy to run this script (http://www.scipy.org/)"
+    raise SystemExit, 1
+
 from optparse import OptionParser
 from gr_plot_data import plot_data
 
-- 
cgit v1.2.3