def inicio(self, particion):
        self.particion = particion
        self.disco = particion[:-1]
        self.num = particion[-1:]

        self.cfg['particion'] = particion
        self.cfg['disco'] = self.disco
        self.cfg['num'] = self.num

        self.p = self.part.lista_particiones(self.disco, self.particion)[0]
        self.particiones = self.part.lista_particiones(self.disco)
        self.ini = self.p[1]
        self.fin = self.p[2]
        self.fs = self.p[5]
        self.cfg['ini'] = self.ini
        self.cfg['fin'] = self.fin

        total = int(self.p[3][:-2])
        usado = gen.kb(self.p[7])
        minimo = gen.kb(self.minimo)
        libre = gen.kb(self.libre)

        self.cur_value = usado + ((total - minimo - usado) / 2)
        if self.barra != None:
            self.barra.inicio(self, total, usado, libre, minimo, self.particion, self.cur_value)
Exemple #2
0
    def inicio(self, particion):
        self.particion = particion
        self.disco = particion[:-1]
        self.num = particion[-1:]

        self.cfg['particion'] = particion
        self.cfg['disco'] = self.disco
        self.cfg['num'] = self.num

        self.p = self.part.lista_particiones(self.disco, self.particion)[0]
        self.particiones = self.part.lista_particiones(self.disco)
        self.ini = self.p[1]
        self.fin = self.p[2]
        self.fs = self.p[5]
        self.cfg['ini'] = self.ini
        self.cfg['fin'] = self.fin

        total = int(self.p[3][:-2])
        usado = gen.kb(self.p[7])
        minimo = gen.kb(self.minimo)
        libre = gen.kb(self.libre)

        self.cur_value = usado + ((total - minimo - usado) / 2)
        if self.barra != None:
            self.barra.inicio(self, total, usado, libre, minimo,
                              self.particion, self.cur_value)
Exemple #3
0
 def __init__(self, cfg, parent):
     self.part_manual = particion_manual.Main(cfg, parent)
     self.particion = cfg['particion']
     self.disco = self.particion[:-1]
     self.num = self.particion[-1:]
     self.ini = cfg['inicio']
     self.fin = cfg['fin']
     self.nuevo_fin = cfg['nuevo_fin']
     self.total = int(gen.kb(self.fin)) - int(gen.kb(self.nuevo_fin))
     self.root_p2 = gen.hum(gen.part_root1(self.total))
     self.root_p3 = gen.hum(gen.part_root2(self.total))
     self.usr = gen.hum(gen.part_root1(self.total))
     self.swap = cfg['swap']
     self.fs = cfg['fs']
     self.par = parent
    def particion_1(self):
        particion_boot = ''
        self.par.accion('Eliminando Particiones')
        gen.desmontar(self.disco)     # Desmonta todas las particiones del disco
        p = self.part.lista_particiones(self.disco)
        print self.ini, self.fin
        if self.vacio == False:
            for s in p:
                num = s[10]
                if s[4].find('swap') > -1:
                    cmd = 'swapoff '.format(s[0])
                    print cmd, commands.getstatusoutput(cmd)
                if num != '':
                    cmd = 'parted -s {0} rm {1}'.format(self.disco, num)
                    print cmd, commands.getstatusoutput(cmd)
            ini = 1049                      # Inicio de la partición
            fin = gen.kb(p[0][9])           # Fin de la partición
        else:
            ini = float(self.ini)           # Inicio de la partición
            fin = float(self.fin)           # Fin de la partición
        disco = self.disco                  # Ruta del disco
        ram = int(gen.ram())                # Cantidad de Ram
        swap = (ram * 2) if ram < 1048576 else ram #tamaño de la swap
        fin_ext  = int(fin)                 # Fin de la partición Extendida
        ini_ext = fin_ext - swap            # Inicio de la partición Extendida
        ini_swap = ini_ext + 32             # Inicio de la partición Swap
        fin_swap = fin_ext                  # Fin de la partición Swap
        ini_root = int(ini)                 # Inicio de la particion Root
        fin_root = ini_ext                  # Fin de la partición Root

        self.par.accion('Creando Particiones')
        self.part.particionar(disco, 'primary', 'ext4', ini_root, fin_root)
        self.part.particionar(disco, 'extended', '', ini_ext, fin_ext)
        self.part.particionar(disco, 'logical', 'linux-swap', ini_swap,fin_swap)

        p = self.part.lista_particiones(self.disco)
        for s in p:
        # vuelvo a listar las particiones para buscar el nombre de cada
        # particion creada
            l = [str(int(float(s[1][:-2].replace(',', '.'))) + 0), \
                str(int(float(s[1][:-2].replace(',', '.'))) + 1), \
                str(int(float(s[1][:-2].replace(',', '.'))) - 1)]

            if str(ini_root) in l:
                self.par.accion('Formateando partición {0} (/) como ext4'\
                .format(s[0]))
                os.system('mkfs.ext4 {0}'.format(s[0]))
                self.particiones_montadas[s[0]] = '/target'
                self.particiones_montadas2[s[0]] = '/target'
                os.system("parted {0} toggle {1} boot".format(s[0][:-1], s[0][-1:]))
                particion_boot=s[0]

            if str(ini_swap) in l:
                self.par.accion('Formateando partición {0} como swap'\
                .format(s[0]))
                os.system('mkswap {0}'.format(s[0]))
                os.system('swapon {0}'.format(s[0]))
        gen.montar(self.particiones_montadas)
        return [self.particiones_montadas2, particion_boot]
    def __init__(self, cfg, parent):
        self.cfg = cfg
        self.metodo = cfg['metodo']
        self.tipo = cfg['tipo']
        self.lista = cfg['lista_manual']
        if (self.metodo == 'todo' or self.metodo == 'vacio') and \
           self.tipo == 'particion_4':
            self.disco = cfg['disco']
        else:
            self.particion = cfg['particion']
            self.disco = self.particion[:-1]
            self.num = int(self.particion[-1:])
            self.ini = int(gen.kb(cfg['inicio']))
            self.fin = int(gen.kb(cfg['fin']))

            print 'Disco: ', cfg['disco']
            if cfg['metodo'] != 'todo' and cfg['metodo'] != 'vacio' :
                self.nuevo_fin = int(gen.kb(cfg['nuevo_fin']))
            print self.nuevo_fin, cfg['nuevo_fin']
            self.fs = cfg['fs']
