Exemplo n.º 1
0
 def get_thumb(thumb):
     if not thumb:
         return handler.failed(request)
     send_contents(
         gio.File(
             ui.thumbnail_path_for_uri(
                 file.get_uri(), ui.THUMBNAIL_SIZE_NORMAL)))
Exemplo n.º 2
0
def import_thumbnail(filepath):
    uriUTF = "file://" + quote(filepath).encode('utf-8')#quote(path).encode('utf-8')              #change path to utf-8 path
    uri = "file://" + filepath
    import hashlib
    hash = hashlib.md5(uriUTF).hexdigest()
    thumbFactory = ui.ThumbnailFactory(ui.THUMBNAIL_SIZE_NORMAL)
    path = os.path.expanduser('~') + "/.thumbnails/normal/"+hash+".png"
    if path is None or not os.path.exists(path):
        path = ui.thumbnail_path_for_uri(gnomevfs.get_uri_from_local_path(os.path.abspath(uri)), 'normal')
    if path is None or not os.path.exists(path):
        path = thumbFactory.lookup(uri,0)
    if path is None or not os.path.exists(path):
        #create thumbnail
        mimetype, _ = mimetypes.guess_type(uri, strict=False)
        result = create_thumbnail_via_gnome(mimetype, uri)
        if result == False:
            return create_thumbnail(uri, hash, mimetype)
        #TODO prepare for not exist file after create thumbnail
    new_path = copy_file_and_change_path(path, os.path.basename(path))
    return new_path
Exemplo n.º 3
0
 def get_thumb(thumb):
     if not thumb:
         return handler.failed(request)
     send_contents(gio.File(ui.thumbnail_path_for_uri(file.get_uri(), ui.THUMBNAIL_SIZE_NORMAL)))