Пример #1
0
 def test_recreate_broken_cache_file(self):
     thumb = thumbnails.get_thumbnail(self.filename, (50, 60))
     self.assertTrue(thumb)
     path, size = thumbnails.get_cache_info(self.filename, (50, 60))
     open(path, "wb").close()
     thumb = thumbnails.get_thumbnail(self.filename, (50, 60))
     self.assertTrue(thumb)
Пример #2
0
 def test_recreate_broken_cache_file(self):
     thumb = thumbnails.get_thumbnail(self.filename, (50, 60))
     self.assertTrue(thumb)
     path, size = thumbnails.get_cache_info(self.filename, (50, 60))
     open(path, "wb").close()
     thumb = thumbnails.get_thumbnail(self.filename, (50, 60))
     self.assertTrue(thumb)
Пример #3
0
    def __update_image(self):
        height = self.__size
        if not height: return

        if self.__resize:
            height = min(self.__max_size, height)
            width = self.__max_size
        else:
            width = height

        if self.__path is None:
            pixbuf = self.__get_no_cover(width, height)
        else:
            try:
                round_thumbs = config.getboolean("albumart", "round")
                pixbuf = thumbnails.get_thumbnail(self.__path, (width, height))
                pixbuf = thumbnails.add_border(pixbuf, 80, round_thumbs)
            except gobject.GError:
                pixbuf = self.__get_no_cover(width, height)

        self.set_from_pixbuf(pixbuf)
        if self.__resize:
            self.__ignore = True
            self.__sig = self.connect_after("size-allocate",
                self.__stop_ignore)
Пример #4
0
    def test_thumb(s):
        thumb = thumbnails.get_thumbnail(s.filename, (50, 60))

        #check for right scaling
        s.failUnless(thumb)
        s.failUnlessEqual((thumb.get_width(), thumb.get_height()), (50, 3))

        #test the thumbnail filename
        uri = "file://" + urllib.pathname2url(s.filename)
        name = hash.md5(uri).hexdigest() + ".png"
        path = os.path.expanduser("~/.thumbnails")
        # newer spec
        new_path = os.path.expanduser("~/.cache/thumbnails")
        if os.path.exists(new_path):
            path = new_path
        path = os.path.join(path, "normal", name)

        s.failUnless(os.path.isfile(path))

        #check for metadata
        thumb_pb = gtk.gdk.pixbuf_new_from_file(path)
        meta_mtime = thumb_pb.get_option("tEXt::Thumb::MTime")
        meta_uri = thumb_pb.get_option("tEXt::Thumb::URI")

        s.failUnlessEqual(int(meta_mtime), int(mtime(s.filename)))
        s.failUnlessEqual(meta_uri, uri)

        #check rights
        s.failUnlessEqual(os.stat(path).st_mode, 33152)
Пример #5
0
    def test_thumb(s):
        thumb = thumbnails.get_thumbnail(s.filename, (50, 60),
                                         ignore_temp=False)

        #check for right scaling
        s.failUnless(thumb)
        s.failUnlessEqual((thumb.get_width(), thumb.get_height()), (50, 25))

        #test the thumbnail filename
        uri = fsn2uri(s.filename)
        name = hash.md5(uri.encode("ascii")).hexdigest() + ".png"

        path = thumbnails.get_thumbnail_folder()
        path = os.path.join(path, "normal", name)

        s.failUnless(os.path.isfile(path))

        #check for metadata
        thumb_pb = GdkPixbuf.Pixbuf.new_from_file(path)
        meta_mtime = thumb_pb.get_option("tEXt::Thumb::MTime")
        meta_uri = thumb_pb.get_option("tEXt::Thumb::URI")

        s.failUnlessEqual(int(meta_mtime), int(mtime(s.filename)))
        s.failUnlessEqual(meta_uri, uri)

        #check rights
        if os.name != "nt":
            s.failUnlessEqual(os.stat(path).st_mode, 33152)
Пример #6
0
    def test_thumb(s):
        thumb = thumbnails.get_thumbnail(s.filename, (50, 60))

        #check for right scaling
        s.failUnless(thumb)
        s.failUnlessEqual((thumb.get_width(), thumb.get_height()), (50, 3))

        #test the thumbnail filename
        uri = "file://" + pathname2url(s.filename)
        name = hash.md5(uri).hexdigest() + ".png"

        path = thumbnails.get_thumbnail_folder()
        path = os.path.join(path, "normal", name)

        s.failUnless(os.path.isfile(path))

        #check for metadata
        thumb_pb = GdkPixbuf.Pixbuf.new_from_file(path)
        meta_mtime = thumb_pb.get_option("tEXt::Thumb::MTime")
        meta_uri = thumb_pb.get_option("tEXt::Thumb::URI")

        s.failUnlessEqual(int(meta_mtime), int(mtime(s.filename)))
        s.failUnlessEqual(meta_uri, uri)

        #check rights
        if os.name != "nt":
            s.failUnlessEqual(os.stat(path).st_mode, 33152)
Пример #7
0
    def scan_cover(self, force=False):
        if (self.scanned and not force) or not self.songs: return
        self.scanned = True

        song = iter(self.songs).next()
        cover = song.find_cover()

        if cover is not None:
            try:
                round = config.getboolean("albumart", "round")
                self.cover = thumbnails.get_thumbnail(cover.name, (48, 48))
                self.cover = thumbnails.add_border(self.cover, 30, round)
            except gobject.GError:
                return
    def scan_cover(self, force=False):
        if (self.scanned and not force) or not self.songs:
            return
        self.scanned = True

        song = iter(self.songs).next()
        cover = song.find_cover()

        if cover is not None:
            s = self.COVER_SIZE
            try:
                round = config.getboolean("albumart", "round")
                self.cover = thumbnails.get_thumbnail(cover.name, (s, s))
                self.cover = thumbnails.add_border(self.cover, 30, round)
            except GLib.GError:
                return