Esempio n. 1
0
def getThumbnailFromCache(link):
    cachePath = getPyShareHomeDirectory() + 'cache/'
    filename = cachePath + md5(link).hexdigest()
    if os.path.exists(filename):
        pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
    else:
        pixbuf = None
    return pixbuf
Esempio n. 2
0
def saveThumbnail(pixbuf, file, link):
    cachePath = getPyShareHomeDirectory() + 'cache/'
    if not os.path.exists(cachePath):
            os.makedirs(cachePath)
    filename = cachePath + md5(link).hexdigest()
    splittedFileName = file.split('.')
    ext = None
    if len(splittedFileName) > 1:
        ext = splittedFileName[-1].lower()
    if(ext=="jpg" or ext=="gif" or (not ext)):
        pixbuf.save(filename, "jpeg")
    else:
        pixbuf.save(filename, ext)
Esempio n. 3
0
def removeFromCache(link):
    cachePath = getPyShareHomeDirectory() + 'cache/'
    filename = cachePath + md5(link).hexdigest()
    if os.path.exists(filename):
        os.remove(filename)