From 3ad8f8ed993cccae7492bf0fa8519ebe15567101 Mon Sep 17 00:00:00 2001
From: Tom Rondeau
Date: Sat, 15 Jan 2011 17:15:11 -0500
Subject: Fix how the end of a file is handled.

---
 gr-utils/src/python/gr_plot_psd.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'gr-utils/src/python')

diff --git a/gr-utils/src/python/gr_plot_psd.py b/gr-utils/src/python/gr_plot_psd.py
index 0e3dbecd9..b386d35ab 100755
--- a/gr-utils/src/python/gr_plot_psd.py
+++ b/gr-utils/src/python/gr_plot_psd.py
@@ -60,8 +60,10 @@ class gr_plot_psd:
         rcParams['xtick.labelsize'] = self.axis_font_size
         rcParams['ytick.labelsize'] = self.axis_font_size
         
-        self.text_file     = figtext(0.10, 0.95, ("File: %s" % filename), weight="heavy", size=self.text_size)
-        self.text_file_pos = figtext(0.10, 0.92, "File Position: ", weight="heavy", size=self.text_size)
+        self.text_file     = figtext(0.10, 0.95, ("File: %s" % filename),
+                                     weight="heavy", size=self.text_size)
+        self.text_file_pos = figtext(0.10, 0.92, "File Position: ",
+                                     weight="heavy", size=self.text_size)
         self.text_block    = figtext(0.35, 0.92, ("Block Size: %d" % self.block_length),
                                      weight="heavy", size=self.text_size)
         self.text_sr       = figtext(0.60, 0.915, ("Sample Rate: %.2f" % self.sample_rate),
@@ -86,9 +88,9 @@ class gr_plot_psd:
     def get_data(self):
         self.position = self.hfile.tell()/self.sizeof_data
         self.text_file_pos.set_text("File Position: %d" % self.position)
-        self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
-        #print "Read in %d items" % len(self.iq)
-        if(len(self.iq) == 0):
+        try:
+            self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
+        except MemoryError:
             print "End of File"
         else:
             tstep = 1.0 / self.sample_rate
-- 
cgit