def uri(self, path): g_file_ptr = self.libgio.g_file_new_for_path(path) if not g_file_ptr: raise RuntimeError(u"No gfile pointer received for {0}".format( util.displayable_path(path))) try: uri_ptr = self.libgio.g_file_get_uri(g_file_ptr) finally: self.libgio.g_object_unref(g_file_ptr) if not uri_ptr: self.libgio.g_free(uri_ptr) raise RuntimeError(u"No URI received from the gfile pointer for " u"{0}".format(util.displayable_path(path))) try: uri = copy_c_string(uri_ptr) finally: self.libgio.g_free(uri_ptr) try: return uri.decode(util._fsencoding()) except UnicodeDecodeError: raise RuntimeError( "Could not decode filename from GIO: {!r}".format(uri))
def uri(self, path): g_file_ptr = self.libgio.g_file_new_for_path(path) if not g_file_ptr: raise RuntimeError(u"No gfile pointer received for {0}".format( util.displayable_path(path))) try: uri_ptr = self.libgio.g_file_get_uri(g_file_ptr) except: raise finally: self.libgio.g_object_unref(g_file_ptr) if not uri_ptr: self.libgio.g_free(uri_ptr) raise RuntimeError(u"No URI received from the gfile pointer for " u"{0}".format(util.displayable_path(path))) try: uri = copy_c_string(uri_ptr) except: raise finally: self.libgio.g_free(uri_ptr) try: return uri.decode(util._fsencoding()) except UnicodeDecodeError: raise RuntimeError( "Could not decode filename from GIO: {!r}".format(uri) )
def make_dolphin_cover_thumbnail(self, album): outfilename = os.path.join(album.path, b".directory") if os.path.exists(outfilename): return artfile = os.path.split(album.artpath)[1] with open(outfilename, 'w') as f: f.write(b"[Desktop Entry]\nIcon=./{0}".format(artfile)) f.close() self._log.debug("Wrote file {0}", util.displayable_path(outfilename))
def add_tags(self, album, image_path): """Write required metadata to the thumbnail See http://standards.freedesktop.org/thumbnail-spec/latest/x142.html """ metadata = {"Thumb::URI": self.get_uri(album.artpath), "Thumb::MTime": unicode(os.stat(album.artpath).st_mtime)} try: self.write_metadata(image_path, metadata) except Exception: self._log.exception(u"could not write metadata to {0}", util.displayable_path(image_path))
def make_dolphin_cover_thumbnail(self, album): outfilename = os.path.join(album.path, b".directory") if os.path.exists(outfilename): return artfile = os.path.split(album.artpath)[1] with open(outfilename, 'w') as f: f.write(b"[Desktop Entry]\nIcon=./{0}".format(artfile)) f.close() self._log.debug(u"Wrote file {0}", util.displayable_path(outfilename))
def add_tags(self, album, image_path): """Write required metadata to the thumbnail See http://standards.freedesktop.org/thumbnail-spec/latest/x142.html """ mtime = os.stat(album.artpath).st_mtime metadata = {"Thumb::URI": self.get_uri(album.artpath), "Thumb::MTime": six.text_type(mtime)} try: self.write_metadata(image_path, metadata) except Exception: self._log.exception(u"could not write metadata to {0}", util.displayable_path(image_path))
def uri(self, path): g_file_ptr = self.libgio.g_file_new_for_path(path) if not g_file_ptr: raise RuntimeError("No gfile pointer received for {0}".format( util.displayable_path(path))) try: uri_ptr = self.libgio.g_file_get_uri(g_file_ptr) except: raise finally: self.libgio.g_object_unref(g_file_ptr) if not uri_ptr: self.libgio.g_free(uri_ptr) raise RuntimeError("No URI received from the gfile pointer for " "{0}".format(util.displayable_path(path))) try: uri = ctypes.c_char_p(uri_ptr).value except: raise finally: self.libgio.g_free(uri_ptr) return uri
def uri(self, path): g_file_ptr = self.libgio.g_file_new_for_path(path) if not g_file_ptr: raise RuntimeError(u"No gfile pointer received for {0}".format( util.displayable_path(path))) try: uri_ptr = self.libgio.g_file_get_uri(g_file_ptr) except: raise finally: self.libgio.g_object_unref(g_file_ptr) if not uri_ptr: self.libgio.g_free(uri_ptr) raise RuntimeError(u"No URI received from the gfile pointer for " u"{0}".format(util.displayable_path(path))) try: uri = copy_c_string(uri_ptr) except: raise finally: self.libgio.g_free(uri_ptr) return uri