Ejemplo n.º 1
0
    def next(self):
        if self.install_config['partitionsnumber'] == 0:
            window_height = 9
            window_width = 40
            window_starty = (self.maxy-window_height) // 2 + 5
            confirm_window = ConfirmWindow(window_height, window_width, self.maxy,
                                           self.maxx, window_starty,
                                           'Partition information cannot be empty',
                                           info=True)
            confirm_window.do_action()
            return self.display(False)
        #must have /
        if not self.has_slash:
            window_height = 9
            window_width = 40
            window_starty = (self.maxy - window_height) // 2 + 5
            confirm_window = ConfirmWindow(window_height, window_width, self.maxy,
                                           self.maxx, window_starty, 'Missing /',
                                           info=True)
            confirm_window.do_action()
            return self.display(False)

        self.window.hide_window()
        self.text_pane.hide()
        return ActionResult(True, {'goNext':True})
Ejemplo n.º 2
0
    def do_action(self):
        self.init_text()
        curses.curs_set(1)

        if self.default_string != None:
            self.textwin.addstr(self.y, 0, self.default_string)
            self.str = self.default_string

        while True:
            if len(self.str) > self.visible_text_width:
                curs_loc = self.visible_text_width
            else:
                curs_loc = len(self.str)
            ch = self.textwin.getch(self.y, curs_loc)

            update_text = False
            if ch in [curses.KEY_ENTER, ord('\n')]:
                if self.confirmation_error_msg:
                    if self.str != self.install_config[self.field]:
                        curses.curs_set(0)
                        conf_message_height = 8
                        conf_message_width = 48
                        conf_message_button_y = (self.maxy -
                                                 conf_message_height) / 2 + 5
                        confrim_window = ConfirmWindow(
                            conf_message_height, conf_message_width, self.maxy,
                            self.maxx, conf_message_button_y,
                            self.confirmation_error_msg, True)
                        confrim_window.do_action()
                        return ActionResult(False, {'goBack': True})
                    self.set_field()
                else:
                    if not self.validate_input():
                        continue
                    self.set_field()
                curses.curs_set(0)
                return ActionResult(True, None)
            elif ch in [ord('\t')]:
                curses.curs_set(0)
                return ActionResult(False, None)
            elif ch == 127:
                # Handle the backspace case
                self.str = self.str[:len(self.str) - 1]

                update_text = True

            elif len(self.str) < self.maxlength and ch in self.accepted_chars:
                self.str += chr(ch)
                update_text = True

            if update_text:
                if len(self.str) > self.visible_text_width:
                    text = self.str[-self.visible_text_width:]
                else:
                    text = self.str
                if self.echo_char:
                    text = self.echo_char * len(text)
                # Add the dashes
                text = text + '_' * (self.visible_text_width - len(self.str))
                self.textwin.addstr(self.y, 0, text)
Ejemplo n.º 3
0
    def next(self):
        if self.install_config['partitionsnumber'] == 0:
            window_height = 9
            window_width = 40
            window_starty = (self.maxy - window_height) / 2 + 5
            confirm_window = ConfirmWindow(
                window_height,
                window_width,
                self.maxy,
                self.maxx,
                window_starty,
                'Partition information cannot be empty',
                info=True)
            confirm_window.do_action()
            return self.display(False)
        #must have /
        if not self.has_slash:
            window_height = 9
            window_width = 40
            window_starty = (self.maxy - window_height) / 2 + 5
            confirm_window = ConfirmWindow(window_height,
                                           window_width,
                                           self.maxy,
                                           self.maxx,
                                           window_starty,
                                           'Missing /',
                                           info=True)
            confirm_window.do_action()
            return self.display(False)

        self.window.hide_window()
        self.text_pane.hide()
        return ActionResult(True, {'goNext': True})
