Exemplo n.º 1
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 = gtk.gdk.pixbuf_new_from_file_at_size(
                     icono, -1, 30)
                 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 = gtk.gdk.pixbuf_new_from_file_at_size(icono, -1, 30)
             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_)
Exemplo n.º 2
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 = gtk.gdk.pixbuf_new_from_file_at_size(
                     icono, -1, 30)
                 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 = gtk.gdk.pixbuf_new_from_file_at_size(icono, -1, 30)
             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_)
Exemplo n.º 3
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):
         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
 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):
         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
Exemplo n.º 5
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

        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_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

        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)
Exemplo n.º 7
0
    def __ejecutar_agregar_elemento(self, elementos):
        """
        Agrega los items a la lista, uno a uno, actualizando.
        """

        if not elementos:
            self.permitir_select = True
            self.seleccionar_primero()
            self.get_toplevel().set_sensitive(True)
            return False

        texto, path = elementos[0]

        from JAMFileSystem import describe_uri
        from JAMFileSystem import describe_archivo

        descripcion = describe_uri(path)

        icono = None
        if descripcion:
            if descripcion[2]:
                # Es un Archivo
                tipo = describe_archivo(path)

                if 'video' in tipo:
                    icono = os.path.join(JAMediaWidgetsBASE,
                        "Iconos", "video.png")

                elif 'audio' in tipo:
                    icono = os.path.join(JAMediaWidgetsBASE,
                        "Iconos", "sonido.png")

                elif 'image' in tipo and not 'iso' in tipo:
                    icono = os.path.join(path)  # exige rendimiento
                    #icono = os.path.join(JAMediaWidgetsBASE,
                    #    "Iconos", "imagen.png")

                elif 'pdf' in tipo:
                    icono = os.path.join(JAMediaWidgetsBASE,
                        "Iconos", "pdf.png")

                elif 'zip' in tipo or 'rar' in tipo:
                    icono = os.path.join(JAMediaWidgetsBASE,
                        "Iconos", "zip.png")

                else:
                    icono = os.path.join(JAMediaWidgetsBASE,
                        "Iconos", "archivo.png")
        else:
            icono = os.path.join(JAMediaWidgetsBASE,
                "Iconos", "archivo.png")

        try:
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono,
                get_pixels(0.8), -1)
            self.modelo.append([pixbuf, texto, path])

        except:
            pass

        elementos.remove(elementos[0])

        gobject.idle_add(self.__ejecutar_agregar_elemento, elementos)

        return False
    def __ejecutar_agregar_elemento(self, elementos):
        """
        Agrega los items a la lista, uno a uno, actualizando.
        """

        if not elementos:
            self.permitir_select = True
            self.seleccionar_primero()
            self.get_toplevel().set_sensitive(True)
            return False

        texto, path = elementos[0]

        from JAMFileSystem import describe_uri
        from JAMFileSystem import describe_archivo

        descripcion = describe_uri(path)

        icono = None
        if descripcion:
            if descripcion[2]:
                # Es un Archivo
                tipo = describe_archivo(path)

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

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

                elif 'image' in tipo and not 'iso' in tipo:
                    icono = os.path.join(path)  # exige rendimiento
                    #icono = os.path.join(JAMediaWidgetsBASE,
                    #    "Iconos", "imagen.png")

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

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

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

        try:
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                icono, get_pixels(0.8), -1)
            self.modelo.append([pixbuf, texto, path])

        except:
            pass

        elementos.remove(elementos[0])

        GLib.idle_add(self.__ejecutar_agregar_elemento, elementos)

        return False