Exemple #6
0
    def __init__(self, cfg, parent):
        self.cfg = cfg
        self.metodo = cfg['metodo']
        self.tipo = cfg['tipo']
        self.lista = cfg['lista_manual']
        if (self.metodo == 'todo' or self.metodo == 'vacio') and \
           self.tipo == 'particion_4':
            self.disco = cfg['disco']
        else:
            self.particion = cfg['particion']
            self.disco = self.particion[:-1]
            self.num = int(self.particion[-1:])
            self.ini = int(gen.kb(cfg['inicio']))
            self.fin = int(gen.kb(cfg['fin']))

            print 'Disco: ', cfg['disco']
            if cfg['metodo'] != 'todo' and cfg['metodo'] != 'vacio':
                self.nuevo_fin = int(gen.kb(cfg['nuevo_fin']))
            print self.nuevo_fin, cfg['nuevo_fin']
            self.fs = cfg['fs']
    def iniciar(self, data):
        '''
        Inicia el llenado de la tabla
        '''

        self.data = data
        self.lista = []
        self.disco = data['disco'] if data['disco'] != '' \
                     else data['particion'][:-1]

        if data['metodo'] != 'todo' and data['metodo'] != 'vacio':
            self.ini = data['nuevo_fin']
        else:
            self.ini = 1049  # Inicio de la partición

        if str(data['fin'])[-2:] != 'kB':
            data['fin'] = str(data['fin']) + 'kB'

        self.fin = int(float(gen.kb(gen.hum(data['fin']))))

        #TODO: Revisar el por qué de esta sentencia, no asigna ni modifica nada
        float(gen.kb(gen.hum(data['fin']))),
        int(float(gen.kb(gen.hum(data['fin']))))

        if str(data['fin'])[-2:] != 'kB':
            data['fin'] = str(data['fin']) + 'kB'

        self.fin = data['fin']

        if self.tabla != None:

            l_part = particiones.Main().lista_particiones(self.disco)
            for particion in l_part:
                p_disp = particion[0]
                p_ini = particion[1]
                p_fin = particion[2]
                p_tam = particion[3]
                p_format = particion[4]
                p_tipo = particion[5]

                fila = [
                    p_disp,
                    p_tipo + '',
                    p_format + '',
                    '',  # Punto de montaje
                    gen.hum(gen.kb(p_tam)),
                    gen.kb(p_ini),
                    gen.kb(p_fin)
                ]
                self.lista.append(fila)

            self.llenar_tabla(self.lista)
    def iniciar(self, data):
        '''
        Inicia el llenado de la tabla
        '''

        self.data = data
        self.lista = []
        self.disco = data['disco'] if data['disco'] != '' \
                     else data['particion'][:-1]

        if data['metodo'] != 'todo' and data['metodo'] != 'vacio':
            self.ini = data['nuevo_fin']
        else:
            self.ini = 1049                            # Inicio de la partición

        if str(data['fin'])[-2:] != 'kB':
            data['fin'] = str(data['fin']) + 'kB'

        self.fin = int(float(gen.kb(gen.hum(data['fin']))))

        #TODO: Revisar el por qué de esta sentencia, no asigna ni modifica nada
        float(gen.kb(gen.hum(data['fin']))),
        int(float(gen.kb(gen.hum(data['fin']))))

        if str(data['fin'])[-2:] != 'kB':
            data['fin'] = str(data['fin']) + 'kB'

        self.fin = data['fin']

        if self.tabla != None:

            l_part = particiones.Main().lista_particiones(self.disco)
            for particion in l_part:
                p_disp = particion[0]
                p_ini = particion[1]
                p_fin = particion[2]
                p_tam = particion[3]
                p_format = particion[4]
                p_tipo = particion[5]

                fila = [
                       p_disp,
                       p_tipo + '',
                       p_format + '',
                       '', # Punto de montaje
                       gen.hum(gen.kb(p_tam)),
                       gen.kb(p_ini),
                       gen.kb(p_fin)
                   ]
                self.lista.append(fila)

            self.llenar_tabla(self.lista)
 def todo(self, vacio):
     p = self.part.lista_particiones(self.disco)
     self.ini = 1049                          # Inicio de la partición
     if self.cfg['fin'][-2:] != 'kB':
         self.cfg['fin'] = self.cfg['fin'] + 'kB'
     self.fin = int(float(gen.kb(self.cfg['fin'])))
     gen.desmontar(self.disco)
     if vacio == False:
         for s in p:
             num = s[10]
             if s[4].find('swap') > -1:
                 cmd = 'swapoff '.format(s[0])
                 print cmd, commands.getstatusoutput(cmd)
                 cmd = 'parted -s {0} rm {1}'.format(self.disco, num)
                 print cmd, commands.getstatusoutput(cmd)
             if num != '':
                 cmd = 'parted -s {0} rm {1}'.format(self.disco, num)
                 print cmd, commands.getstatusoutput(cmd)
     salida = self.particionar()
     return salida
Exemple #10
0
 def todo(self, vacio):
     p = self.part.lista_particiones(self.disco)
     self.ini = 1049  # Inicio de la partición
     if self.cfg['fin'][-2:] != 'kB':
         self.cfg['fin'] = self.cfg['fin'] + 'kB'
     self.fin = int(float(gen.kb(self.cfg['fin'])))
     gen.desmontar(self.disco)
     if vacio == False:
         for s in p:
             num = s[10]
             if s[4].find('swap') > -1:
                 cmd = 'swapoff '.format(s[0])
                 print cmd, commands.getstatusoutput(cmd)
                 cmd = 'parted -s {0} rm {1}'.format(self.disco, num)
                 print cmd, commands.getstatusoutput(cmd)
             if num != '':
                 cmd = 'parted -s {0} rm {1}'.format(self.disco, num)
                 print cmd, commands.getstatusoutput(cmd)
     salida = self.particionar()
     return salida