Ejemplo n.º 4
0
    def do_action(self):
        self.init_text()
        curses.curs_set(1)

        while True:
            if len(self.str) > self.visible_text_width:
                curs_loc = self.visible_text_width
            else:
                curs_loc = len(self.str)
            ch = self.textwin.getch(self.y, curs_loc)

            if ch in [curses.KEY_ENTER, ord('\n')]:
                if self.confirm_pass:
                    if self.str != self.install_config['password']:
                        curses.curs_set(0)
                        conf_message_height = 8
                        conf_message_width = 40
                        conf_message_button_y = (self.maxy - conf_message_height) / 2 + 5
                        confrim_window = ConfirmWindow(conf_message_height, conf_message_width, self.maxy, self.maxx, conf_message_button_y, "passwords don't match, please try again.", True)
                        confrim_window.do_action()
                        return ActionResult(False, {'goBack': True})
                    self.install_config['password'] = self.generate_password_hash(self.str)
                elif self.ispassword:
                    err = self.validate_password(self.str)
                    if err != self.str:
                        self.init_text()
                        self.textwin.addstr(self.y + 2, 0, "Error: " + err, curses.color_pair(4))
                        continue
                    self.install_config['password'] = self.str;
                else:
                    if not self.validate_hostname(self.str):
                        self.textwin.addstr(self.y + 2, 0, "It should start with alpha char and ends with alpha-numeric char", curses.color_pair(4))
                        continue
                    self.install_config['hostname'] = self.str
                curses.curs_set(0)
                return ActionResult(True, None)
            elif ch in [ord('\t')]:
                curses.curs_set(0)
                return ActionResult(False, None)
            elif ch == 127:
                # Handle the backspace case
                self.str = self.str[:len(self.str) - 1]

                update_text = True

            elif len(self.str) < self.maxlength and ch in self.accepted_chars:
                self.str += chr(ch)
                update_text = True

            if update_text:
                if len(self.str) > self.visible_text_width:
                    text = self.str[-self.visible_text_width:]
                else:
                    text = self.str
                if self.ispassword:
                    text = '*' * len(text)
                # Add the dashes
                text = text + '_' * (self.visible_text_width - len(self.str))
                self.textwin.addstr(self.y, 0, text)
Ejemplo n.º 5
0
    def do_action(self):
        self.init_text()
        curses.curs_set(1)

        if self.default_string != None:
            self.textwin.addstr(self.y, 0, self.default_string)
            self.str = self.default_string

        while True:
            if len(self.str) > self.visible_text_width:
                curs_loc = self.visible_text_width
            else:
                curs_loc = len(self.str)
            ch = self.textwin.getch(self.y, curs_loc)

            update_text = False
            if ch in [curses.KEY_ENTER, ord('\n')]:
                if self.confirmation_error_msg:
                    if self.str != self.install_config[self.field]:
                        curses.curs_set(0)
                        conf_message_height = 8
                        conf_message_width = 48
                        conf_message_button_y = (self.maxy - conf_message_height) / 2 + 5
                        confrim_window = ConfirmWindow(conf_message_height, conf_message_width, self.maxy, self.maxx, conf_message_button_y, self.confirmation_error_msg, True)
                        confrim_window.do_action()
                        return ActionResult(False, {'goBack': True})
                    self.set_field()
                else:
                    if not self.validate_input():
                        continue
                    self.set_field()
                curses.curs_set(0)
                return ActionResult(True, None)
            elif ch in [ord('\t')]:
                curses.curs_set(0)
                return ActionResult(False, None)
            elif ch == 127:
                # Handle the backspace case
                self.str = self.str[:len(self.str) - 1]

                update_text = True

            elif len(self.str) < self.maxlength and ch in self.accepted_chars:
                self.str += chr(ch)
                update_text = True

            if update_text:
                if len(self.str) > self.visible_text_width:
                    text = self.str[-self.visible_text_width:]
                else:
                    text = self.str
                if self.echo_char:
                    text = self.echo_char * len(text)
                # Add the dashes
                text = text + '_' * (self.visible_text_width - len(self.str))
                self.textwin.addstr(self.y, 0, text)
