Exemplo n.º 1
0
 def action_lib():
     try:
         partition_lib.action(op,
                              name,
                              start=start,
                              end=end,
                              fstype=fstype)
         self._scan_lib()
     except Exception:
         self.add_log_lib(traceback.format_exc())
Exemplo n.º 2
0
 def action_lib():
     try:
         partition_lib.action(op,
                              name,
                              size=size,
                              parttable=parttable,
                              crypt=crypt,
                              passphrase=passphrase)
         self._scan_lib()
     except Exception:
         self.add_log_lib(traceback.format_exc())
Exemplo n.º 3
0
 def action_lib():
     try:
         partition_lib.action(op, name)
         self._scan_lib()
     except Exception:
         self.add_log_lib(traceback.format_exc())
Exemplo n.º 4
0
    def _handle_action(self, name, size, op):
        if op == 'autosetup':
            res, text = dialog.inputbox(
                text='Partitioning type (msdos, gpt, ...):',
                init=partition_lib.default_partitioning)
            if res != dialog.OK:
                return False
            res = dialog.yesno(text='Enable encryption?', defaultno=True)
            passphrase = ''
            if res == dialog.OK:
                res2, passphrase = dialog.passwordbox(text='Enter passphrase:',
                                                      insecure=True)
                if res2 != dialog.OK:
                    return False
                res2, passphrase2 = dialog.passwordbox(
                    text='Confirm passphrase:', insecure=True)
                if res2 != dialog.OK:
                    return False
                if passphrase2 != passphrase:
                    dialog.msgbox('Passphrases do not match.')
                    return False
            res2 = dialog.yesno(
                text='Are you sure you want to wipe this disk?')
            if res2 != dialog.OK:
                return False

            partition_lib.action(op,
                                 name,
                                 size=size,
                                 parttable=text,
                                 crypt=(res == dialog.OK),
                                 passphrase=passphrase)

            self._switch_to_finish = True

        elif op == 'parttable':
            res, text = dialog.inputbox(
                text=partition_lib.get_text_for_op(op) + '\n\n' +
                'Partitioning type (msdos, gpt, ...):',
                init=partition_lib.default_partitioning)
            if res != dialog.OK:
                return False
            res = dialog.yesno(text='Are you sure you want to wipe this disk?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, parttable=text)

        elif op == 'part':
            info = name.split('*')
            res, lst = dialog.form(
                text=partition_lib.get_text_for_op(op) + '\n',
                elements=[('Disk', 1, 1, info[1], 1, 48, -32, 1024),
                          ('Start', 3, 1, info[2], 3, 48, 32, 1024),
                          ('End', 5, 1, info[3], 5, 48, 32, 1024),
                          ('Filesystem (ext4, linux-swap, fat32, ...)', 7, 1,
                           partition_lib.default_filesystem, 7, 48, 32, 1024)])
            if res != dialog.OK:
                return False

            partition_lib.action(op,
                                 name,
                                 start=lst[0],
                                 end=lst[1],
                                 fstype=lst[2])

        elif op == 'format':
            res, text = dialog.inputbox(
                text=partition_lib.get_text_for_op(op) + '\n\n' +
                'Filesystem type (ext4, swap, fat, ...):',
                init=partition_lib.default_filesystem)
            if res != dialog.OK:
                return False
            res = dialog.yesno(text='Are you sure?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, fstype=text)

        elif op == 'remove':
            res = dialog.yesno(text='Are you sure?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name)

        elif op == 'cryptsetup':
            res, passphrase = dialog.passwordbox(text='Enter passphrase:',
                                                 insecure=True)
            if res != dialog.OK:
                return False

            res, passphrase2 = dialog.passwordbox(text='Confirm passphrase:',
                                                  insecure=True)
            if res != dialog.OK:
                return False
            if passphrase2 != passphrase:
                dialog.msgbox('Passphrases do not match.')
                return False

            res = dialog.yesno(text='Are you sure?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, passphrase=passphrase)

        elif op in ['cryptopen', 'swap-cryptopen']:
            res, passphrase = dialog.passwordbox(text='Enter passphrase:',
                                                 insecure=True)
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, passphrase=passphrase)

        else:
            partition_lib.action(op, name)

        return True