def establecer_metodo(self, widget=None): ''' Crea una lista de los metodos de instalación disponibles para la partición ''' for d in self.metodos: if d['msg'] == self.cmb_metodo.get_active_text(): self.metodo = d if self.metodo['tipo'] == 'TODO': msg = _("By choosing this option, Canaima will occupy all of your \ hard drive. Note that all data present will be erased. You can take this time \ to make a backup before proceeding with the installation.") elif self.metodo['tipo'] == 'LIBRE': msg = _("By choosing this option, Canaima will be installed in \ the free space of {0} that is in you hard disk, preserving the other data and \ systems that are in the other portions of the disc.") \ .format(humanize(self.metodo['part'][2] - self.metodo['part'][1])) elif self.metodo['tipo'] == 'REDIM': msg = _("This option will use the free space present in the \ partition {0} to install Canaima. The partition will be resized to free up \ space, preserving the data and/or systems present.") \ .format(self.metodo['part'][0]) elif self.metodo['tipo'] == 'MANUAL': msg = _("If you choose this option will open the partition \ editor, allowing you to adjust the partitions according to your convenience. \ We do not recommend you use this option unless you know what you are doing.") elif self.metodo['tipo'] == 'NONE': msg = _("Canaima needs at least {0} to be installed. Select other \ disk with more available space.").format(humanize(ESPACIO_TOTAL)) else: pass self.lbl4.set_text(msg)
def establecer_metodo(self, widget=None): ''' Crea una lista de los metodos de instalación disponibles para la partición ''' for d in self.metodos: if d['msg'] == self.cmb_metodo.get_active_text(): self.metodo = d if self.metodo['tipo'] == 'TODO': msg = _("By choosing this option, Canaima will occupy all of your \ hard drive. Note that all data present will be erased. You can take this time \ to make a backup before proceeding with the installation.") elif self.metodo['tipo'] == 'LIBRE': msg = _("By choosing this option, Canaima will be installed in \ the free space of {0} that is in you hard disk, preserving the other data and \ systems that are in the other portions of the disc." ) \ .format(humanize(self.metodo['part'][2] - self.metodo['part'][1])) elif self.metodo['tipo'] == 'REDIM': msg = _("This option will use the free space present in the \ partition {0} to install Canaima. The partition will be resized to free up \ space, preserving the data and/or systems present." ) \ .format(self.metodo['part'][0]) elif self.metodo['tipo'] == 'MANUAL': msg = _("If you choose this option will open the partition \ editor, allowing you to adjust the partitions according to your convenience. \ We do not recommend you use this option unless you know what you are doing.") elif self.metodo['tipo'] == 'NONE': msg = _("Canaima needs at least {0} to be installed. Select other \ disk with more available space.").format(humanize(ESPACIO_TOTAL)) else: pass self.lbl4.set_text(msg)
def delete_partition(self, part): 'Ejecuta el proceso de eliminar la particion de la lista' i = get_row_index(self.lista, part) particion = self.lista[i] inicio = particion[TblCol.INICIO] fin = particion[TblCol.FIN] del_sig = del_ant = False # Si tiene una fila anterior if i > 0: p_anterior = self.lista[i - 1] if self.is_summable(p_anterior, particion): del_ant = True inicio = p_anterior[TblCol.INICIO] # si tiene una fila siguiente if has_next_row(self.lista, i): p_siguiente = self.lista[i + 1] if self.is_summable(p_siguiente, particion): del_sig = True fin = p_siguiente[TblCol.FIN] tamano = fin - inicio temp = copy(particion) temp[TblCol.DISPOSITIVO] = '' # Validar de que tipo quedará la particion libre if is_primary(temp): temp[TblCol.TIPO] = msj.particion.primaria elif is_logic(temp): temp[TblCol.TIPO] = msj.particion.logica temp[TblCol.FORMATO] = msj.particion.libre temp[TblCol.MONTAJE] = '' temp[TblCol.TAMANO] = humanize(tamano) temp[TblCol.USADO] = humanize(0) temp[TblCol.LIBRE] = humanize(tamano) temp[TblCol.INICIO] = inicio temp[TblCol.FIN] = fin temp[TblCol.FORMATEAR] = False temp[TblCol.ESTADO] = PStatus.FREED # Sustituimos con los nuevos valores self.lista[i] = temp # Borramos los esṕacios vacios contiguos si existieren if del_sig: del self.lista[i + 1] if del_ant: del self.lista[i - 1] # Si lo que se estaeliminando no es un espacio libre if not is_free(particion): # Agregamos la accion correspondiente self.acciones.append(['borrar', self.disco, None, particion[TblCol.INICIO], particion[TblCol.FIN], particion[TblCol.FORMATO], msj.particion.get_tipo_orig( particion[TblCol.TIPO]), 0])
def delete_partition(self, part): 'Ejecuta el proceso de eliminar la particion de la lista' i = get_row_index(self.lista, part) particion = self.lista[i] inicio = particion[TblCol.INICIO] fin = particion[TblCol.FIN] del_sig = del_ant = False # Si tiene una fila anterior if i > 0: p_anterior = self.lista[i - 1] if self.is_summable(p_anterior, particion): del_ant = True inicio = p_anterior[TblCol.INICIO] # si tiene una fila siguiente if has_next_row(self.lista, i): p_siguiente = self.lista[i + 1] if self.is_summable(p_siguiente, particion): del_sig = True fin = p_siguiente[TblCol.FIN] tamano = fin - inicio temp = copy(particion) temp[TblCol.DISPOSITIVO] = '' # Validar de que tipo quedará la particion libre if is_primary(temp): temp[TblCol.TIPO] = msj.particion.primaria elif is_logic(temp): temp[TblCol.TIPO] = msj.particion.logica temp[TblCol.FORMATO] = msj.particion.libre temp[TblCol.MONTAJE] = '' temp[TblCol.TAMANO] = humanize(tamano) temp[TblCol.USADO] = humanize(0) temp[TblCol.LIBRE] = humanize(tamano) temp[TblCol.INICIO] = inicio temp[TblCol.FIN] = fin temp[TblCol.FORMATEAR] = False temp[TblCol.ESTADO] = PStatus.FREED # Sustituimos con los nuevos valores self.lista[i] = temp # Borramos los esṕacios vacios contiguos si existieren if del_sig: del self.lista[i + 1] if del_ant: del self.lista[i - 1] # Si lo que se estaeliminando no es un espacio libre if not is_free(particion): # Agregamos la accion correspondiente self.acciones.append([ 'borrar', self.disco, None, particion[TblCol.INICIO], particion[TblCol.FIN], particion[TblCol.FORMATO], msj.particion.get_tipo_orig(particion[TblCol.TIPO]), 0 ])
def validate_fs_size(self): formato = self.fs_box.cmb_fs.get_active_text() tamano = self.particion_act[TblCol.FIN] - self.particion_act[TblCol.INICIO] estatus = True if not validate_minimun_fs_size(formato, tamano): estatus = False msg = "%s debe tener un tamaño mínimo de %s." % (formato, humanize(FSMIN[formato])) UserMessage(msg, 'Información', gtk.MESSAGE_INFO, gtk.BUTTONS_OK) if not validate_maximun_fs_size(formato, tamano): estatus = False msg = "%s debe tener un tamaño máximo de %s." % (formato, humanize(FSMAX[formato])) UserMessage(msg, 'Información', gtk.MESSAGE_INFO, gtk.BUTTONS_OK) return estatus
def add_partition_to_list(self, tipo, formato, montaje, tamano, usado, libre, inicio, fin): disp = self.disco crear_accion = True formatear = False # Si es espacio libre if formato == msj.particion.libre: crear_accion = False pop = False disp = '' montaje = '' usado = humanize(0) libre = tamano # Si NO es espacio libre else: pop = True formatear = True if tipo == msj.particion.extendida: formato = '' montaje = '' if montaje == MSG_NONE: montaje = '' # Entrada de la particion para la tabla particion = [disp, tipo, formato, montaje, tamano, usado, libre, \ inicio, fin, formatear, PStatus.NEW] # Crea la acción correspondiente que va ejecutarse if crear_accion: self.acciones.append(['crear', disp, montaje, inicio, fin, formato, msj.particion.get_tipo_orig(tipo), 0]) self.lista = set_partition(self.lista, self.particion_act, particion, \ pop)
def establecer_metodo(self, widget=None): """ Crea una lista de los metodos de instalación disponibles para la partición """ for d in self.metodos: if d["msg"] == self.cmb_metodo.get_active_text(): self.metodo = d if self.metodo["tipo"] == "TODO": msg = "Al escoger esta opción el nuevo Sistema Operativo ocupará la totalidad de su disco duro. Tenga en cuenta que se borrarán todos los datos y/o sistemas presentes. Puede aprovechar este momento para realizar un respaldo antes de proseguir con la instalación." elif self.metodo["tipo"] == "LIBRE": msg = "Esta opción le permitirá instalar el Sistema Operativo en el espacio libre de {0} que se encuentra en su disco duro, conservando los demás datos y/o sistemas que se encuentren en las demás porciones del disco.".format( humanize(self.metodo["part"][2] - self.metodo["part"][1]) ) elif self.metodo["tipo"] == "REDIM": msg = "Esta opción permitirá utilizar el espacio libre presente en la partición {0} para instalar el Sistema Operativo. Se redimensionará la partición para liberar el espacio, manteniendo los datos y/o sistemas presentes".format( self.metodo["part"][0] ) elif self.metodo["tipo"] == "MANUAL": msg = "Si escoge esta opción se abrirá el editor de particiones, que le permitirá ajustar las particiones según más le convenga. No le recomendamos que utilice esta opción a menos que sepa lo que está haciendo." elif self.metodo["tipo"] == "NONE": msg = "El sistema operativo necesita al menos 6GB libres para poder instalar. Seleccione otro disco duro." else: pass self.lbl4.set_text(msg)
def expose(self, widget=None, event=None): self.forma = self.p.forma self.nuevas = self.p.nuevas self.lbl_1.set_text("") self.lbl_2.set_text("") self.lbl_3.set_text("") self.lbl_4.set_text("") self.lbl_5.set_text("") self.lbl_6.set_text("") self.lbl_7.set_text("") j = 1 for i in self.nuevas: part = i[0] size = humanize(i[2] - i[1]) if part == "ROOT": exec "self.lbl_" + str(j) + ".set_text('Espacio principal (/): '+size)" elif part == "SWAP": exec "self.lbl_" + str(j) + ".set_text('Espacio de intercambio (swap): '+size)" elif part == "HOME": exec "self.lbl_" + str(j) + ".set_text('Espacio de usuarios (/home): '+size)" elif part == "USR": exec "self.lbl_" + str(j) + ".set_text('Espacio de aplicaciones (/usr): '+size)" elif part == "BOOT": exec "self.lbl_" + str(j) + ".set_text('Espacio de arranque (/boot): '+size)" elif part == "VAR": exec "self.lbl_" + str(j) + ".set_text('Espacio de variables (/var): '+size)" elif part == "LIBRE": exec "self.lbl_" + str(j) + ".set_text('Espacio Libre: '+size)" elif part == "PART": exec "self.lbl_" + str(j) + ".set_text('Partición redimensionada: '+size)" j += 1
def initialize(self, data): ''' Inicializa todas las variables ''' self.lista = [] # Lista de las particiones hechas self.acciones = [] # Almacena las acciones pendientes a realizar self.fila_selec = None # Ultima fila seleccionada de la tabla self.raiz = False self.set_buttons_insensitives() # Llenar la tabla con el contenido actual del disco if self.tabla != None: #l_part = Particiones().lista_particiones(self.disco) for particion in self.data['particiones']: p_disp = particion[0] p_ini = particion[1] p_fin = particion[2] p_tam = particion[3] p_format = particion[4] p_tipo = particion[5] p_usado = particion[7] p_libre = particion[8] p_num = particion[10] fila = [ msj.particion.get_dispositivo(p_disp, p_num), msj.particion.get_tipo(p_tipo), msj.particion.get_formato(p_format), '', humanize(floatify(p_tam)), humanize(p_usado), humanize(p_libre), p_ini, p_fin, False, PStatus.NORMAL, ] self.lista.append(fila) self.fill_table()
def validate_fs_size(self): formato = self.fs_box.cmb_fs.get_active_text() tamano = self.particion_act[TblCol.FIN] \ - self.particion_act[TblCol.INICIO] estatus = True if not validate_minimun_fs_size(formato, tamano): estatus = False msg = _("{0} must have a minimum size of {1}.")\ .format(formato, humanize(FSMIN[formato])) UserMessage(msg, 'Información', gtk.MESSAGE_INFO, gtk.BUTTONS_OK) if not validate_maximun_fs_size(formato, tamano): estatus = False msg = _("{0} must have a maximum size of {1}.")\ .format(formato, humanize(FSMAX[formato])) UserMessage(msg, _('Information'), gtk.MESSAGE_INFO, gtk.BUTTONS_OK) return estatus
def escala_on_changed(self, widget=None): formato = self.cmb_fs.get_active_text() tamano = widget.get_value() - self.inicio_part # Impide que se sobrepasen los maximos y minimos if not validate_minimun_fs_size(formato, tamano): widget.set_value(self.inicio_part + FSMIN[formato]) elif not validate_maximun_fs_size(formato, tamano): widget.set_value(self.inicio_part + FSMAX[formato]) if self.cmb_fs: self.lblsize.set_text(humanize(widget.get_value() - self.inicio_part))
def escala_on_changed(self, widget=None): formato = self.cmb_fs.get_active_text() tamano = widget.get_value() - self.inicio_part # Impide que se sobrepasen los maximos y minimos if not validate_minimun_fs_size(formato, tamano): widget.set_value(self.inicio_part + FSMIN[formato]) elif not validate_maximun_fs_size(formato, tamano): widget.set_value(self.inicio_part + FSMAX[formato]) if self.cmb_fs: self.lblsize.set_text(humanize(widget.get_value() \ - self.inicio_part))
def escala_value_changed(self, adjustment): 'Acciones a tomar cuando se mueve el valor de la escala' # No reducir menos del espacio minimo tamano = adjustment.value - self.inicio if not validate_minimun_fs_size(self.formato, tamano): adjustment.set_value(self.inicio + FSMIN[self.formato]) elif not validate_maximun_fs_size(self.formato, tamano): adjustment.set_value(self.inicio + FSMAX[self.formato]) # No reducir menos del espacio usado elif adjustment.value <= self.get_used_space(): adjustment.set_value(self.get_used_space()) # Activa el boton de aceptar sólo si se ha modificado el valor if adjustment.value == self.fin: self.set_response_sensitive(gtk.RESPONSE_OK, False) else: self.set_response_sensitive(gtk.RESPONSE_OK, True) # Actualizar los textos con los valores self.lbl_tamano_num.set_text(humanize(self.get_new_partition_size())) self.lbl_libre_num.set_text(humanize(self.get_free_space())) self.lbl_sin_particion_num.set_text(humanize(self.get_unasigned_space()))
def escala_value_changed(self, adjustment): 'Acciones a tomar cuando se mueve el valor de la escala' # No reducir menos del espacio minimo tamano = adjustment.value - self.inicio if not validate_minimun_fs_size(self.formato, tamano): adjustment.set_value(self.inicio + FSMIN[self.formato]) elif not validate_maximun_fs_size(self.formato, tamano): adjustment.set_value(self.inicio + FSMAX[self.formato]) # No reducir menos del espacio usado elif adjustment.value <= self.get_used_space(): adjustment.set_value(self.get_used_space()) # Activa el boton de aceptar sólo si se ha modificado el valor if adjustment.value == self.fin: self.set_response_sensitive(gtk.RESPONSE_OK, False) else: self.set_response_sensitive(gtk.RESPONSE_OK, True) # Actualizar los textos con los valores self.lbl_tamano_num.set_text(humanize(self.get_new_partition_size())) self.lbl_libre_num.set_text(humanize(self.get_free_space())) self.lbl_sin_particion_num.set_text( humanize(self.get_unasigned_space()))
def expose(self, widget=None, event=None): self.forma = self.p.forma self.nuevas = self.p.nuevas self.lbl_1.set_text('') self.lbl_2.set_text('') self.lbl_3.set_text('') self.lbl_4.set_text('') self.lbl_5.set_text('') self.lbl_6.set_text('') self.lbl_7.set_text('') j = 1 for i in self.nuevas: part = i[0] size = humanize(i[2] - i[1]) if part == 'ROOT': exec "self.lbl_" + str(j) + ".set_text('" + MSG_ROOT_DIR \ + " '+size)" elif part == 'SWAP': exec "self.lbl_" + str(j) + ".set_text('" + MSG_SWAP_SPC \ + " '+size)" elif part == 'HOME': exec "self.lbl_" + str(j) + ".set_text('" + MSG_USER_DIR \ + " '+size)" elif part == 'USR': exec "self.lbl_" + str(j) + ".set_text('" + MSG_APP_DIR \ + " '+size)" elif part == 'BOOT': exec "self.lbl_" + str(j) + ".set_text('" + MSG_BOOT_DIR \ + " '+size)" elif part == 'VAR': exec "self.lbl_" + str(j) + ".set_text('" + MSG_VAR_DIR \ + " '+size)" elif part == 'LIBRE': exec "self.lbl_" + str(j) + ".set_text('" + MSG_FREE_SPC \ + " '+size)" elif part == 'PART': exec "self.lbl_" + str(j) + ".set_text('" + MSG_RESIZE_SPC \ + " '+size)" j += 1
def add_partition_to_list(self, tipo, formato, montaje, tamano, usado, libre, inicio, fin): disp = self.disco crear_accion = True formatear = False # Si es espacio libre if formato == msj.particion.libre: crear_accion = False pop = False disp = '' montaje = '' usado = humanize(0) libre = tamano # Si NO es espacio libre else: pop = True formatear = True if tipo == msj.particion.extendida: formato = '' montaje = '' if montaje == MSG_NONE: montaje = '' # Entrada de la particion para la tabla particion = [disp, tipo, formato, montaje, tamano, usado, libre, \ inicio, fin, formatear, PStatus.NEW] # Crea la acción correspondiente que va ejecutarse if crear_accion: self.acciones.append([ 'crear', disp, montaje, inicio, fin, formato, msj.particion.get_tipo_orig(tipo), 0 ]) self.lista = set_partition(self.lista, self.particion_act, particion, \ pop)
def process_response(self, response=None): if not response: return response part_actual = self.lista[self.num_fila_act] original = copy(part_actual) part_sig = self.get_next_free_partition() if response == gtk.RESPONSE_OK: part_actual[TblCol.FIN] = self.escala.get_value() part_actual[TblCol.TAMANO] = humanize( self.get_new_partition_size()) part_actual[TblCol.LIBRE] = humanize(self.get_free_space()) part_actual[TblCol.ESTADO] = PStatus.REDIM # Si dejamos espacio libre if part_actual[TblCol.FIN] < self.get_maximum_size(): # Si hay particion libre siguiente, solo modificamos algunos # valores if part_sig: part_sig[TblCol.INICIO] = part_actual[TblCol.FIN] \ + self.sector tamano = humanize(part_sig[TblCol.FIN] - part_sig[TblCol.INICIO]) part_sig[TblCol.TAMANO] = tamano part_sig[TblCol.LIBRE] = tamano part_sig[TblCol.ESTADO] = PStatus.FREED self.lista[self.num_fila_act + 1] = part_sig # Si no hay particion siguiente, tenemos que crear toda la fila else: part_sig = list(range(len(part_actual))) part_sig[TblCol.DISPOSITIVO] = '' part_sig[TblCol.TIPO] = part_actual[TblCol.TIPO] part_sig[TblCol.FORMATO] = msj.particion.libre part_sig[TblCol.MONTAJE] = '' part_sig[TblCol.TAMANO] = humanize( self.get_unasigned_space()) part_sig[TblCol.USADO] = humanize(0) part_sig[TblCol.LIBRE] = humanize( self.get_unasigned_space()) part_sig[TblCol.INICIO] = part_actual[TblCol.FIN] \ + self.sector part_sig[TblCol.FIN] = self.get_maximum_size() part_sig[TblCol.FORMATEAR] = False part_sig[TblCol.ESTADO] = PStatus.FREED tmp = [] for i in range(len(self.lista)): if i == self.num_fila_act: tmp.append(part_actual) tmp.append(part_sig) else: tmp.append(self.lista[i]) self.lista = tmp # Sino dejamos espacio libre elif part_sig: self.lista.remove(part_sig) self.acciones.append([ 'redimensionar', part_actual[TblCol.DISPOSITIVO], part_actual[TblCol.MONTAJE], part_actual[TblCol.INICIO], # Fin original original[TblCol.FIN], part_actual[TblCol.FORMATO], msj.particion.get_tipo_orig(part_actual[TblCol.TIPO]), # Nuevo Fin part_actual[TblCol.FIN], ]) self.destroy() return response
def __init__(self, padre): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) gtk.Window.set_position(self, gtk.WIN_POS_CENTER_ALWAYS) self.disco = padre.disco self.sector = get_sector_size(self.disco) self.lista = padre.lista self.acciones = padre.acciones self.particion_act = padre.fila_selec # Toma el inicio_part y fin_part de la particion seleccionada self.inicio_part = self.particion_act[TblCol.INICIO] self.fin_part = self.particion_act[TblCol.FIN] self.num_fila_act = get_row_index(self.lista, self.particion_act) self.particion_sig = get_next_row(self.lista, self.particion_act, self.num_fila_act) self.set_title(_("New partition")) self.set_resizable(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) #Tamaño de la partición lbl_tamano = gtk.Label(_("Size:")) lbl_tamano.set_alignment(0, 0.5) lbl_tamano.show() adj = gtk.Adjustment(self.fin_part, self.inicio_part, self.fin_part, \ 1.0, 1024.0, 0.0) self.escala = gtk.HScale() self.escala.set_digits(0) self.escala.set_draw_value(False) self.escala.set_adjustment(adj) self.escala.set_size_request(450, -1) self.escala.connect("value-changed", self.escala_on_changed) self.escala.show() self.lblsize = gtk.Label(humanize(self.escala.get_value() - \ self.inicio_part)) self.lblsize.show() hbox = gtk.VBox() hbox.show() hbox.pack_start(self.escala) hbox.pack_start(self.lblsize) fs_container = frame_fs(self, self.lista, self.particion_act) self.cmb_tipo = fs_container.cmb_tipo self.cmb_fs = fs_container.cmb_fs self.cmb_fs.connect('changed', self.cmb_fs_changed) self.cmb_montaje = fs_container.cmb_montaje self.entrada = fs_container.entrada fs_container.formatear.set_active(True) fs_container.formatear.set_sensitive(False) # Contenedor General self.cont = gtk.VBox() self.cont.pack_start(lbl_tamano) self.cont.pack_start(hbox, padding=15) self.cont.pack_start(fs_container) self.cont.show() self.vbox.pack_start(self.cont) response = self.run() self.process_response(response)
def process_response(self, response=None): if not response: return response if response == gtk.RESPONSE_OK: tipo = self.cmb_tipo.get_active_text() formato = self.cmb_fs.get_active_text() montaje = self.cmb_montaje.get_active_text() usado = humanize(0) # Calculo el tamaño inicio = self.inicio_part fin = self.escala.get_value() tamano = humanize(fin - inicio) libre = tamano if formato == 'swap': montaje = 'swap' if montaje == MSG_ENTER_MANUAL: montaje = self.entrada.get_text().strip() print "---NUEVA----" # Primaria if tipo == msj.particion.primaria: print "Partición primaria" self.add_partition_to_list(tipo, formato, montaje, tamano, \ usado, libre, inicio + self.sector, fin) if fin != self.fin_part: print "Que deja espacio libre" inicio = self.escala.get_value() fin = self.fin_part tamano = humanize(fin - inicio) libre = tamano self.add_partition_to_list(tipo, msj.particion.libre, \ montaje, tamano, usado, libre, inicio, fin) # Extendida elif tipo == msj.particion.extendida: print "Partición Extendida" usado = tamano libre = humanize(0) self.add_partition_to_list(tipo, formato, montaje, tamano, \ usado, libre, inicio + self.sector, fin) print "Crea vacío interno" self.add_partition_to_list(msj.particion.logica, \ msj.particion.libre, montaje, tamano, usado, libre, \ # agregamos +1 al inicio para que la lista no se desordene inicio + 1, fin) if fin != self.fin_part: print "Y deja espacio libre" inicio = self.escala.get_value() fin = self.fin_part tamano = humanize(fin - inicio) libre = tamano self.add_partition_to_list(msj.particion.primaria, \ msj.particion.libre, montaje, tamano, usado, libre, \ inicio, fin) # Lógica elif tipo == msj.particion.logica: print "Partición Lógica" self.add_partition_to_list(tipo, formato, montaje, tamano, \ usado, libre, inicio + self.sector * 4, fin) if fin != self.fin_part: print "Que deja espacio extendido libre" inicio = self.escala.get_value() fin = self.fin_part tamano = humanize(fin - inicio) libre = tamano self.add_partition_to_list(tipo, msj.particion.libre, \ montaje, tamano, usado, libre, inicio, fin) print "------------" self.destroy() return response
def seleccionar_disco(self, widget=None): primarias = 0 extendidas = 0 logicas = 0 self.metodos = [] try: self.barra_part.expose() except: pass self.cmb_metodo.get_model().clear() self.cmb_metodo.set_sensitive(False) CFG['w'].siguiente.set_sensitive(False) self.lbl4.set_text('') self.disco = self.cmb_discos.get_active_text() print '{0} seleccionado'.format(self.disco) self.particiones = self.part.lista_particiones(self.disco) if len(self.particiones) == 0: UserMessage( message=_("""Disk "{0}" needs a partition table to \ continue the installation. Do you want to create a partition table now? If you press Cancel you can not use that disk to install Canaima.""")\ .format(self.disco), title=_("Partition table not found."), mtype=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK_CANCEL, c_1=gtk.RESPONSE_OK, f_1=self.part.nueva_tabla_particiones, p_1=(self.disco, 'msdos'), c_2=gtk.RESPONSE_OK, f_2=self.seleccionar_disco, p_2=() ) else: try: self.barra_part.expose() except: pass self.total = self.particiones[0][9] CFG['w'].siguiente.set_sensitive(True) self.cmb_metodo.set_sensitive(True) mini = self.particiones[0][1] mfin = self.particiones[0][9] for t in self.particiones: if mini > t[1]: mini = t[1] if mfin < t[2]: mfin = t[2] if t[5] == 'primary' and t[4] != 'free': primarias += 1 elif t[5] == 'logical' and t[4] != 'free': logicas += 1 elif t[5] == 'extended': extendidas += 1 disco_array = [ self.disco, mini, mfin, primarias, extendidas, logicas ] if self.total >= self.minimo: for p in self.particiones: part = p[0] tam = p[3] fs = p[4] tipo = p[5] libre = p[8] if fs != 'free' and libre >= self.minimo: if fs in FSPROGS: if tipo == 'logical' and FSPROGS[fs][1][0] != '': if logicas < 10: self.metodos.append({ 'tipo': 'REDIM', 'msg': _("Install resizing {0} to \ free up space ({1} free)").format(part, humanize(libre)), 'part': p, 'disco': disco_array }) elif tipo == 'primary' and FSPROGS[fs][1][0] != '': if (extendidas < 1 and primarias < 4) \ or (extendidas > 0 and primarias < 2): self.metodos.append({ 'tipo': 'REDIM', 'msg': _("Install resizing {0} to \ free up space ({1} free)").format(part, humanize(libre)), 'part': p, 'disco': disco_array }) if fs == 'free' and tam >= self.minimo: if tipo == 'logical': if logicas < 10: self.metodos.append({ 'tipo': 'LIBRE', 'msg': _("Install using available free \ space ({0})").format(humanize(tam)), 'part': p, 'disco': disco_array }) elif tipo == 'primary': if (extendidas < 1 and primarias < 4) \ or (extendidas > 0 and primarias < 2): self.metodos.append({ 'tipo': 'LIBRE', 'msg': _("Install using available free \ space ({0})").format(humanize(tam)), 'part': p, 'disco': disco_array }) self.metodos.append({ 'tipo': 'TODO', 'msg': _("Install using the entire disk ({0})") \ .format(humanize(self.total)), 'part': disco_array, 'disco': disco_array }) self.metodos.append({ 'tipo': 'MANUAL', 'msg': _("Install editing partitions manually")\ .format(humanize(tam)), 'part': disco_array, 'disco': disco_array }) else: self.metodos.append({ 'tipo': 'NONE', 'msg': 'El tamaño del disco no es suficiente' }) CFG['w'].siguiente.set_sensitive(False) self.cmb_metodo.set_sensitive(False) for k in sorted(self.metodos, key=lambda ordn: ordn['tipo'], reverse=True): self.cmb_metodo.append_text(k['msg']) self.cmb_metodo.set_active(0)
def seleccionar_disco(self, widget=None): primarias = 0 extendidas = 0 logicas = 0 self.metodos = [] try: self.barra_part.expose() except: pass self.cmb_metodo.get_model().clear() self.cmb_metodo.set_sensitive(False) CFG['w'].siguiente.set_sensitive(False) self.lbl4.set_text('') self.disco = self.cmb_discos.get_active_text() print '{0} seleccionado'.format(self.disco) self.particiones = self.part.lista_particiones(self.disco) if len(self.particiones) == 0: UserMessage( message=_("""Disk "{0}" needs a partition table to \ continue the installation. Do you want to create a partition table now? If you press Cancel you can not use that disk to install Canaima.""")\ .format(self.disco), title=_("Partition table not found."), mtype=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK_CANCEL, c_1=gtk.RESPONSE_OK, f_1=self.part.nueva_tabla_particiones, p_1=(self.disco, 'msdos'), c_2=gtk.RESPONSE_OK, f_2=self.seleccionar_disco, p_2=() ) else: try: self.barra_part.expose() except: pass self.total = self.particiones[0][9] CFG['w'].siguiente.set_sensitive(True) self.cmb_metodo.set_sensitive(True) mini = self.particiones[0][1] mfin = self.particiones[0][9] for t in self.particiones: if mini > t[1]: mini = t[1] if mfin < t[2]: mfin = t[2] if t[5] == 'primary' and t[4] != 'free': primarias += 1 elif t[5] == 'logical' and t[4] != 'free': logicas += 1 elif t[5] == 'extended': extendidas += 1 disco_array = [self.disco, mini, mfin, primarias, extendidas, logicas] if self.total >= self.minimo: for p in self.particiones: part = p[0] tam = p[3] fs = p[4] tipo = p[5] libre = p[8] if fs != 'free' and libre >= self.minimo: if fs in FSPROGS: if tipo == 'logical' and FSPROGS[fs][1][0] != '': if logicas < 10: self.metodos.append({ 'tipo': 'REDIM', 'msg': _("Install resizing {0} to \ free up space ({1} free)").format(part, humanize(libre)), 'part': p, 'disco': disco_array }) elif tipo == 'primary' and FSPROGS[fs][1][0] != '': if (extendidas < 1 and primarias < 4) \ or (extendidas > 0 and primarias < 2): self.metodos.append({ 'tipo': 'REDIM', 'msg': _("Install resizing {0} to \ free up space ({1} free)").format(part, humanize(libre)), 'part': p, 'disco': disco_array }) if fs == 'free' and tam >= self.minimo: if tipo == 'logical': if logicas < 10: self.metodos.append({ 'tipo': 'LIBRE', 'msg': _("Install using available free \ space ({0})").format(humanize(tam)), 'part': p, 'disco': disco_array }) elif tipo == 'primary': if (extendidas < 1 and primarias < 4) \ or (extendidas > 0 and primarias < 2): self.metodos.append({ 'tipo': 'LIBRE', 'msg': _("Install using available free \ space ({0})").format(humanize(tam)), 'part': p, 'disco': disco_array }) self.metodos.append({ 'tipo': 'TODO', 'msg': _("Install using the entire disk ({0})") \ .format(humanize(self.total)), 'part': disco_array, 'disco': disco_array }) self.metodos.append({ 'tipo': 'MANUAL', 'msg': _("Install editing partitions manually")\ .format(humanize(tam)), 'part': disco_array, 'disco': disco_array }) else: self.metodos.append({ 'tipo': 'NONE', 'msg': 'El tamaño del disco no es suficiente' }) CFG['w'].siguiente.set_sensitive(False) self.cmb_metodo.set_sensitive(False) for k in sorted(self.metodos, key=lambda ordn: ordn['tipo'], reverse=True): self.cmb_metodo.append_text(k['msg']) self.cmb_metodo.set_active(0)
def __init__(self, data): gtk.VBox.__init__(self) self.data = data self.disco = self.data['metodo']['disco'][0] self.tabla = TablaParticiones() #self.tabla.set_doble_click(self.activar_tabla); self.tabla.set_seleccionar(self.table_row_selected) label = gtk.Label( _("""Use the following table to modify disk \ partitions to your liking. We recommend: - Establish a minimum of {0} for the root partition (/). - Create a swap space.""").format(humanize(ESPACIO_TOTAL))) label.set_line_wrap(False) label.set_justify(gtk.JUSTIFY_LEFT) label.set_alignment(0, 0) label.show() self.pack_start(label, False, False, 0) self.scroll = gtk.ScrolledWindow() self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.scroll.set_size_request(0, 150) self.scroll.add(self.tabla) self.tabla.show() self.scroll.show() self.pack_start(self.scroll, True, True, 10) # btn_nueva self.btn_nueva = gtk.Button(_("New...")) image = gtk.Image() image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_nueva.set_image(image) self.btn_nueva.show() self.btn_nueva.connect("clicked", self.new_partition) # btn_editar self.btn_editar = gtk.Button(_("Edit...")) image = gtk.Image() image.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_editar.set_image(image) self.btn_editar.show() self.btn_editar.connect("clicked", self.edit_partition) # btn_eliminar self.btn_eliminar = gtk.Button(_("Delete")) image = gtk.Image() image.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_eliminar.set_image(image) self.btn_eliminar.show() self.btn_eliminar.connect("clicked", self.delete_partition) # btn_redimension self.btn_redimension = gtk.Button(_("Resize...")) image = gtk.Image() image.set_from_stock(gtk.STOCK_INDENT, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_redimension.set_image(image) self.btn_redimension.show() self.btn_redimension.connect("clicked", self.resize_partition) # btn_deshacer self.btn_deshacer = gtk.Button(_("Undo all")) image = gtk.Image() image.set_from_stock(gtk.STOCK_UNDO, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_deshacer.set_image(image) self.btn_deshacer.show() self.btn_deshacer.connect("clicked", self.undo_all_actions) self.botonera1 = gtk.HButtonBox() self.botonera1.set_layout(gtk.BUTTONBOX_START) self.botonera1.set_homogeneous(False) self.botonera1.add(self.btn_nueva) self.botonera1.add(self.btn_editar) self.botonera1.add(self.btn_redimension) self.botonera1.add(self.btn_eliminar) self.botonera1.add(self.btn_deshacer) self.pack_start(self.botonera1, False, False, 0) # llenar la tabla por primera vez self.initialize(data)
def process_response(self, response=None): if not response: return response part_actual = self.lista[self.num_fila_act] original = copy(part_actual) part_sig = self.get_next_free_partition() if response == gtk.RESPONSE_OK: part_actual[TblCol.FIN] = self.escala.get_value() part_actual[TblCol.TAMANO] = humanize(self.get_new_partition_size()) part_actual[TblCol.LIBRE] = humanize(self.get_free_space()) part_actual[TblCol.ESTADO] = PStatus.REDIM # Si dejamos espacio libre if part_actual[TblCol.FIN] < self.get_maximum_size(): # Si hay particion libre siguiente, solo modificamos algunos # valores if part_sig: part_sig[TblCol.INICIO] = part_actual[TblCol.FIN] + self.sector tamano = humanize( part_sig[TblCol.FIN] - part_sig[TblCol.INICIO]) part_sig[TblCol.TAMANO] = tamano part_sig[TblCol.LIBRE] = tamano part_sig[TblCol.ESTADO] = PStatus.FREED self.lista[self.num_fila_act + 1] = part_sig # Si no hay particion siguiente, tenemos que crear toda la fila else: part_sig = list(range(len(part_actual))) part_sig[TblCol.DISPOSITIVO] = '' part_sig[TblCol.TIPO] = part_actual[TblCol.TIPO] part_sig[TblCol.FORMATO] = msj.particion.libre part_sig[TblCol.MONTAJE] = '' part_sig[TblCol.TAMANO] = humanize(self.get_unasigned_space()) part_sig[TblCol.USADO] = humanize(0) part_sig[TblCol.LIBRE] = humanize(self.get_unasigned_space()) part_sig[TblCol.INICIO] = part_actual[TblCol.FIN] + self.sector part_sig[TblCol.FIN] = self.get_maximum_size() part_sig[TblCol.FORMATEAR] = False part_sig[TblCol.ESTADO] = PStatus.FREED tmp = [] for i in range(len(self.lista)): if i == self.num_fila_act: tmp.append(part_actual) tmp.append(part_sig) else: tmp.append(self.lista[i]) self.lista = tmp # Sino dejamos espacio libre elif part_sig: self.lista.remove(part_sig) self.acciones.append([ 'redimensionar', part_actual[TblCol.DISPOSITIVO], part_actual[TblCol.MONTAJE], part_actual[TblCol.INICIO], original[TblCol.FIN], # Fin original part_actual[TblCol.FORMATO], msj.particion.get_tipo_orig(part_actual[TblCol.TIPO]), part_actual[TblCol.FIN], # Nuevo Fin ]) self.destroy() return response
def __init__(self, disco, lista, fila, acciones): self.sector = get_sector_size(disco) self.lista = lista self.acciones = acciones self.num_fila_act = get_row_index(lista, fila) self.dispositivo = fila[TblCol.DISPOSITIVO] self.formato = fila[TblCol.FORMATO] self.inicio = fila[TblCol.INICIO] self.fin = fila[TblCol.FIN] self.usado = floatify(fila[TblCol.USADO]) gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) gtk.Window.set_position(self, gtk.WIN_POS_CENTER_ALWAYS) self.set_title("Redimensionar Partición") self.set_size_request(400, 200) self.set_resizable(0) self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) self.set_response_sensitive(gtk.RESPONSE_OK, False) self.set_default_response(gtk.RESPONSE_CANCEL) self.escala = gtk.HScale() self.escala.set_draw_value(False) adj = gtk.Adjustment(self.fin, self.inicio, self.get_maximum_size(), 1.0, 1024.0, 0.0) adj.connect("value-changed", self.escala_value_changed) self.escala.set_adjustment(adj) self.escala.show() self.lbl_dispositivo = gtk.Label("Partición '%s'" % self.dispositivo) self.lbl_dispositivo.show() self.lbl_tamano = gtk.Label('Tamaño') self.lbl_tamano_num = gtk.Label(humanize(self.get_new_partition_size())) self.vb_tamano = gtk.VBox() self.vb_tamano.add(self.lbl_tamano) self.vb_tamano.add(self.lbl_tamano_num) self.vb_tamano.show_all() self.lbl_usado = gtk.Label('Usado') self.lbl_usado_num = gtk.Label(humanize(self.usado)) self.vb_usado = gtk.VBox() self.vb_usado.add(self.lbl_usado) self.vb_usado.add(self.lbl_usado_num) self.vb_usado.show_all() self.lbl_libre = gtk.Label('Libre') self.lbl_libre_num = gtk.Label(humanize(self.get_free_space())) self.vb_libre = gtk.VBox() self.vb_libre.add(self.lbl_libre) self.vb_libre.add(self.lbl_libre_num) self.vb_libre.show_all() self.lbl_sin_particion = gtk.Label('Sin Particionar') self.lbl_sin_particion_num = gtk.Label(humanize(self.get_unasigned_space())) self.vb_sin_particion = gtk.VBox() self.vb_sin_particion.add(self.lbl_sin_particion) self.vb_sin_particion.add(self.lbl_sin_particion_num) self.vb_sin_particion.show_all() self.hb_leyenda = gtk.HBox() self.hb_leyenda.add(self.vb_tamano) self.hb_leyenda.add(self.vb_usado) self.hb_leyenda.add(self.vb_libre) self.hb_leyenda.add(self.vb_sin_particion) self.hb_leyenda.show_all() self.cont = gtk.VBox() self.cont.add(self.lbl_dispositivo) self.cont.add(self.hb_leyenda) self.cont.add(self.escala) self.cont.show() self.vbox.pack_start(self.cont) self.process_response(self.run())
def __init__(self, data): gtk.VBox.__init__(self) self.data = data self.disco = self.data['metodo']['disco'][0] self.tabla = TablaParticiones() #self.tabla.set_doble_click(self.activar_tabla); self.tabla.set_seleccionar(self.table_row_selected) label = gtk.Label(_("""Use the following table to modify disk \ partitions to your liking. We recommend: - Establish a minimum of {0} for the root partition (/). - Create a swap space.""").format(humanize(ESPACIO_TOTAL))) label.set_line_wrap(False) label.set_justify(gtk.JUSTIFY_LEFT) label.set_alignment(0, 0) label.show() self.pack_start(label, False, False, 0) self.scroll = gtk.ScrolledWindow() self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.scroll.set_size_request(0, 150) self.scroll.add(self.tabla) self.tabla.show() self.scroll.show() self.pack_start(self.scroll, True, True, 10) # btn_nueva self.btn_nueva = gtk.Button(_("New...")) image = gtk.Image() image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_nueva.set_image(image) self.btn_nueva.show() self.btn_nueva.connect("clicked", self.new_partition) # btn_editar self.btn_editar = gtk.Button(_("Edit...")) image = gtk.Image() image.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_editar.set_image(image) self.btn_editar.show() self.btn_editar.connect("clicked", self.edit_partition) # btn_eliminar self.btn_eliminar = gtk.Button(_("Delete")) image = gtk.Image() image.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_eliminar.set_image(image) self.btn_eliminar.show() self.btn_eliminar.connect("clicked", self.delete_partition) # btn_redimension self.btn_redimension = gtk.Button(_("Resize...")) image = gtk.Image() image.set_from_stock(gtk.STOCK_INDENT, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_redimension.set_image(image) self.btn_redimension.show() self.btn_redimension.connect("clicked", self.resize_partition) # btn_deshacer self.btn_deshacer = gtk.Button(_("Undo all")) image = gtk.Image() image.set_from_stock(gtk.STOCK_UNDO, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_deshacer.set_image(image) self.btn_deshacer.show() self.btn_deshacer.connect("clicked", self.undo_all_actions) self.botonera1 = gtk.HButtonBox() self.botonera1.set_layout(gtk.BUTTONBOX_START) self.botonera1.set_homogeneous(False) self.botonera1.add(self.btn_nueva) self.botonera1.add(self.btn_editar) self.botonera1.add(self.btn_redimension) self.botonera1.add(self.btn_eliminar) self.botonera1.add(self.btn_deshacer) self.pack_start(self.botonera1, False, False, 0) # llenar la tabla por primera vez self.initialize(data)
def __init__(self, disco, lista, fila, acciones): self.sector = get_sector_size(disco) self.lista = lista self.acciones = acciones self.num_fila_act = get_row_index(lista, fila) self.dispositivo = fila[TblCol.DISPOSITIVO] self.formato = fila[TblCol.FORMATO] self.inicio = fila[TblCol.INICIO] self.fin = fila[TblCol.FIN] self.usado = floatify(fila[TblCol.USADO]) gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) gtk.Window.set_position(self, gtk.WIN_POS_CENTER_ALWAYS) self.set_title("Redimensionar Partición") self.set_size_request(400, 200) self.set_resizable(0) self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) self.set_response_sensitive(gtk.RESPONSE_OK, False) self.set_default_response(gtk.RESPONSE_CANCEL) self.escala = gtk.HScale() self.escala.set_draw_value(False) adj = gtk.Adjustment(self.fin, self.inicio, self.get_maximum_size(), 1.0, 1024.0, 0.0) adj.connect("value-changed", self.escala_value_changed) self.escala.set_adjustment(adj) self.escala.show() self.lbl_dispositivo = gtk.Label("Partición '%s'" % self.dispositivo) self.lbl_dispositivo.show() self.lbl_tamano = gtk.Label('Tamaño') self.lbl_tamano_num = gtk.Label(humanize( self.get_new_partition_size())) self.vb_tamano = gtk.VBox() self.vb_tamano.add(self.lbl_tamano) self.vb_tamano.add(self.lbl_tamano_num) self.vb_tamano.show_all() self.lbl_usado = gtk.Label('Usado') self.lbl_usado_num = gtk.Label(humanize(self.usado)) self.vb_usado = gtk.VBox() self.vb_usado.add(self.lbl_usado) self.vb_usado.add(self.lbl_usado_num) self.vb_usado.show_all() self.lbl_libre = gtk.Label('Libre') self.lbl_libre_num = gtk.Label(humanize(self.get_free_space())) self.vb_libre = gtk.VBox() self.vb_libre.add(self.lbl_libre) self.vb_libre.add(self.lbl_libre_num) self.vb_libre.show_all() self.lbl_sin_particion = gtk.Label('Sin Particionar') self.lbl_sin_particion_num = gtk.Label( humanize(self.get_unasigned_space())) self.vb_sin_particion = gtk.VBox() self.vb_sin_particion.add(self.lbl_sin_particion) self.vb_sin_particion.add(self.lbl_sin_particion_num) self.vb_sin_particion.show_all() self.hb_leyenda = gtk.HBox() self.hb_leyenda.add(self.vb_tamano) self.hb_leyenda.add(self.vb_usado) self.hb_leyenda.add(self.vb_libre) self.hb_leyenda.add(self.vb_sin_particion) self.hb_leyenda.show_all() self.cont = gtk.VBox() self.cont.add(self.lbl_dispositivo) self.cont.add(self.hb_leyenda) self.cont.add(self.escala) self.cont.show() self.vbox.pack_start(self.cont) self.process_response(self.run())
def seleccionar_disco(self, widget=None): primarias = 0 extendidas = 0 logicas = 0 self.metodos = [] try: self.barra_part.expose() except: pass self.cmb_metodo.get_model().clear() self.cmb_metodo.set_sensitive(False) CFG["w"].siguiente.set_sensitive(False) self.lbl4.set_text("") self.disco = self.cmb_discos.get_active_text() print "{0} seleccionado".format(self.disco) self.particiones = self.part.lista_particiones(self.disco) if len(self.particiones) == 0: UserMessage( message="El disco {0} necesita una tabla de particiones para poder continuar con la instalación. ¿Desea crear una tabla de particiones ahora?.\n\nSi presiona cancelar no podrá utilizar este disco para instalar Canaima.".format( self.disco ), title="Tabla de particiones no encontrada".format(self.disco), mtype=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK_CANCEL, c_1=gtk.RESPONSE_OK, f_1=self.part.nueva_tabla_particiones, p_1=(self.disco, "msdos"), c_2=gtk.RESPONSE_OK, f_2=self.seleccionar_disco, p_2=(), ) else: try: self.barra_part.expose() except: pass self.total = self.particiones[0][9] CFG["w"].siguiente.set_sensitive(True) self.cmb_metodo.set_sensitive(True) mini = self.particiones[0][1] mfin = self.particiones[0][9] for t in self.particiones: if mini > t[1]: mini = t[1] if mfin < t[2]: mfin = t[2] if t[5] == "primary" and t[4] != "free": primarias += 1 elif t[5] == "logical" and t[4] != "free": logicas += 1 elif t[5] == "extended": extendidas += 1 disco_array = [self.disco, mini, mfin, primarias, extendidas, logicas] if self.total >= self.minimo: for p in self.particiones: part = p[0] tam = p[3] fs = p[4] tipo = p[5] libre = p[8] if fs != "free" and libre >= self.minimo: if fs in FSPROGS: if tipo == "logical" and FSPROGS[fs][1][0] != "": if logicas < 10: self.metodos.append( { "tipo": "REDIM", "msg": "Instalar redimensionando {0} para liberar espacio ({1} libres)".format( part, humanize(libre) ), "part": p, "disco": disco_array, } ) elif tipo == "primary" and FSPROGS[fs][1][0] != "": if (extendidas < 1 and primarias < 4) or (extendidas > 0 and primarias < 2): self.metodos.append( { "tipo": "REDIM", "msg": "Instalar redimensionando {0} para liberar espacio ({1} libres)".format( part, humanize(libre) ), "part": p, "disco": disco_array, } ) if fs == "free" and tam >= self.minimo: if tipo == "logical": if logicas < 10: self.metodos.append( { "tipo": "LIBRE", "msg": "Instalar usando espacio libre disponible ({0})".format(humanize(tam)), "part": p, "disco": disco_array, } ) elif tipo == "primary": if (extendidas < 1 and primarias < 4) or (extendidas > 0 and primarias < 2): self.metodos.append( { "tipo": "LIBRE", "msg": "Instalar usando espacio libre disponible ({0})".format(humanize(tam)), "part": p, "disco": disco_array, } ) self.metodos.append( { "tipo": "TODO", "msg": "Instalar usando todo el disco ({0})".format(humanize(self.total)), "part": disco_array, "disco": disco_array, } ) self.metodos.append( { "tipo": "MANUAL", "msg": "Instalar editando particiones manualmente".format(humanize(tam)), "part": disco_array, "disco": disco_array, } ) else: self.metodos.append({"tipo": "NONE", "msg": "El tamaño del disco no es suficiente"}) CFG["w"].siguiente.set_sensitive(False) self.cmb_metodo.set_sensitive(False) for k in sorted(self.metodos, key=lambda ordn: ordn["tipo"], reverse=True): self.cmb_metodo.append_text(k["msg"]) self.cmb_metodo.set_active(0)
def __init__(self, data): gtk.VBox.__init__(self) self.data = data self.disco = self.data["metodo"]["disco"][0] self.tabla = TablaParticiones() # self.tabla.set_doble_click(self.activar_tabla); self.tabla.set_seleccionar(self.table_row_selected) label = gtk.Label( """Utilice la siguiente tabla para modificar \ las particiones en disco a su gusto. Le recomendamos: - Establecer un minimo de {0} para la partición raíz (/). - Crear un área de intercambio (swap).""".format( humanize(ESPACIO_TOTAL) ) ) label.set_line_wrap(False) label.set_justify(gtk.JUSTIFY_LEFT) label.set_alignment(0, 0) label.show() self.pack_start(label, False, False, 0) self.scroll = gtk.ScrolledWindow() self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.scroll.set_size_request(0, 150) self.scroll.add(self.tabla) self.tabla.show() self.scroll.show() self.pack_start(self.scroll, True, True, 10) # btn_nueva self.btn_nueva = gtk.Button("Nueva") image = gtk.Image() image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_nueva.set_image(image) self.btn_nueva.show() self.btn_nueva.connect("clicked", self.new_partition) # btn_editar self.btn_editar = gtk.Button("Editar") image = gtk.Image() image.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_editar.set_image(image) self.btn_editar.show() self.btn_editar.connect("clicked", self.edit_partition) # btn_eliminar self.btn_eliminar = gtk.Button("Eliminar") image = gtk.Image() image.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_eliminar.set_image(image) self.btn_eliminar.show() self.btn_eliminar.connect("clicked", self.delete_partition) # btn_redimension self.btn_redimension = gtk.Button("Redimensionar") image = gtk.Image() image.set_from_stock(gtk.STOCK_INDENT, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_redimension.set_image(image) self.btn_redimension.show() self.btn_redimension.connect("clicked", self.resize_partition) # btn_deshacer self.btn_deshacer = gtk.Button("Deshacer todo") image = gtk.Image() image.set_from_stock(gtk.STOCK_UNDO, gtk.ICON_SIZE_SMALL_TOOLBAR) self.btn_deshacer.set_image(image) self.btn_deshacer.show() self.btn_deshacer.connect("clicked", self.undo_all_actions) self.botonera1 = gtk.HButtonBox() self.botonera1.set_layout(gtk.BUTTONBOX_START) self.botonera1.set_homogeneous(False) self.botonera1.add(self.btn_nueva) self.botonera1.add(self.btn_editar) self.botonera1.add(self.btn_redimension) self.botonera1.add(self.btn_eliminar) self.botonera1.add(self.btn_deshacer) self.pack_start(self.botonera1, False, False, 0) # llenar la tabla por primera vez self.initialize(data)