Ejemplo n.º 6
0
    def next(self):
        if self.cp_config['partitionsnumber'] == 0:
            window_height = 9
            window_width = 40
            window_starty = (self.maxy - window_height) // 2 + 5
            confirm_window = ConfirmWindow(
                window_height,
                window_width,
                self.maxy,
                self.maxx,
                window_starty,
                'Partition information cannot be empty',
                info=True)
            confirm_window.do_action()
            return self.display()
        #must have /
        if not self.has_slash:
            window_height = 9
            window_width = 40
            window_starty = (self.maxy - window_height) // 2 + 5
            confirm_window = ConfirmWindow(window_height,
                                           window_width,
                                           self.maxy,
                                           self.maxx,
                                           window_starty,
                                           'Missing /',
                                           info=True)
            confirm_window.do_action()
            return self.display()

        self.window.hide_window()
        self.partition_pane.hide()

        partitions = []
        for i in range(int(self.cp_config['partitionsnumber'])):
            if len(self.cp_config[str(i) + 'partition_info' + str(0)]) == 0:
                sizedata = 0
            else:
                sizedata = int(self.cp_config[str(i) + 'partition_info' +
                                              str(0)])
            mtdata = self.cp_config[str(i) + 'partition_info' + str(2)]
            typedata = self.cp_config[str(i) + 'partition_info' + str(1)]

            partitions = partitions + [
                {
                    "mountpoint": mtdata,
                    "size": sizedata,
                    "filesystem": typedata
                },
            ]
        self.install_config['partitions'] = partitions

        return ActionResult(True, {'goNext': True})
Ejemplo n.º 7
0
    def guided_partitions(self, device_index):
        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        confrim_window = ConfirmWindow(
            menu_height, menu_width, self.maxy, self.maxx, menu_starty,
            'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if not confirmed:
            return ActionResult(confirmed, None)

        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        self.window.clearerror()
        partitions_data = modules.commons.partition_disk(
            self.devices[device_index].path)
        if partitions_data == None:
            self.window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)