Exemple #11
0
    def __init__(self, particion):
        gtk.Fixed.__init__(self)

        self.inicio(particion)
        #        self.particion = particion
        #        self.disco = particion[:-1]
        #        self.num = particion[-1:]

        #        self.cfg['particion'] = particion
        #        self.cfg['disco'] = self.disco
        #        self.cfg['num'] = self.num

        #        p = self.part.lista_particiones(self.disco, self.particion)[0]
        #        self.particiones = self.part.lista_particiones(self.disco)
        #        self.ini = p[1]
        #        self.fin = p[2]
        #        self.fs = p[5]
        #        self.cfg['ini'] = self.ini
        #        self.cfg['fin'] = self.fin

        txt_info = "Seleccione el tamaño que desea usar para la instalación"
        self.lbl1 = gtk.Label(txt_info)
        self.lbl1.set_size_request(590, 20)
        self.lbl1.set_justify(gtk.JUSTIFY_CENTER)
        self.put(self.lbl1, 0, 0)
        self.lbl1.show()

        # Barra
        total = int(self.p[3][:-2])
        usado = gen.kb(self.p[7])
        minimo = gen.kb(self.minimo)
        libre = gen.kb(self.libre)
        self.swap = self.hay_swap()

        self.barra = widget.Barra(self, total, usado, libre, minimo, particion,
                                  self.cur_value)
        self.barra.set_size_request(590, 60)
        self.barra.show()
        self.put(self.barra, 0, 25)

        self.leyenda = leyenda.Main(self)
        self.leyenda.set_size_request(20, 100)
        self.put(self.leyenda, 0, 90)
        self.leyenda.show()

        # Etiqueta Información Espacio Usado
        msg = 'Espacio Usado en la partición'
        self.lbl_usado = gtk.Label('{0} ({1})'.format(msg, gen.hum(usado)))
        self.lbl_usado.set_size_request(590, 20)
        self.lbl_usado.set_alignment(0, 0)
        self.put(self.lbl_usado, 22, 90)
        self.lbl_usado.show()

        # Etiqueta Información Espacio Libre
        self.lbl_otra = gtk.Label('')
        self.lbl_otra.set_size_request(590, 20)
        self.lbl_otra.set_alignment(0, 0)
        self.put(self.lbl_otra, 22, 115)
        self.lbl_otra.show()

        # Etiqueta Información Instalación canaima
        self.lbl_canaima = gtk.Label('')
        self.lbl_canaima.set_size_request(590, 20)
        self.lbl_canaima.set_alignment(0, 0)
        self.put(self.lbl_canaima, 22, 140)
        self.lbl_canaima.show()

        # Etiqueta Información Espacio mínimo
        msg = 'Espacio mínimo requerido para instalar Canaima GNU/Linux'
        self.lbl_minimo = gtk.Label('{0} ({1})'.format(msg,
                                                       gen.hum(self.minimo)))
        self.lbl_minimo.set_size_request(590, 20)
        self.lbl_minimo.set_alignment(0, 0)
        self.put(self.lbl_minimo, 22, 165)
        self.lbl_minimo.show()

        # Opciones
        button = gtk.RadioButton(
            None, "Realizar la instalación en una sola partición")
        button.connect("toggled", self.RadioButton_on_changed, "particion_1")
        button.set_size_request(590, 20)
        button.set_active(True)
        self.put(button, 0, 190)
        button.show()

        button = gtk.RadioButton(button,
                                 "Separar la partición /home (Recomendado)")
        button.connect("toggled", self.RadioButton_on_changed, "particion_2")
        button.set_size_request(590, 20)
        self.put(button, 0, 210)
        button.show()

        button = gtk.RadioButton(
            button, "Separar las particiones /home, /usr y /boot")
        button.connect("toggled", self.RadioButton_on_changed, "particion_3")
        button.set_size_request(590, 20)
        self.put(button, 0, 230)
        button.show()

        button = gtk.RadioButton(button, "Particionar Manualmente")
        button.connect("toggled", self.RadioButton_on_changed, "particion_4")
        button.set_size_request(590, 20)
        self.put(button, 0, 250)
        button.show()

        if self.swap != False:
            # Etiqueta Información Swap
            msg = 'Se usará la partición Swap Existente'
            self.lbl_usado = gtk.Label('{0}'.format(msg))
            self.lbl_usado.set_size_request(590, 20)
            self.lbl_usado.set_alignment(1, 0)
            self.put(self.lbl_usado, 0, 265)
            self.lbl_usado.show()
    def deshacer(self, widget=None):
        if self.lista[0][1] == 'Espacio Libre':
            return False
        if self.lista[-1][1] == 'Espacio Libre':
            self.lista.pop()
        if self.lista[-1][1] == 'Espacio Libre Extendida':
            self.lista.pop()
        if self.lista[-1][1] == 'Lógica':
            self.bext = True
        else:
            self.bext = False

        tipo = self.lista[-1][1]
        fin = self.lista[-1][6]

        self.lista.pop()

        if tipo == 'Extendida':
            inicio = self.ext_ini
            fin = self.ext_fin
        elif tipo == 'Lógica' and self.bext == True:
            if self.lista[-1][1] == 'Extendida':
                inicio = self.lista[-1][5]
            else:
                inicio = self.lista[-1][6]
            fin = self.ext_fin
        elif tipo == 'Primaria':
            try:
                inicio = self.lista[-1][6]
            except:
                inicio = gen.kb(self.ini)
            fin = gen.kb(self.fin)

        if self.bext == True:
            tamano = gen.hum(fin - inicio)
            particion = [self.disco, #Dispositivo
                         'Espacio Libre Extendida', #Formato
                         '', #Tipo
                         '', #Punto de montaje
                         tamano, #Tamaño
                         inicio, #inicio
                         fin]                       #fin
            self.lista.append(particion)


        if fin != self.fin:
            try:
                inicio = self.lista[-1][6]
            except:
                inicio = gen.kb(self.ini)
            fin = gen.kb(self.fin)
            tamano = gen.hum(fin - inicio)
            particion = [self.disco, #Dispositivo
                         'Espacio Libre', #Formato
                         '', #Tipo
                         '', #Punto de montaje
                         tamano, #Tamaño
                         inicio, #inicio
                         fin]               #fin
            self.lista.append(particion)

        self.llenar_tabla(self.lista)
Exemple #13
0
    def particion_2(self):
        particion_boot = ''
        self.par.accion('Eliminando Particiones')
        gen.desmontar(self.disco)  # Desmonta todas las particiones del disco
        p = self.part.lista_particiones(self.disco)
        if self.vacio == False:
            ini = 1049  # Inicio de la partición
            fin = gen.kb(p[0][9])  # Fin de la partición
            for s in p:
                num = s[10]
                if s[4].find('swap') > -1:
                    cmd = 'swapoff '.format(s[0])
                    print cmd, commands.getstatusoutput(cmd)
                if num != '':
                    cmd = 'parted -s {0} rm {1}'.format(self.disco, num)
                    print cmd, commands.getstatusoutput(cmd)
        else:
            ini = float(self.ini)  # Inicio de la partición
            fin = float(self.fin)  # Fin de la partición
        disco = self.disco  # Ruta del disco
        ram = int(gen.ram())  # Cantidad de Ram
        swap = (ram * 2) if ram < 1048576 else ram  #tamaño de la swap
        ini_root = int(ini)  # Inicio de la particion Root
        fin_root = ini_root + int(gen.kb(
            self.root_p2))  #Fin de la partición Root
        ini_ext = (int(fin_root) + 32)  # Inicio de la partición Extendida
        fin_ext = (int(fin))  # Fin de la partición Extendida
        ini_home = ini_ext + 32  # Inicio de la partición Home
        fin_home = fin_ext - swap  # Fin de la partición Home
        ini_swap = fin_ext - swap + 32  # Inicio de la partición Swap
        fin_swap = fin_ext  # Fin de la partición Swap

        self.par.accion('Creando Particiones')
        self.part.particionar(disco, 'primary', 'ext4', ini_root, fin_root)
        self.part.particionar(disco, 'extended', '', ini_ext, fin_ext)
        self.part.particionar(disco, 'logical', 'ext4', ini_home, fin_home)
        self.part.particionar(disco, 'logical', 'linux-swap', ini_swap,
                              fin_swap)

        p = self.part.lista_particiones(disco)
        for s in p:
            # vuelvo a listar las particiones para buscar el nombre de cada
            # particion creada
            l = [str(int(float(s[1][:-2].replace(',', '.'))) + 0), \
                str(int(float(s[1][:-2].replace(',', '.'))) + 1), \
                str(int(float(s[1][:-2].replace(',', '.'))) - 1)]
            print ini_root, ini_home, ini_swap, l

            if str(ini_root) in l:
                self.par.accion('Formateando partición {0} como ext4'\
                .format(s[0]))
                os.system('mkfs.ext4 {0}'.format(s[0]))
                self.particiones_montadas[s[0]] = '/target'
                self.particiones_montadas2[s[0]] = '/target'
                os.system("parted {0} toggle {1} boot".format(
                    s[0][:-1], s[0][-1:]))
                particion_boot = s[0]

            if str(ini_home) in l:
                self.par.accion('Formateando partición {0} como ext4'\
                .format(s[0]))
                os.system('mkfs.ext4 {0}'.format(s[0]))
                self.particiones_montadas[s[0]] = '/target/home'
                self.particiones_montadas2[s[0]] = '/target/home'

            if str(ini_swap) in l:
                self.par.accion('Formateando partición {0} como swap'\
                .format(s[0]))
                os.system('mkswap {0}'.format(s[0]))
                os.system('swapon {0}'.format(s[0]))
        gen.montar(self.particiones_montadas)
        return [self.particiones_montadas2, particion_boot]
