예제 #1
0
    def siguiente(self, CFG):
        CFG['passroot1'] = CFG['w'].formulario('Usuario').txtpassroot1\
            .get_text()
        CFG['passroot2'] = CFG['w'].formulario('Usuario').txtpassroot2\
            .get_text()
        CFG['nombre'] = CFG['w'].formulario('Usuario').txtnombre.get_text()
        CFG['usuario'] = CFG['w'].formulario('Usuario').txtusuario.get_text()
        CFG['passuser1'] = CFG['w'].formulario('Usuario').txtpassuser1\
            .get_text()
        CFG['passuser2'] = CFG['w'].formulario('Usuario').txtpassuser2\
            .get_text()
        CFG['maquina'] = CFG['w'].formulario('Usuario').txtmaquina.get_text()
        CFG['oem'] = CFG['w'].formulario('Usuario').chkoem.get_active()
        CFG['gdm'] = CFG['w'].formulario('Usuario').chkgdm.get_active()

        if CFG['oem'] == False:
            if CFG['passroot1'].strip() == '':
                message = _("You must enter a password for the administrator.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return
            if CFG['passroot1'] != CFG['passroot2']:
                message = _("Administrator passwords do not match.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return
            if CFG['nombre'].strip() == '':
                message = _("You must enter a name.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return
            if CFG['usuario'].strip() == '':
                message = _("You must enter a user name.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return
            if re.compile('^[a-z][-a-z-0-9]*$').search(CFG['usuario']) == None:
                message = _("The user name has invalid characters.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return
            if CFG['passuser1'].strip() == '':
                message = _("You must enter a password for the user.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return
            if CFG['passuser1'] != CFG['passuser2']:
                message = _("User passwords do not match.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return
            if re.compile("^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*\
([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$").search(CFG['maquina']) == None:
                message = _("The machine name is not spelled correctly.")
                UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                            gtk.BUTTONS_OK)
                return

        CFG['w'].next('Info', Info, (CFG), PasoInfo(CFG))
        CFG['w'].pasos['Info'].grab_focus()
예제 #2
0
    def siguiente(self, CFG):
        if CFG['w'].formulario('PartManual').raiz == False:
            message = _("Root partition (/) must exists")
            UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR, gtk.BUTTONS_OK)
            return False

        CFG['acciones'] = CFG['w'].formulario('PartManual').acciones
        CFG['w'].next('Usuario', Usuario, (CFG), PasoUsuario(CFG))
        print 'CFG: {0}'.format(CFG)
예제 #3
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 = _("{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
예제 #4
0
 def close(self, widget=None, event=None):
     '''
         Cierra la ventana
     '''
     return UserMessage(
         _('Are you sure you want to cancel the installation?'),
         _('Exit'),
         gtk.MESSAGE_WARNING,
         gtk.BUTTONS_YES_NO,
         c_1=gtk.RESPONSE_YES,
         f_1=gtk.main_quit,
         p_1=())
예제 #5
0
def UserMessageError(message, window, bindlist, mountlist):
    '''Hacemos acá una especie de sobreescritura de UserMessage para resumir
    líneas de código, ya que será un método de uso frecuente en este
    módulo'''

    UserMessage(
        message,
        title='ERROR',
        mtype=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK,
        c_1=gtk.RESPONSE_OK, f_1=assisted_umount, p_1=(True, bindlist),
        c_2=gtk.RESPONSE_OK, f_2=assisted_umount, p_2=(True, mountlist),
        c_3=gtk.RESPONSE_OK, f_3=window.destroy, p_3=(),
        c_4=gtk.RESPONSE_OK, f_4=gtk.main_quit, p_4=(),
        c_5=gtk.RESPONSE_OK, f_5=sys.exit, p_5=()
    )
예제 #6
0
    def __init__(self, lista, fila_selec, acciones):
        self.lista = lista
        self.fila_selec = fila_selec
        self.acciones = acciones
        self.disco = fila_selec[TblCol.DISPOSITIVO]

        if is_primary(self.fila_selec, False) or is_logic(self.fila_selec):
            self.delete_partition(self.fila_selec)
        else:
            is_clean = True
            for partition in self.lista:
                if is_logic(partition) and not is_free(partition):
                    message = _("You must first delete the logical \
partitions.")
                    UserMessage(message, 'ERROR', gtk.MESSAGE_ERROR,
                                gtk.BUTTONS_OK)
                    is_clean = False
                    break
            if is_clean:
                i = get_row_index(self.lista, self.fila_selec)
                free = self.lista[i + 1]
                self.delete_partition(self.fila_selec)
                free[TblCol.TIPO] = msj.particion.primaria
                self.delete_partition(free)
예제 #7
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)
예제 #8
0
#
# CODE IS POETRY

from canaimainstalador.clases.common import UserMessage
from canaimainstalador.config import CFG, BANNER_IMAGE
from canaimainstalador.main import Bienvenida, Wizard
from canaimainstalador.translator import MAIN_ROOT_ERROR_MSG, \
    MAIN_ROOT_ERROR_TITLE, gettext_install
import gtk
import os
import sys

gettext_install()

if __name__ == "__main__":
    if os.geteuid() != 0:
        dialog = UserMessage(message=MAIN_ROOT_ERROR_MSG,
                             title=MAIN_ROOT_ERROR_TITLE,
                             mtype=gtk.MESSAGE_ERROR,
                             buttons=gtk.BUTTONS_OK,
                             c_1=gtk.RESPONSE_OK,
                             f_1=sys.exit,
                             p_1=(1, ))
    else:
        CFG['w'] = Wizard(700, 470, _('Canaima Installation'), BANNER_IMAGE)
        b = Bienvenida(CFG)
        a = b.init(CFG)

        gtk.main()
        sys.exit()