Ejemplo n.º 8
0
    def guided_partitions(self, device_index):
        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        confrim_window = ConfirmWindow(
            menu_height, menu_width, self.maxy, self.maxx, menu_starty,
            'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if not confirmed:
            return ActionResult(confirmed, None)

        #self.install_config['disk'] = self.devices[device_index].path
        #return ActionResult(True, None)

        # Do the partitioning
        self.window.clearerror()
        json_ret = subprocess.check_output([
            'gpartedbin', 'defaultpartitions', self.devices[device_index].path
        ],
                                           stderr=open(os.devnull, 'w'))
        json_dct = json.loads(json_ret)
        if json_dct['success']:
            self.install_config['disk'] = json_dct['data']
        else:
            self.window.adderror('Partitioning failed, you may try again')
        return ActionResult(json_dct['success'], None)
Ejemplo n.º 9
0
    def guided_partitions(self, params):
        if not 'diskindex' in self.install_config:
            return ActionResult(False, None)

        device_index = self.install_config['diskindex']

        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) // 2 + 5
        self.install_config['delete_partition'] = True
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy,
                                       self.maxx, menu_starty,
                                       'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if confirmed == False:
            self.install_config['skipPrevs'] = True
            return ActionResult(False, {'goBack':True})

        self.install_config['skipPrevs'] = False
        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        if 'partitionsnumber' in self.install_config:
            if int(self.install_config['partitionsnumber']) == 0:
                partitions_data = modules.commons.partition_disk(
                    self.devices[device_index].path, modules.commons.default_partitions)
            else:
                partitions = []
                for i in range(int(self.install_config['partitionsnumber'])):
                    if len(self.install_config[str(i)+'partition_info'+str(0)]) == 0:
                        sizedata = 0
                    else:
                        sizedata = int(self.install_config[str(i) + 'partition_info' + str(0)])
                    mtdata = self.install_config[str(i) + 'partition_info' + str(2)]
                    typedata = self.install_config[str(i) + 'partition_info'+str(1)]

                    partitions = partitions + [{"mountpoint": mtdata,
                                                "size": sizedata,
                                                "filesystem": typedata},]
                partitions_data = modules.commons.partition_disk(
                    self.devices[device_index].path, partitions)
        else:
            partitions_data = modules.commons.partition_disk(
                self.devices[device_index].path, modules.commons.default_partitions)

        if partitions_data == None:
            self.partition_window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data
            arch = subprocess.check_output(['uname', '-m'], universal_newlines=True)
            if "x86" in arch:
                self.install_config['boot'] = 'dualboot'
            else:
                self.install_config['boot'] = 'efi'

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)
Ejemplo n.º 10
0
    def guided_partitions(self, params):
        if not 'diskindex' in self.install_config:
            return ActionResult(False, None)

        device_index = self.install_config['diskindex']

        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) // 2 + 5
        self.install_config['delete_partition'] = True
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy,
                                       self.maxx, menu_starty,
                                       'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if confirmed == False:
            self.install_config['skipPrevs'] = True
            return ActionResult(False, {'goBack':True})

        self.install_config['skipPrevs'] = False
        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        if 'partitionsnumber' in self.install_config:
            if int(self.install_config['partitionsnumber']) == 0:
                partitions_data = modules.commons.partition_disk(
                    self.devices[device_index].path, modules.commons.default_partitions)
            else:
                partitions = []
                for i in range(int(self.install_config['partitionsnumber'])):
                    if len(self.install_config[str(i)+'partition_info'+str(0)]) == 0:
                        sizedata = 0
                    else:
                        sizedata = int(self.install_config[str(i) + 'partition_info' + str(0)])
                    mtdata = self.install_config[str(i) + 'partition_info' + str(2)]
                    typedata = self.install_config[str(i) + 'partition_info'+str(1)]

                    partitions = partitions + [{"mountpoint": mtdata,
                                                "size": sizedata,
                                                "filesystem": typedata},]
                partitions_data = modules.commons.partition_disk(
                    self.devices[device_index].path, partitions)
        else:
            partitions_data = modules.commons.partition_disk(
                self.devices[device_index].path, modules.commons.default_partitions)

        if partitions_data == None:
            self.partition_window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)
Ejemplo n.º 11
0
 def guided_partitions(self, device_index):
     menu_height = 9
     menu_width = 40
     menu_starty = (self.maxy - menu_height) / 2 + 5
     confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
     confirmed = confrim_window.do_action().result['yes']
     
     if not confirmed:
         return ActionResult(confirmed, None)
     
     #self.install_config['disk'] = self.devices[device_index].path
     #return ActionResult(True, None)
     
     # Do the partitioning
     self.window.clearerror()
     json_ret = subprocess.check_output(['gpartedbin', 'defaultpartitions', self.devices[device_index].path], stderr=open(os.devnull, 'w'))
     json_dct = json.loads(json_ret)
     if json_dct['success']:
         self.install_config['disk'] = json_dct['data']
     else:
         self.window.adderror('Partitioning failed, you may try again')
     return ActionResult(json_dct['success'], None)
Ejemplo n.º 12
0
    def guided_partitions(self, device_index):
        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if not confirmed:
            return ActionResult(confirmed, None)

        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        self.window.clearerror()
        partitions_data = modules.commons.partition_disk(self.devices[device_index].path, modules.commons.default_partitions)
        if partitions_data == None:
            self.window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)