Exemple #14
0
    def particion_1(self):
        particion_boot = ''
        ini = int(gen.kb(self.ini))        # Inicio de la partición
        fin = int(gen.kb(self.fin))        # Fin de la partición
        swap = self.swap            # existe o no una partición swap en el disco
        fs = self.fs                       # Sistema de Archivos de la partición
        particion = self.particion         # Ruta de la partición
        disco = self.disco                 # Ruta del disco
        num = self.num                     # número de la partición
        ram = int(gen.ram())               # Cantidad de Ram
        ini_win = int(ini)                 # Inicio de la partición con windows
        fin_win = int(self.nuevo_fin)      # Fin de la partición con windows
        ini_root = fin_win + ini_win + 32  # Inicio de la particion Root
        if swap == True:               # Si existe una partición Swap
            fin_root = fin                 # Fin de la partición Root
        else:                          # Si no existe una partición Swap
            swap = (ram * 2) if ram < 1048576 else ram #tamaño de la swap
            ini_ext = fin - swap           # Inicio de la partición Extendida
            fin_ext  = fin                 # Fin de la partición Extendida
            ini_swap = ini_ext + 32        # Inicio de la partición Swap
            fin_swap = fin_ext             # Fin de la partición Swap
            fin_root = ini_ext             # Fin de la partición Root
            swap = False
        self.par.accion('Desmontando dispositivo')
        os.system('umount -l {0}'.format(self.particion) )
        self.par.accion('redimensionando partición {0}'.format(self.particion))
        print "fs: " + fs
        if fs == 'ntfs': # Redimensiono la particion si es NTFS
            cmd = 'echo y | ntfsresize -P --force {0} -s {1}k'.\
                format(particion, fin_win)
            print cmd, commands.getstatusoutput(cmd)
            cmd = 'parted -s {0} rm {1}'.format(disco, num)
            print cmd, commands.getstatusoutput(cmd)
            cmd = 'parted -s {0} mkpart primary NTFS {1}k {2}k'.\
                format(disco, ini_win, fin_win + ini_win)
            print cmd, commands.getstatusoutput(cmd)
        elif fs == 'fat32' or fs == 'ext3': # Redimensiono la partición si es FAT32 o EXT3
            cmd = 'parted -s {0} resize {1} {2}k {3}k'.\
                format(disco, num, ini_win, fin_win + ini_win)
            print cmd
            commands.getstatusoutput(cmd)
            #commands.getstatusoutput(cmd)
        self.par.accion('Creando Particiones')
        self.part.particionar(disco, 'primary', 'ext4', ini_root, fin_root)
        if swap == False:
            self.part.particionar(disco, 'extended', '', ini_ext, fin_ext)
            self.part.particionar(disco, 'logical', 'linux-swap', ini_swap,\
                fin_swap)

        p = self.part.lista_particiones(disco)
        for s in p:
        # vuelvo a listar las particiones para buscar el nombre de cada
        # particion creada
            l = [s[1][:-2], \
                str(int(float(s[1][:-2].replace(',', '.'))) + 1), \
                str(int(float(s[1][:-2].replace(',', '.'))) - 1)]

            if str(ini_root) in l:
                self.par.accion('Formateando partición {0} como ext4'. \
                    format(s[0]))
                os.system('mkfs.ext4 {0}'.format(s[0]))
                self.particiones_montadas[s[0]] = '/target'
                self.particiones_montadas2[s[0]] = '/target'
                os.system("parted {0} toggle {1} boot".format(s[0][:-1], s[0][-1:]))
                particion_boot=s[0]

            if swap == False:
                if str(ini_swap) in l:
                    self.par.accion('Formateando partición {0} como swap'. \
                        format(s[0]))
                    os.system('mkswap {0}'.format(s[0]))
                    os.system('swapon {0}'.format(s[0]))
        gen.montar(self.particiones_montadas)
        return [self.particiones_montadas2, particion_boot]
    def deshacer(self, widget=None):
        if self.lista[0][1] == 'Espacio Libre':
            return False
        if self.lista[-1][1] == 'Espacio Libre':
            self.lista.pop()
        if self.lista[-1][1] == 'Espacio Libre Extendida':
            self.lista.pop()
        if self.lista[-1][1] == 'Lógica':
            self.bext = True
        else:
            self.bext = False

        tipo = self.lista[-1][1]
        fin = self.lista[-1][6]

        self.lista.pop()

        if tipo == 'Extendida':
            inicio = self.ext_ini
            fin = self.ext_fin
        elif tipo == 'Lógica' and self.bext == True:
            if self.lista[-1][1] == 'Extendida':
                inicio = self.lista[-1][5]
            else:
                inicio = self.lista[-1][6]
            fin = self.ext_fin
        elif tipo == 'Primaria':
            try:
                inicio = self.lista[-1][6]
            except:
                inicio = gen.kb(self.ini)
            fin = gen.kb(self.fin)

        if self.bext == True:
            tamano = gen.hum(fin - inicio)
            particion = [
                self.disco,  #Dispositivo
                'Espacio Libre Extendida',  #Formato
                '',  #Tipo
                '',  #Punto de montaje
                tamano,  #Tamaño
                inicio,  #inicio
                fin
            ]  #fin
            self.lista.append(particion)

        if fin != self.fin:
            try:
                inicio = self.lista[-1][6]
            except:
                inicio = gen.kb(self.ini)
            fin = gen.kb(self.fin)
            tamano = gen.hum(fin - inicio)
            particion = [
                self.disco,  #Dispositivo
                'Espacio Libre',  #Formato
                '',  #Tipo
                '',  #Punto de montaje
                tamano,  #Tamaño
                inicio,  #inicio
                fin
            ]  #fin
            self.lista.append(particion)

        self.llenar_tabla(self.lista)
    def __init__(self, particion):
        gtk.Fixed.__init__(self)

        self.inicio(particion)
#        self.particion = particion
#        self.disco = particion[:-1]
#        self.num = particion[-1:]

#        self.cfg['particion'] = particion
#        self.cfg['disco'] = self.disco
#        self.cfg['num'] = self.num

