def test_thumbnail_name(self): """Verify thumbnail_name function returns the proper thumbnail filename""" m = hashlib.md5(self.sample_data_file) expected_thumb_name = os.path.join(pathfinder.thumbnails_path(), m.hexdigest() + '.png') self.assertEqual(expected_thumb_name, model.thumbnail_name(self.sample_data_file))
def plot_thumb(self, data_fname, width, height): """Creates (if necessary) and retrieves a matplotlib plot of the specified data file, returning a wx Bitmap or None if the data could not be plotted (e.g. attempting to plot 3D data) """ thumbnail = self.empty_bitmap(width, height) if data_fname: thumb_fname = model.thumbnail_name(data_fname) if not os.path.exists(thumb_fname): # No thumbnail for this file exists, generate thumbnail = model.multiprocess_plot( data_fname, self.view.bitmap_width / 100, self.view.bitmap_height / 100) else: # Thumbnail found, skip generation with open(thumb_fname, 'rb') as img_file: img = wx.Image(img_file, type=wx.BITMAP_TYPE_PNG) thumbnail = wx.Bitmap(img) return thumbnail
def plot_thumb(self, data_fname, width, height): """Creates (if necessary) and retrieves a matplotlib plot of the specified data file, returning a wx Bitmap or None if the data could not be plotted (e.g. attempting to plot 3D data) """ thumbnail = self.empty_bitmap(width, height) if data_fname: thumb_fname = model.thumbnail_name(data_fname) if not os.path.exists(thumb_fname): # No thumbnail for this file exists, generate thumbnail = model.multiprocess_plot(data_fname, self.view.bitmap_width / 100, self.view.bitmap_height / 100) else: # Thumbnail found, skip generation with open(thumb_fname, 'rb') as img_file: img = wx.ImageFromStream(img_file, type=wx.BITMAP_TYPE_PNG) thumbnail = wx.BitmapFromImage(img) return thumbnail
def tearDown(self): if os.path.exists(self.sample_data_file): os.remove(self.sample_data_file) thumbnail_name = model.thumbnail_name(self.sample_data_file) if os.path.exists(thumbnail_name): os.remove(thumbnail_name)