Ejemplo n.º 13
0
    def do_action(self):
        self.init_text()
        curses.curs_set(1)

        if self.default_string != None:
            self.textwin.addstr(self.y, 0, self.default_string)
            self.str = self.default_string

        while True:
            if len(self.str[self.position]) > self.visible_text_width:
                curs_loc = self.visible_text_width + 1
            else:
                curs_loc = len(self.str[self.position]) +1
            ch = self.textwin.getch(self.y+2+self.position*4, curs_loc)

            update_text = False
            if ch in [curses.KEY_ENTER, ord('\n')]:
                if self.menu_pos==1:
                    curses.curs_set(0)
                    self.shadowpanel.hide()
                    return ActionResult(False, None)
                if self.confirmation_error_msg:
                    if self.str != self.install_config[self.field]:
                        curses.curs_set(0)
                        conf_message_height = 8
                        conf_message_width = 48
                        conf_message_button_y = (self.maxy - conf_message_height) / 2 + 5
                        confrim_window = ConfirmWindow(conf_message_height, conf_message_width, self.maxy, self.maxx, conf_message_button_y, self.confirmation_error_msg, True)
                        confrim_window.do_action()
                        return ActionResult(False, {'goBack': True})
                    self.set_field()
                else:
                    if not self.validate_input():
                        continue
                    self.set_field()
                curses.curs_set(0)
                self.shadowpanel.hide()
                return ActionResult(True, None)
            elif ch == curses.KEY_UP:
                self.refresh(-1)

            elif ch == curses.KEY_DOWN:
                self.refresh(1)

            elif ch in [ord('\t')]:
                self.refresh(1, reset=True)

            elif ch ==curses.KEY_LEFT:
                self.menu_refresh(1)

            elif ch == curses.KEY_RIGHT:
                self.menu_refresh(-1)

            elif ch == curses.KEY_BACKSPACE:
                # Handle the backspace case
                self.str[self.position] = self.str[self.position][:len(self.str[self.position]) - 1]
                update_text = True

            elif len(self.str[self.position]) < self.maxlength and ch in self.accepted_chars:
                self.str[self.position] += chr(ch)
                update_text = True

            if update_text:
                self.update_text()
Ejemplo n.º 14
0
    def do_action(self):
        self.init_text()
        curses.curs_set(1)

        if self.default_string != None:
            self.textwin.addstr(self.y, 0, self.default_string)
            self.str = self.default_string

        while True:
            if len(self.str[self.position]) > self.visible_text_width:
                curs_loc = self.visible_text_width + 1
            else:
                curs_loc = len(self.str[self.position]) +1
            ch = self.textwin.getch(self.y + 2 + self.position * 4, curs_loc)

            update_text = False
            if ch in [curses.KEY_ENTER, ord('\n')]:
                if self.menu_pos == 1:
                    curses.curs_set(0)
                    self.shadowpanel.hide()
                    return ActionResult(False, None)
                if self.confirmation_error_msg:
                    if self.str != self.install_config[self.field]:
                        curses.curs_set(0)
                        conf_message_height = 8
                        conf_message_width = 48
                        conf_message_button_y = (self.maxy - conf_message_height) // 2 + 5
                        confrim_window = ConfirmWindow(conf_message_height, conf_message_width,
                                                       self.maxy, self.maxx, conf_message_button_y,
                                                       self.confirmation_error_msg, True)
                        confrim_window.do_action()
                        return ActionResult(False, {'goBack': True})
                    self.set_field()
                else:
                    if not self.validate_input():
                        continue
                    self.set_field()
                curses.curs_set(0)
                self.shadowpanel.hide()
                return ActionResult(True, None)
            elif ch == curses.KEY_UP:
                self.refresh(-1)

            elif ch == curses.KEY_DOWN:
                self.refresh(1)

            elif ch in [ord('\t')]:
                self.refresh(1, reset=True)

            elif ch == curses.KEY_LEFT:
                self.menu_refresh(1)

            elif ch == curses.KEY_RIGHT:
                self.menu_refresh(-1)

            elif ch == curses.KEY_BACKSPACE:
                # Handle the backspace case
                self.str[self.position] = self.str[self.position][:len(self.str[self.position]) - 1]
                update_text = True

            elif len(self.str[self.position]) < self.maxlength and ch in self.accepted_chars:
                self.str[self.position] += chr(ch)
                update_text = True

            if update_text:
                self.update_text()