def test_disappears(self): filename = os.path.join(self.tempdir, 'mtime_test_disappears') file(filename, 'w').write('foo') invalidator = util.mtime_invalidator(filename) self.assertFalse(invalidator(None)) os.unlink(filename) self.assertTrue(invalidator(None))
def test_invalid(self): filename = os.path.join(self.tempdir, 'mtime_test_future') file(filename, 'w').write('foo') invalidator = util.mtime_invalidator(filename) mtime = os.stat(filename).st_mtime # pretend the file was modified in the future os.utime(filename, (mtime + 10, mtime + 10)) self.assertTrue(invalidator(None))
def make_album_art(self, context): """Make an image to draw as album art. Returns ImageSurface to draw or None if we don't have anything """ if self.get_total_rows() < 6: # don't draw album art if we have less than 6 items in the group return None album_art_path = self.get_image_path() if album_art_path is None: return None return imagepool.get_surface( album_art_path, size=(self.album_art_size, self.album_art_size), invalidator=util.mtime_invalidator(album_art_path))
def make_album_art(self, context): """Make an image to draw as album art. Returns ImageSurface to draw or None if we don't have anything """ if self.get_total_rows() < 6: # don't draw album art if we have less than 6 items in the group return None album_art_path = self.get_image_path() if album_art_path is None: return None return imagepool.get_surface(album_art_path, size=(self.album_art_size, self.album_art_size), invalidator=util.mtime_invalidator( album_art_path))
def test_doesnotexist(self): filename = os.path.join(self.tempdir, 'mtime_test_doesnotexist') invalidator = util.mtime_invalidator(filename) self.assertTrue(invalidator(None))
def test_valid(self): filename = os.path.join(self.tempdir, 'mtime_test') file(filename, 'w').write('foo') invalidator = util.mtime_invalidator(filename) self.assertFalse(invalidator(None))