Exemple #1
0
    def load_previews(self, basepath):
        """
        Crea y carga los previews de imagen de los archivos
        contenidos en basepath.
        """

        imagen_en_path = False

        self.get_toplevel().set_sensitive(False)

        self.path = basepath

        for temp_path in os.listdir(self.path):
            path = os.path.join(self.path, temp_path)

            if not os.access(path, os.R_OK):
                continue

            if os.path.isdir(path):

                for archivo in os.listdir(path):
                    new_path = os.path.join(path, archivo)

                    if os.path.isfile(new_path):
                        descripcion = describe_archivo(new_path)

                        if 'image' in descripcion and not 'iso' in descripcion:
                            try:
                                pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                                    new_path, 200, -1)
                                self.previews.append(
                                    [pixbuf, path.split("/")[-1]])

                                #while Gtk.events_pending():
                                #    Gtk.main_iteration()

                            except:
                                pass

            elif os.path.isfile(path):
                descripcion = describe_archivo(path)

                if 'image' in descripcion and not 'iso' in descripcion:
                    try:
                        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                            path, 200, -1)
                        self.previews.append([pixbuf, path.split("/")[-1]])

                        imagen_en_path = True

                        #while Gtk.events_pending():
                        #    Gtk.main_iteration()

                    except:
                        pass

        self.get_toplevel().set_sensitive(True)
        return imagen_en_path
Exemple #2
0
def get_item_list(path):

    if os.path.exists(path):
        if os.path.isfile(path):
            archivo = os.path.basename(path)

            from JAMediaObjects.JAMFileSystem import describe_archivo

            if 'audio' in describe_archivo(path) or \
                'video' in describe_archivo(path):
                    return [archivo, path]

    return False
Exemple #3
0
    def __get_info(self, widget, path):
        """
        Recibe el path seleccionado en la estructura
        de directorios, obtiene información sobre el mismo
        y la pasa a infowidget para ser mostrada.
        """

        if not path:
            return

        if not os.path.exists(path):
            return

        from JAMediaObjects.JAMFileSystem import get_tamanio
        from JAMediaObjects.JAMFileSystem import describe_archivo
        from JAMediaObjects.JAMFileSystem import describe_uri
        from JAMediaObjects.JAMFileSystem import describe_acceso_uri

        self.toolbar_try.label.set_text(path)

        # FIXME: Falla si se movió y no se actualiza
        unidad, directorio, archivo, enlace = describe_uri(path)
        lectura, escritura, ejecucion = describe_acceso_uri(path)

        texto = ""
        typeinfo = ""

        if enlace:
            texto = "Enlace.\n"

        else:
            if directorio:
                texto = "Directorio.\n"

            elif archivo:
                texto = "Archivo.\n"
                texto += "Tipo:\n"

                for dato in describe_archivo(path).split(";"):
                    texto += "\t%s\n" % (dato.strip())
                    typeinfo += dato

                texto += "Tamaño:\n"
                texto += "\t%s bytes\n" % (get_tamanio(path))

        texto += "Permisos: \n"
        texto += "\tLactura: %s\n" % (lectura)
        texto += "\tEscritura: %s\n" % (escritura)
        texto += "\tEjecución: %s\n" % (ejecucion)

        self.navegador.infowidget.set_info(texto, typeinfo)
def get_item_list(path):

    if os.path.exists(path):
        if os.path.isfile(path):

            from JAMediaObjects.JAMFileSystem import describe_archivo

            archivo = os.path.basename(path)
            datos = describe_archivo(path)

            if 'audio' in datos or \
                'video' in datos or \
                'application/ogg' in datos or \
                'application/octet-stream' in datos:
                    return [archivo, path]

    return False
Exemple #5
0
    def __get_items(self, directorio, tipo):

        if not os.path.exists(directorio) \
            or not os.path.isdir(directorio):
                return []

        items = []

        for archivo in os.listdir(directorio):
            from JAMediaObjects.JAMFileSystem import describe_archivo

            path = os.path.join(directorio, archivo)
            descripcion = describe_archivo(path)

            if tipo in descripcion and not 'iso' in descripcion:
                items.append([archivo, path])

        return items
Exemple #6
0
    def __leer(self, dire):

        archivo = ""

        try:
            directorio = dire[0]
            path = dire[1]

            if path:
                iter_ = self.get_model().get_iter(path)

            else:
                iter_ = self.get_model().get_iter_first()

            archivos = []
            listdir = os.listdir(os.path.join(directorio))
            listdir.sort()

            for archivo in listdir:
                direccion = os.path.join(directorio, archivo)

                if not self.get_parent().get_parent().ver_ocultos:
                    if archivo.startswith('.'):
                        continue

                if os.path.isdir(direccion):
                    icono = None
                    lectura, escritura, ejecucion = describe_acceso_uri(
                        direccion)

                    if not lectura:
                        icono = os.path.join(ICONOS, "button-cancel.svg")

                    else:
                        icono = os.path.join(ICONOS, "document-open.svg")

                    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                        icono, -1, get_pixels(0.8))

                    iteractual = self.get_model().append(
                        iter_, [pixbuf,
                        archivo, direccion, ""])

                    self.__agregar_nada(iteractual)

                elif os.path.isfile(direccion):
                    archivos.append(direccion)

            for x in archivos:
                archivo = os.path.basename(x)
                icono = None
                tipo = describe_archivo(x)

                if 'video' in tipo:
                    icono = os.path.join(ICONOS, "video.svg")

                elif 'audio' in tipo:
                    icono = os.path.join(ICONOS, "sonido.svg")

                elif 'image' in tipo and not 'iso' in tipo:
                    #icono = os.path.join(x) #exige en rendimiento
                    icono = os.path.join(ICONOS, "edit-select-all.svg")

                elif 'pdf' in tipo:
                    icono = os.path.join(ICONOS, "pdf.svg")

                elif 'zip' in tipo or 'rar' in tipo:
                    icono = os.path.join(ICONOS, "edit-select-all.svg")

                else:
                    icono = os.path.join(ICONOS, "edit-select-all.svg")

                pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                    icono, -1, get_pixels(0.8))

                self.get_model().append(
                    iter_, [pixbuf, archivo,
                    x, str(os.path.getsize(x)) + " bytes"])

            self.dict[directorio] = str(listdir)

        except:
            print "**** Error de acceso:", dire, archivo

        iter_ = self.get_model().get_iter_first()

        if iter_:
            self.get_selection().select_iter(iter_)