#        p = self.part.lista_particiones(self.disco, self.particion)[0]
#        self.particiones = self.part.lista_particiones(self.disco)
#        self.ini = p[1]
#        self.fin = p[2]
#        self.fs = p[5]
#        self.cfg['ini'] = self.ini
#        self.cfg['fin'] = self.fin

        txt_info = "Seleccione el tamaño que desea usar para la instalación"
        self.lbl1 = gtk.Label(txt_info)
        self.lbl1.set_size_request(590, 20)
        self.lbl1.set_justify(gtk.JUSTIFY_CENTER)
        self.put(self.lbl1, 0, 0)
        self.lbl1.show()

        # Barra
        total = int(self.p[3][:-2])
        usado = gen.kb(self.p[7])
        minimo = gen.kb(self.minimo)
        libre = gen.kb(self.libre)
        self.swap = self.hay_swap()

        self.barra = widget.Barra(self, total, usado, libre, minimo, particion, self.cur_value)
        self.barra.set_size_request(590, 60)
        self.barra.show()
        self.put(self.barra, 0, 25)

        self.leyenda = leyenda.Main(self)
        self.leyenda.set_size_request(20, 100)
        self.put(self.leyenda, 0, 90)
        self.leyenda.show()

        # Etiqueta Información Espacio Usado
        msg = 'Espacio Usado en la partición'
        self.lbl_usado = gtk.Label('{0} ({1})'.format(msg, gen.hum(usado)))
        self.lbl_usado.set_size_request(590, 20)
        self.lbl_usado.set_alignment(0, 0)
        self.put(self.lbl_usado, 22, 90)
        self.lbl_usado.show()

        # Etiqueta Información Espacio Libre
        self.lbl_otra = gtk.Label('')
        self.lbl_otra.set_size_request(590, 20)
        self.lbl_otra.set_alignment(0, 0)
        self.put(self.lbl_otra, 22, 115)
        self.lbl_otra.show()

        # Etiqueta Información Instalación canaima
        self.lbl_canaima = gtk.Label('')
        self.lbl_canaima.set_size_request(590, 20)
        self.lbl_canaima.set_alignment(0, 0)
        self.put(self.lbl_canaima, 22, 140)
        self.lbl_canaima.show()

        # Etiqueta Información Espacio mínimo
        msg = 'Espacio mínimo requerido para instalar Canaima GNU/Linux'
        self.lbl_minimo = gtk.Label('{0} ({1})'.format(msg, gen.hum(self.minimo)))
        self.lbl_minimo.set_size_request(590, 20)
        self.lbl_minimo.set_alignment(0, 0)
        self.put(self.lbl_minimo, 22, 165)
        self.lbl_minimo.show()

        # Opciones
        button = gtk.RadioButton(None,
            "Realizar la instalación en una sola partición")
        button.connect("toggled", self.RadioButton_on_changed, "particion_1")
        button.set_size_request(590, 20)
        button.set_active(True)
        self.put(button, 0, 190)
        button.show()

        button = gtk.RadioButton(button,
            "Separar la partición /home (Recomendado)")
        button.connect("toggled", self.RadioButton_on_changed, "particion_2")
        button.set_size_request(590, 20)
        self.put(button, 0, 210)
        button.show()

        button = gtk.RadioButton(button,
            "Separar las particiones /home, /usr y /boot")
        button.connect("toggled", self.RadioButton_on_changed, "particion_3")
        button.set_size_request(590, 20)
        self.put(button, 0, 230)
        button.show()

        button = gtk.RadioButton(button,
            "Particionar Manualmente")
        button.connect("toggled", self.RadioButton_on_changed, "particion_4")
        button.set_size_request(590, 20)
        self.put(button, 0, 250)
        button.show()

        if self.swap != False:
            # Etiqueta Información Swap
            msg = 'Se usará la partición Swap Existente'
            self.lbl_usado = gtk.Label('{0}'.format(msg))
            self.lbl_usado.set_size_request(590, 20)
            self.lbl_usado.set_alignment(1, 0)
            self.put(self.lbl_usado, 0, 265)
            self.lbl_usado.show()
    def __init__(self, padre):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        gtk.Window.set_position(self, gtk.WIN_POS_CENTER_ALWAYS)
        self.set_title("Nueva Partición")
        self.padre = padre
        self.set_size_request(400, 200)
        self.set_resizable(0)
        self.set_border_width(0)

        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        self.set_default_response(gtk.RESPONSE_CANCEL)

        if self.padre.bext == False:
            self.inicio = gen.kb(self.padre.lista[-1][5])
            self.fin = gen.kb(self.padre.fin)
        else:
            self.inicio = gen.kb(self.padre.ext_ini)
            self.fin = gen.kb(self.padre.ext_fin)

        # Contenedor General
        self.cont = gtk.Fixed()
        self.cont.show()
        self.vbox.pack_start(self.cont)

        #Tamaño de la partición
        self.lbl = gtk.Label('Tamaño')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.lbl.show()
        self.cont.put(self.lbl, 5, 5)
        adj = gtk.Adjustment(float(self.fin), float(self.inicio),
                             float(self.fin), 1.0, 5.0, 0.0)
        self.escala = gtk.HScale()
        self.escala.set_draw_value(False)
        self.escala.set_adjustment(adj)
        self.escala.set_property('value-pos', gtk.POS_RIGHT)
        self.escala.set_size_request(250, 30)
        self.escala.connect("value-changed", self.on_changed)
        self.cont.put(self.escala, 60, 5)
        self.escala.show()
        self.lblsize = gtk.Label(gen.hum(self.escala.get_value() - \
                                 float(self.inicio)))
        self.lblsize.set_alignment(0, 0.5)
        self.lblsize.set_size_request(100, 30)
        self.lblsize.show()
        self.cont.put(self.lblsize, 320, 5)

        #Tipo de partición
        self.lbl = gtk.Label('Tipo de partición')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.cont.put(self.lbl, 5, 35)
        self.lbl.show()

        self.cmb_tipo = gtk.combo_box_new_text()
        self.cmb_tipo.set_size_request(100, 30)
        self.cont.put(self.cmb_tipo, 145, 35)
        if padre.bext == True:
            self.cmb_tipo.append_text('Lógica')
            self.cmb_tipo.set_sensitive(False)
        else:
            #if self.padre.primarias < 4:
            self.cmb_tipo.append_text('Primaria')
            self.cmb_tipo.append_text('Extendida')
        self.cmb_tipo.set_active(0)
        self.cmb_tipo.connect("changed", self.cmb_tipo_on_changed)
        self.cmb_tipo.show()

        #Sistema de Archivos
        self.lbl = gtk.Label('Sistema de Archivos')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.lbl.show()
        self.cont.put(self.lbl, 5, 65)
        self.cmb_fs = gtk.combo_box_new_text()
        self.cmb_fs.set_size_request(100, 30)
        self.cont.put(self.cmb_fs, 145, 65)
        self.cmb_fs.append_text('ext2')
        self.cmb_fs.append_text('ext3')
        self.cmb_fs.append_text('ext4')
        self.cmb_fs.append_text('linux-swap')
        self.cmb_fs.append_text('reiserfs')
        self.cmb_fs.append_text('fat16')
        self.cmb_fs.append_text('fat32')
        self.cmb_fs.set_active(2)
        self.cmb_fs.connect("changed", self.cmb_fs_on_changed)
        self.cmb_fs.show()

        # Punto de Montaje
        self.lbl = gtk.Label('Punto de Montaje')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.cont.put(self.lbl, 5, 95)
        self.lbl.show()

        self.cmb_montaje = gtk.combo_box_new_text()
        self.cmb_montaje.set_size_request(200, 30)
        self.cont.put(self.cmb_montaje, 145, 95)
        self.agregar('/')
        self.agregar('/boot')
        self.agregar('/home')
        self.agregar('/tmp')
        self.agregar('/usr')
        self.agregar('/var')
        self.agregar('/srv')
        self.agregar('/opt')
        self.agregar('/usr/local')
        self.cmb_montaje.append_text('Ninguno')
        self.cmb_montaje.append_text('Escoger manualmente')
        self.cmb_montaje.set_active(0)
        self.cmb_montaje.connect("changed", self.cmb_montaje_on_changed)
        self.cmb_montaje.show()

        self.entrada = gtk.Entry()
        self.entrada.set_text('/')
        self.entrada.set_size_request(200, 30)
        self.cont.put(self.entrada, 145, 125)
        self.entrada.connect("changed", self.validar_punto)

        response = self.run()

        if response == gtk.RESPONSE_OK:
            tipo = gen.get_active_text(self.cmb_tipo)
            formato = gen.get_active_text(self.cmb_fs)
            montaje = gen.get_active_text(self.cmb_montaje)
            if tipo == 'Extendida':
                formato = 'Ninguno'
                montaje = 'Ninguno'
            if formato == 'linux-swap':
                montaje = 'Ninguno'
            if montaje == 'Escoger manualmente':
                montaje = self.entrada.get_text().strip()

            if self.padre.lista[-1][1] == 'Espacio Libre':
                self.padre.lista.pop()
            if len(self.padre.lista) > 0:
                if self.padre.lista[-1][1] == 'Espacio Libre Extendida':
                    self.padre.lista.pop()

            # Si la partición nueva es Primaria
            if tipo == 'Primaria':
                # Calculo el tamaño
                inicio = int(self.inicio)
                fin = int(self.escala.get_value())
                tamano = gen.hum(fin - inicio)
                # Elimina ultimo elemento de la lista
                #self.padre.lista.pop()
                # Se crea elemento particion primaria y se agrega a la lista
                particion = [
                    self.padre.disco,  #Dispositivo
                    tipo,  #Tipo
                    formato,  #Formato
                    montaje,  #Punto de montaje
                    tamano,  #Tamaño
                    inicio,  #inicio
                    fin
                ]  #fin
                self.padre.lista.append(particion)
            # Si la partición nueva es Extendida
            elif tipo == 'Extendida':
                # Calculo el tamaño
                inicio = int(self.inicio)
                fin = int(self.escala.get_value())
                tamano = gen.hum(fin - inicio)
                # Cambia variable bext a True
                self.padre.bext = True
                # Establece las variables ext_ini y ext_fin
                self.padre.ext_ini = inicio
                self.padre.ext_fin = fin
                # Elimina ultimo elemento de la lista
                #self.padre.lista.pop()
                # Se crea elemento particion extendida y se agrega a la lista
                particion = [
                    self.padre.disco,  #Dispositivo
                    tipo,  #Tipo
                    '',  #formato,     #Formato
                    montaje,  #Punto de montaje
                    tamano,  #Tamaño
                    inicio,  #inicio
                    fin
                ]  #fin
                self.padre.lista.append(particion)
                # Se crea elemento espacio libre en partición extendida
                particion = [
                    '',  #self.padre.disco,                      #Dispositivo
                    'Espacio Libre Extendida',  #Tipo
                    '',  #self.get_active_text(self.cmb_fs),     #Formato
                    '',  #self.get_active_text(self.cmb_montaje),#Punto de montaje
                    tamano,  #Tamaño
                    inicio,  #inicio
                    fin
                ]  #fin
                self.padre.lista.append(particion)
            # Si la partición nueva es Lógica
            elif tipo == 'Lógica':
                # Calculo el tamaño
                inicio = int(self.padre.ext_ini)
                fin = int(self.escala.get_value())
                tamano = gen.hum(fin - inicio)
                # Elimina los dos ultimos elementos de la lista
                #self.padre.lista.pop()
                #self.padre.lista.pop()
                # Se crea elemento particion lógica y se agrega a la lista
                particion = [
                    self.padre.disco,  #Dispositivo
                    tipo,  #Tipo
                    formato,  #Formato
                    montaje,  #Punto de montaje
                    tamano,  #Tamaño
                    inicio,  #inicio
                    fin
                ]  #fin
                self.padre.lista.append(particion)
                # Si self.padre.ext_fin != fin entonces
                if self.padre.ext_fin == fin:
                    # No se crea elemento espacio libre en partición extendida
                    # Cambia variable bext a False
                    self.padre.bext = False
                # Si no
                else:
                    # se calcula el tamaño de la partición libre
                    ext_ini = fin
                    ext_fin = self.padre.ext_fin
                    tamano = gen.hum(ext_fin - ext_ini)
                    self.padre.ext_ini = ext_ini
                    # Se crea elemento espacio libre en partición extendida
                    particion = [
                        '',  #self.padre.disco,                      #Dispositivo
                        'Espacio Libre Extendida',  #Tipo
                        '',  #self.get_active_text(self.cmb_fs),     #Formato
                        '',  #self.get_active_text(self.cmb_montaje),#Punto de montaje
                        tamano,  #Tamaño
                        ext_ini,  #inicio
                        ext_fin
                    ]  #fin
                    self.padre.lista.append(particion)

            # Calculamos el tamaño de la partición libre
            # si bext == True entonces se usará ext_fin como fin
            if self.padre.bext == True:
                fin = self.padre.ext_fin
            #print 'Inicio:', inicio, 'fin:', fin, "self.fin", int(self.fin)
            # Si fin == self.fin entonces
            if fin == int(gen.kb(self.padre.fin)):
                pass
                # No se crea elemento espacio libre
                #print "No crea la elemento espacio libre"
            # Si no
            else:
                #print "Crea elemento espacio libre"
                # se calcula el tamaño de la partición libre
                inicio = fin
                fin = int(gen.kb(self.padre.fin))
                tamano = gen.hum(fin - inicio)
                # Se crea elemento espacio libre
                libre = [
                    '',  #Dispositivo
                    'Espacio Libre',  #Tipo
                    '',  #Formato
                    '',  #Punto de montaje
                    tamano,  #Tamaño
                    inicio,  #inicio
                    fin
                ]  #fin
                self.padre.lista.append(libre)
            # Se actualiza la tabla
            self.padre.llenar_tabla(self.padre.lista)

        else:
            pass

        self.destroy()
        return None
    def expose(self, widget=None, event=None):
        cr = self.window.cairo_create()
        cr.set_line_width(0.8)

        cr.select_font_face("Courier", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
        cr.set_font_size(11)

        ancho = self.get_size_request()[0]
        alto = self.get_size_request()[1]

        w_swap = ((self.swap * ancho) / self.total) - 1
        x_swap = ancho - w_swap + 1

        cr.set_source_rgb(1.0, 1.0, 1.0)
        cr.rectangle(0, 0, ancho, alto)
        cr.fill()

        linear = cairo.LinearGradient(0, 0, 0, alto)
        linear.add_color_stop_rgb(0, 0.3, 0.05, 0.0)
        linear.add_color_stop_rgb(0.3, 0.5, 0.2, 0.1)
        linear.add_color_stop_rgb(0.7, 0.7, 0.4, 0.3)
        cr.set_source(linear)
        cr.rectangle(x_swap, 0, w_swap, alto)
        cr.fill()

        # print self.metodo
        if self.metodo == "particion_1":
            w_root = ancho - w_swap
            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.2)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.4)
            cr.set_source(linear)
            cr.rectangle(0, 0, w_root, alto)
            cr.fill()
        elif self.metodo == "particion_2":
            w_root = ((gen.kb(self.root1) * ancho) / self.total) - 1
            x_root = 0
            w_home = ancho - w_swap - w_root - 1
            x_home = x_root + w_root + 1

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.0, 0.05, 0.1)
            linear.add_color_stop_rgb(0.3, 0.1, 0.2, 0.3)
            linear.add_color_stop_rgb(0.7, 0.3, 0.4, 0.5)
            cr.set_source(linear)
            cr.rectangle(x_home, 0, w_home, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.2)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.4)
            cr.set_source(linear)
            cr.rectangle(x_root, 0, w_root, alto)
            cr.fill()

        elif self.metodo == "particion_3":
            w_boot = ((gen.kb(self.boot) * ancho) / self.total) - 1
            x_boot = 0
            w_root = ((gen.kb(self.root2) * ancho) / self.total) - 2
            x_root = x_boot + w_boot + 1
            w_usr = ((gen.kb(self.usr) * ancho) / self.total) - 2
            x_usr = x_root + w_root + 1
            w_home = ancho - w_swap - w_root - w_boot - w_usr - 3
            x_home = x_usr + w_usr + 1

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.0, 0.0, 0.05)
            linear.add_color_stop_rgb(0.3, 0.0, 0.1, 0.2)
            linear.add_color_stop_rgb(0.7, 0.2, 0.3, 0.4)
            cr.set_source(linear)
            cr.rectangle(x_boot, 0, w_boot, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.2)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.4)
            cr.set_source(linear)
            cr.rectangle(x_root, 0, w_root, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0.3)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.5)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.8)
            cr.set_source(linear)
            cr.rectangle(x_usr, 0, w_usr, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.0, 0.05, 0.1)
            linear.add_color_stop_rgb(0.3, 0.1, 0.2, 0.3)
            linear.add_color_stop_rgb(0.7, 0.3, 0.4, 0.5)
            cr.set_source(linear)
            cr.rectangle(x_home, 0, w_home, alto)
            cr.fill()
    def __init__(self, padre):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        gtk.Window.set_position(self, gtk.WIN_POS_CENTER_ALWAYS)
        self.set_title("Nueva Partición")
        self.padre = padre
        self.set_size_request(400, 200)
        self.set_resizable(0)
        self.set_border_width(0)

        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        self.set_default_response(gtk.RESPONSE_CANCEL)

        if self.padre.bext == False:
            self.inicio = gen.kb(self.padre.lista[-1][5])
            self.fin = gen.kb(self.padre.fin)
        else:
            self.inicio = gen.kb(self.padre.ext_ini)
            self.fin = gen.kb(self.padre.ext_fin)

        # Contenedor General
        self.cont = gtk.Fixed()
        self.cont.show()
        self.vbox.pack_start(self.cont)

        #Tamaño de la partición
        self.lbl = gtk.Label('Tamaño')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.lbl.show()
        self.cont.put(self.lbl, 5, 5)
        adj = gtk.Adjustment(float(self.fin),
                             float(self.inicio),
                             float(self.fin),
                             1.0,
                             5.0,
                             0.0)
        self.escala = gtk.HScale()
        self.escala.set_draw_value(False)
        self.escala.set_adjustment(adj)
        self.escala.set_property('value-pos', gtk.POS_RIGHT)
        self.escala.set_size_request(250, 30)
        self.escala.connect("value-changed", self.on_changed)
        self.cont.put(self.escala, 60, 5)
        self.escala.show()
        self.lblsize = gtk.Label(gen.hum(self.escala.get_value() - \
                                 float(self.inicio)))
        self.lblsize.set_alignment(0, 0.5)
        self.lblsize.set_size_request(100, 30)
        self.lblsize.show()
        self.cont.put(self.lblsize, 320, 5)

        #Tipo de partición
        self.lbl = gtk.Label('Tipo de partición')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.cont.put(self.lbl, 5, 35)
        self.lbl.show()

        self.cmb_tipo = gtk.combo_box_new_text()
        self.cmb_tipo.set_size_request(100, 30)
        self.cont.put(self.cmb_tipo, 145, 35)
        if padre.bext == True:
            self.cmb_tipo.append_text('Lógica')
            self.cmb_tipo.set_sensitive(False)
        else:
            #if self.padre.primarias < 4:
            self.cmb_tipo.append_text('Primaria')
            self.cmb_tipo.append_text('Extendida')
        self.cmb_tipo.set_active(0)
        self.cmb_tipo.connect("changed", self.cmb_tipo_on_changed)
        self.cmb_tipo.show()

        #Sistema de Archivos
        self.lbl = gtk.Label('Sistema de Archivos')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.lbl.show()
        self.cont.put(self.lbl, 5, 65)
        self.cmb_fs = gtk.combo_box_new_text()
        self.cmb_fs.set_size_request(100, 30)
        self.cont.put(self.cmb_fs, 145, 65)
        self.cmb_fs.append_text('ext2')
        self.cmb_fs.append_text('ext3')
        self.cmb_fs.append_text('ext4')
        self.cmb_fs.append_text('linux-swap')
        self.cmb_fs.append_text('reiserfs')
        self.cmb_fs.append_text('fat16')
        self.cmb_fs.append_text('fat32')
        self.cmb_fs.set_active(2)
        self.cmb_fs.connect("changed", self.cmb_fs_on_changed)
        self.cmb_fs.show()

        # Punto de Montaje
        self.lbl = gtk.Label('Punto de Montaje')
        self.lbl.set_alignment(0, 0.5)
        self.lbl.set_size_request(200, 30)
        self.cont.put(self.lbl, 5, 95)
        self.lbl.show()

        self.cmb_montaje = gtk.combo_box_new_text()
        self.cmb_montaje.set_size_request(200, 30)
        self.cont.put(self.cmb_montaje, 145, 95)
        self.agregar('/')
        self.agregar('/boot')
        self.agregar('/home')
        self.agregar('/tmp')
        self.agregar('/usr')
        self.agregar('/var')
        self.agregar('/srv')
        self.agregar('/opt')
        self.agregar('/usr/local')
        self.cmb_montaje.append_text('Ninguno')
        self.cmb_montaje.append_text('Escoger manualmente')
        self.cmb_montaje.set_active(0)
        self.cmb_montaje.connect("changed", self.cmb_montaje_on_changed)
        self.cmb_montaje.show()

        self.entrada = gtk.Entry()
        self.entrada.set_text('/')
        self.entrada.set_size_request(200, 30)
        self.cont.put(self.entrada, 145, 125)
        self.entrada.connect("changed", self.validar_punto)

        response = self.run()

        if response == gtk.RESPONSE_OK:
            tipo = gen.get_active_text(self.cmb_tipo)
            formato = gen.get_active_text(self.cmb_fs)
            montaje = gen.get_active_text(self.cmb_montaje)
            if tipo == 'Extendida':
                formato = 'Ninguno'
                montaje = 'Ninguno'
            if formato == 'linux-swap':
                montaje = 'Ninguno'
            if montaje == 'Escoger manualmente':
                montaje = self.entrada.get_text().strip()

            if self.padre.lista[-1][1] == 'Espacio Libre':
                self.padre.lista.pop()
            if len(self.padre.lista) > 0:
                if self.padre.lista[-1][1] == 'Espacio Libre Extendida':
                    self.padre.lista.pop()

            # Si la partición nueva es Primaria
            if tipo == 'Primaria':
                # Calculo el tamaño
                inicio = int(self.inicio)
                fin = int(self.escala.get_value())
                tamano = gen.hum(fin - inicio)
                # Elimina ultimo elemento de la lista
                #self.padre.lista.pop()
                # Se crea elemento particion primaria y se agrega a la lista
                particion = [self.padre.disco, #Dispositivo
                             tipo, #Tipo
                             formato, #Formato
                             montaje, #Punto de montaje
                             tamano, #Tamaño
                             inicio, #inicio
                             fin]               #fin
                self.padre.lista.append(particion)
            # Si la partición nueva es Extendida
            elif tipo == 'Extendida':
                # Calculo el tamaño
                inicio = int(self.inicio)
                fin = int(self.escala.get_value())
                tamano = gen.hum(fin - inicio)
                # Cambia variable bext a True
                self.padre.bext = True
                # Establece las variables ext_ini y ext_fin
                self.padre.ext_ini = inicio
                self.padre.ext_fin = fin
                # Elimina ultimo elemento de la lista
                #self.padre.lista.pop()
                # Se crea elemento particion extendida y se agrega a la lista
                particion = [self.padre.disco, #Dispositivo
                             tipo, #Tipo
                             '', #formato,     #Formato
                             montaje, #Punto de montaje
                             tamano, #Tamaño
                             inicio, #inicio
                             fin]               #fin
                self.padre.lista.append(particion)
                # Se crea elemento espacio libre en partición extendida
                particion = ['', #self.padre.disco,                      #Dispositivo
                             'Espacio Libre Extendida', #Tipo
                             '', #self.get_active_text(self.cmb_fs),     #Formato
                             '', #self.get_active_text(self.cmb_montaje),#Punto de montaje
                             tamano, #Tamaño
                             inicio, #inicio
                             fin]                                   #fin
                self.padre.lista.append(particion)
            # Si la partición nueva es Lógica
            elif tipo == 'Lógica':
                # Calculo el tamaño
                inicio = int(self.padre.ext_ini)
                fin = int(self.escala.get_value())
                tamano = gen.hum(fin - inicio)
                # Elimina los dos ultimos elementos de la lista
                #self.padre.lista.pop()
                #self.padre.lista.pop()
                # Se crea elemento particion lógica y se agrega a la lista
                particion = [self.padre.disco, #Dispositivo
                             tipo, #Tipo
                             formato, #Formato
                             montaje, #Punto de montaje
                             tamano, #Tamaño
                             inicio, #inicio
                             fin]               #fin
                self.padre.lista.append(particion)
                # Si self.padre.ext_fin != fin entonces
                if self.padre.ext_fin == fin:
                    # No se crea elemento espacio libre en partición extendida
                    # Cambia variable bext a False
                    self.padre.bext = False
                # Si no
                else:
                    # se calcula el tamaño de la partición libre
                    ext_ini = fin
                    ext_fin = self.padre.ext_fin
                    tamano = gen.hum(ext_fin - ext_ini)
                    self.padre.ext_ini = ext_ini
                    # Se crea elemento espacio libre en partición extendida
                    particion = ['', #self.padre.disco,                      #Dispositivo
                                 'Espacio Libre Extendida', #Tipo
                                 '', #self.get_active_text(self.cmb_fs),     #Formato
                                 '', #self.get_active_text(self.cmb_montaje),#Punto de montaje
                                 tamano, #Tamaño
                                 ext_ini, #inicio
                                 ext_fin]                                   #fin
                    self.padre.lista.append(particion)

            # Calculamos el tamaño de la partición libre
            # si bext == True entonces se usará ext_fin como fin
            if self.padre.bext == True:
                fin = self.padre.ext_fin
            #print 'Inicio:', inicio, 'fin:', fin, "self.fin", int(self.fin)
            # Si fin == self.fin entonces 
            if fin == int(gen.kb(self.padre.fin)):
                pass
                # No se crea elemento espacio libre
                #print "No crea la elemento espacio libre"
            # Si no
            else:
                #print "Crea elemento espacio libre"
                # se calcula el tamaño de la partición libre
                inicio = fin
                fin = int(gen.kb(self.padre.fin))
                tamano = gen.hum(fin - inicio)
                # Se crea elemento espacio libre
                libre = ['', #Dispositivo
                         'Espacio Libre', #Tipo
                         '', #Formato
                         '', #Punto de montaje
                         tamano, #Tamaño
                         inicio, #inicio
                         fin]               #fin
                self.padre.lista.append(libre)
            # Se actualiza la tabla
            self.padre.llenar_tabla(self.padre.lista)

        else:
            pass

        self.destroy()
        return None
    def expose(self, widget=None, event=None):
        cr = self.window.cairo_create()
        cr.set_line_width(0.8)

        cr.select_font_face("Courier", cairo.FONT_SLANT_NORMAL,
                            cairo.FONT_WEIGHT_NORMAL)
        cr.set_font_size(11)

        ancho = self.get_size_request()[0]
        alto = self.get_size_request()[1]

        w_swap = ((self.swap * ancho) / self.total) - 1
        x_swap = ancho - w_swap + 1

        cr.set_source_rgb(1.0, 1.0, 1.0)
        cr.rectangle(0, 0, ancho, alto)
        cr.fill()

        linear = cairo.LinearGradient(0, 0, 0, alto)
        linear.add_color_stop_rgb(0, 0.3, 0.05, 0.0)
        linear.add_color_stop_rgb(0.3, 0.5, 0.2, 0.1)
        linear.add_color_stop_rgb(0.7, 0.7, 0.4, 0.3)
        cr.set_source(linear)
        cr.rectangle(x_swap, 0, w_swap, alto)
        cr.fill()

        #print self.metodo
        if self.metodo == 'particion_1':
            w_root = ancho - w_swap
            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.2)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.4)
            cr.set_source(linear)
            cr.rectangle(0, 0, w_root, alto)
            cr.fill()
        elif self.metodo == 'particion_2':
            w_root = ((gen.kb(self.root1) * ancho) / self.total) - 1
            x_root = 0
            w_home = ancho - w_swap - w_root - 1
            x_home = x_root + w_root + 1

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.0, 0.05, 0.1)
            linear.add_color_stop_rgb(0.3, 0.1, 0.2, 0.3)
            linear.add_color_stop_rgb(0.7, 0.3, 0.4, 0.5)
            cr.set_source(linear)
            cr.rectangle(x_home, 0, w_home, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.2)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.4)
            cr.set_source(linear)
            cr.rectangle(x_root, 0, w_root, alto)
            cr.fill()

        elif self.metodo == 'particion_3':
            w_boot = ((gen.kb(self.boot) * ancho) / self.total) - 1
            x_boot = 0
            w_root = ((gen.kb(self.root2) * ancho) / self.total) - 2
            x_root = x_boot + w_boot + 1
            w_usr = ((gen.kb(self.usr) * ancho) / self.total) - 2
            x_usr = x_root + w_root + 1
            w_home = ancho - w_swap - w_root - w_boot - w_usr - 3
            x_home = x_usr + w_usr + 1

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.0, 0.0, 0.05)
            linear.add_color_stop_rgb(0.3, 0.0, 0.1, 0.2)
            linear.add_color_stop_rgb(0.7, 0.2, 0.3, 0.4)
            cr.set_source(linear)
            cr.rectangle(x_boot, 0, w_boot, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.2)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.4)
            cr.set_source(linear)
            cr.rectangle(x_root, 0, w_root, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.3, 0.3, 0.3)
            linear.add_color_stop_rgb(0.3, 0.5, 0.5, 0.5)
            linear.add_color_stop_rgb(0.7, 0.8, 0.8, 0.8)
            cr.set_source(linear)
            cr.rectangle(x_usr, 0, w_usr, alto)
            cr.fill()

            linear = cairo.LinearGradient(0, 0, 0, alto)
            linear.add_color_stop_rgb(0, 0.0, 0.05, 0.1)
            linear.add_color_stop_rgb(0.3, 0.1, 0.2, 0.3)
            linear.add_color_stop_rgb(0.7, 0.3, 0.4, 0.5)
            cr.set_source(linear)
            cr.rectangle(x_home, 0, w_home, alto)
            cr.fill()