예제 #1
0
파일: l_connector.py 프로젝트: AnTAVR/aai2
    def dialog_configured(self) -> bool:
        help_txt: List[str] = [_('Подождите...'), '', '*' * 30]

        sec = 0

        ModuleInterface.my_dialog.gauge_start('\n'.join(help_txt), percent=sec)

        while sec < self.CONFIGURED_TIMEOUT:
            ret = networkctl('list', self.opti_.iface)
            if ret.returncode:
                return True
            ret = ret.stdout.decode()
            ret = ret.split()
            if ret[4] == 'configured':
                return True
            elif ret[4] == 'configuring':
                ret[4] = ColorTxt(ret[4]).yellow.bold
            else:
                ret[4] = ColorTxt(ret[4]).red.bold

            help_txt[2] = ' '.join(ret)

            ModuleInterface.my_dialog.gauge_update(
                int(sec / self.CONFIGURED_TIMEOUT * 100), '\n'.join(help_txt),
                True)

            time.sleep(1)
            sec += 1

        ModuleInterface.my_dialog.gauge_stop()
        return False
예제 #2
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def menu_item(self) -> Tuple[str, str]:
        text = [
            ColorTxt('(' + _('ВЫПОЛНЕНО') + ')').green.bold if self.is_run else
            ColorTxt('(' + _('ОБЯЗАТЕЛЬНО!!!') + ')').red.bold
        ]

        return super().get_menu_item(text)
예제 #3
0
파일: m_mount_home.py 프로젝트: AnTAVR/aai2
    def menu_item(self) -> Tuple[str, str]:
        text = [
            self.opti_.partition,
            ColorTxt('(' + _('ВЫПОЛНЕНО') + ')').green.bold if self.is_run else
            ColorTxt('(' + _('Рекомендуется') + ')').yellow.bold
        ]

        return super().get_menu_item(text)
예제 #4
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def menu_item(self) -> Tuple[str, str]:
        text = [
            ColorTxt('(' + _('ВЫПОЛНЕНО') + ')').green.bold if self.is_run else
            ColorTxt('(' + _('ОБЯЗАТЕЛЬНО!!!') + ')').red.bold
        ]
        if not Iface.get_ifaces():
            text.append(ColorTxt(_('УСТРОЙСТВА НЕ НАЙДЕНЫ!!!')).red.bold)

        return super().get_menu_item(text)
예제 #5
0
파일: m_static.py 프로젝트: AnTAVR/aai2
    def dialog_gateway(self) -> Tuple[str, str]:
        key = 'gateway'

        demo_text = ''  # todo: Доделать выбор для ipv4 и ipv6!
        demo_text = ColorTxt(demo_text).blue.bold

        default = ''
        if self.opti_.address is not None:
            if self.opti_.ipv4:
                address = self.opti_.address.split('.')
                address[3] = '2'
                default = '.'.join(address)
            else:
                pass  # todo: Доделать выбор для ipv6!

        help_txt = self._head_txt()
        help_txt += ['', _('Введите шлюз ({})').format(key), demo_text]

        while True:
            code, value = self._dialog_inputbox(default,
                                                help_txt)  # type: str str
            if code in self.my_dialog.ESC_CANCEL:
                return code, value
            if self.test_gateway(value):
                return code, value
            default = value
예제 #6
0
파일: m_static.py 프로젝트: AnTAVR/aai2
    def dialog_netmask(self) -> Tuple[str, str]:
        key = 'netmask'

        demo_text = ''  # todo: Доделать выбор для ipv4 и ipv6!
        demo_text = ColorTxt(demo_text).blue.bold

        default = ''
        if self.opti_.ipv4:
            default = '255.255.255.0'
        else:
            pass  # todo: Доделать выбор для ipv6!

        help_txt = self._head_txt()
        help_txt += [
            '', _('Введите маску подсети ({})').format(key), demo_text
        ]

        while True:
            code, value = self._dialog_inputbox(default,
                                                help_txt)  # type: str str
            if code in self.my_dialog.ESC_CANCEL:
                return code, value
            if self.test_netmask(value):
                return code, value
            default = value
예제 #7
0
파일: l_net.py 프로젝트: AnTAVR/aai2
    def dialog_dns(self, test_: bool = False) -> Tuple[str, str]:
        key = 'dns'

        default = '8.8.8.8' if self.opti_.ipv4 else '2001:4860:4860::8888'

        demo_text = 'google DNS: '
        demo_text += default
        demo_text = ColorTxt(demo_text).blue.bold

        help_txt = self._head_txt()
        help_txt += ['', _('Введите DNS сервер ({})').format(key),
                     demo_text]

        if self.opti_.address is None:
            default = ''

        while True:
            code, value = self._dialog_inputbox(default, help_txt)  # type: str str
            if code in self.my_dialog.ESC_CANCEL:
                return code, value
            if not test_ and not value:
                return code, value
            if self.test_dns(value):
                return code, value
            default = value
예제 #8
0
    def menu_item(self) -> Tuple[str, str]:
        text = [
            self.opti_.swap_size,
            ColorTxt('(' + _('ВЫПОЛНЕНО') +
                     ')').green.bold if self.is_run else ''
        ]

        return super().get_menu_item(text)
예제 #9
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_test_connect(self, cmd: List[str]) -> subprocess.Popen:
        help_txt: List[str] = [
            _('Подождите...'), '',
            subprocess.list2cmdline(cmd)
        ]
        help_txt: str = '\n'.join(help_txt)
        help_txt: str = ColorTxt(help_txt).green.bold

        t, p = self.my_dialog.progressbox_cmd(cmd, help_txt, title=self.name)
        return p
예제 #10
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_localtime(self) -> Tuple[str, str]:
        items = [('UTC', _('Всемирное координированное время')),
                 ('LOCAL', _('Местное время') + ' ' + ColorTxt(_('(КАТЕГОРИЧЕСКИ НЕ РЕКОМЕНДУЕТСЯ)')).red.bold)]

        help_txt = self._head_txt()
        help_txt += ['', _('Выберите тип аппаратных часов')]

        default = 'UTC'

        return self._dialog_menu(items, default, help_txt)
예제 #11
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_hostname(self) -> Tuple[str, str]:
        demo_text = 'hostname.domain.org'
        demo_text = ColorTxt(demo_text).blue.bold

        help_txt = self._head_txt()
        help_txt += ['', _('Введите имя компьютера'),
                     demo_text]

        default = 'hostname.' + self.opti_.country.lower()

        return self._dialog_inputbox(default, help_txt)
예제 #12
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_type(self, modules_: ModuleCollection,
                    default: str) -> Tuple[str, str]:
        help_txt = [
            _('Сетевой адаптер: {}').format(ColorTxt(self.iface).green.bold),
            '',
            _('Выберите тип подключения')
        ]

        return self._dialog_menu(modules_.menu_items,
                                 default,
                                 help_txt,
                                 cancel_label=_('Назад'))
예제 #13
0
파일: m_markup.py 프로젝트: AnTAVR/aai2
    def dialog_command(self) -> Tuple[str, str]:
        items = [
            # ('cfdisk', 'MBR'),
            ('fdisk', 'MBR and GPT ' +
             ColorTxt('(' + _('Рекомендуется') + ')').yellow.bold),
            # ('sfdisk', 'MBR'),
            ('parted', '-'),
            # ('cgdisk', 'GPT'),
            # ('gdisk', 'GPT'),
            # ('sgdisk', 'GPT'),
        ]

        default = self.opti_.command or 'fdisk'

        help_txt = self._head_txt()
        help_txt += ['', _('Выберите программу для разметки')]

        return self._dialog_menu(items, default, help_txt)
예제 #14
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_locale(self) -> Tuple[str, str]:
        timezones = DbTimezones().read()
        locales = DbLocales().read()

        items = locales.menu_items

        help_txt = self._head_txt()
        help_txt += ['', _('Выберите локаль')]

        timezone = timezones.get(self.opti_.timezone, 'timezone')
        default = ''
        if timezone:
            default = timezone.default_locale
        else:
            help_txt.append('')
            help_txt.append(ColorTxt(_('В базе {} нет локали по умолчанию для часового пояса <{}> !!!').format(
                timezones.db_file_name, self.opti_.timezone)).red.bold)

        return self._dialog_menu(items, default, help_txt)
예제 #15
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_timezone(self) -> Tuple[str, str]:
        domains = DbDomains().read()
        timezones = DbTimezones().read()

        items = timezones.menu_items

        help_txt = self._head_txt()
        help_txt += ['', _('Выберите часовой пояс')]

        country = domains.get(self.opti_.country)
        default = ''
        if country:
            default = country.default_timezone
        else:
            help_txt.append('')
            help_txt.append(ColorTxt(_('В базе {} нет часового пояса по умолчанию для домена <{}> !!!').format(
                domains.db_file_name, self.opti_.country)).red.bold)

        return self._dialog_menu(items, default, help_txt)
예제 #16
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_font(self) -> Tuple[str, str]:
        locales = DbLocales().read()
        fonts = DbFonts().read()

        items = fonts.menu_items

        help_txt = self._head_txt()
        help_txt += ['', _('Выберите шрифт')]

        locale = locales.get(self.opti_.locale, 'locale')
        default = ''
        if locale:
            default = locale.default_font
        else:
            help_txt.append('')
            help_txt.append(ColorTxt(_('В базе {} нет шрифта по умолчанию для локали <{}> !!!').format(
                locales.db_file_name, self.opti_.locale)).red.bold)

        return self._dialog_menu(items, default, help_txt)
예제 #17
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_keymap(self) -> Tuple[str, str]:
        locales = DbLocales().read()
        keymaps = DbKeymaps().read()

        items = keymaps.menu_items

        help_txt = self._head_txt()
        help_txt += ['', _('Выберите раскладку клавиатуры')]

        locale = locales.get(self.opti_.locale, 'locale')
        default = ''
        if locale:
            default = locale.default_keymap
        else:
            help_txt.append('')
            help_txt.append(ColorTxt(_('В базе {} нет раскладки по умолчанию для локали <{}> !!!').format(
                locales.db_file_name, self.opti_.locale)).red.bold)

        return self._dialog_menu(items, default, help_txt)
예제 #18
0
파일: m_static.py 프로젝트: AnTAVR/aai2
    def dialog_address(self) -> Tuple[str, str]:
        key = 'address'

        demo_text = 'формат: ipv4 192.168.0.2 ipv6 2002:C0A8:2::'
        demo_text = ColorTxt(demo_text).blue.bold

        default = '10.0.2.15'

        help_txt = self._head_txt()
        help_txt += ['', _('Введите IP адрес ({})').format(key), demo_text]

        while True:
            code, value = self._dialog_inputbox(default,
                                                help_txt)  # type: str str
            if code in self.my_dialog.ESC_CANCEL:
                return code, value
            if self.test_address(value):
                return code, value
            default = value
예제 #19
0
파일: l_net.py 프로젝트: AnTAVR/aai2
    def dialog_proxy(self) -> Tuple[str, List[str]]:
        demo_text = 'protocol://*****:*****@server:port/'
        demo_text = ColorTxt(demo_text).blue.bold

        help_txt = self._head_txt()
        help_txt += ['', _('Введите прокси сервера'),
                     demo_text]

        help_txt = '\n'.join(help_txt)

        title_column = 1
        field_column = 15
        field_length = 45
        input_length = 120
        elements = (
            # title, title_row, title_column, field, field_row, field_column, field_length, input_length
            ('http_proxy', 1, title_column, '', 1, field_column, field_length, input_length),
            ('https_proxy', 3, title_column, '', 3, field_column, field_length, input_length),
            ('ftp_proxy', 5, title_column, '', 5, field_column, field_length, input_length),
        )
        return self.my_dialog.form(help_txt, elements, 20, 70, 5, title=self.name)
예제 #20
0
파일: m_main.py 프로젝트: AnTAVR/aai2
    def dialog_font_unimap(self) -> Tuple[str, str]:
        fonts = DbFonts().read()
        fontunimaps = DbFontUnimaps().read()

        items = fontunimaps.menu_items
        items.insert(0, (self.DEFAULT_ITEM, self.DEFAULT_ITEM))

        help_txt = self._head_txt()
        help_txt += ['', _('Выберите unicode карту шрифта')]

        font = fonts.get(self.opti_.font)
        default = ''
        if font:
            default = font.font_unimap
        else:
            help_txt.append('')
            help_txt.append(ColorTxt(_('В базе {} нет unicode карты шрифта по умолчанию для шрифта <{}> !!!').format(
                fonts.db_file_name, self.opti_.font)).red.bold)
        if not default:
            default = self.DEFAULT_ITEM

        return self._dialog_menu(items, default, help_txt)
예제 #21
0
파일: m_markup.py 프로젝트: AnTAVR/aai2
    def dialog_parts(self) -> Tuple[str, str]:
        items = format_items(self._get_parts())

        default = ''

        type_txt = _('тип {}')

        # noinspection PyListCreation
        help_txt: List[str] = []

        help_txt.append(
            _('Цветом отмечены форматы таблицы разделов {}').format(' '.join((
                ColorTxt('MBR').cyan.bold,
                ColorTxt('GPT').magenta.bold,
            ))))
        help_txt.append('')
        help_txt.append(
            _('Загрузка BIOS GPT - 2MiB, {}').format(
                type_txt.format(ColorTxt('(4) BIOS boot').magenta.bold), ))
        # help_txt.append('MBR GPT - 2MiB, {}'.format(
        #     type_txt.format('(ee) GPT'),
        # ))
        # help_txt.append('GPT MBR - 2MiB, {}'.format(
        #     type_txt.format('(2) MBR partition scheme'),
        # ))

        help_txt.append('/boot/efi - 128MiB-512MiB ({}) {}'.format(
            ColorTxt('128MiB').green.bold,
            type_txt.format(' | '.join((
                ColorTxt('(ef) EFI (FAT-12/16/32)').cyan.bold,
                ColorTxt('(1) EFI System').magenta.bold,
            ))),
        ))
        help_txt.append(
            TWO_SPACE +
            'FLASH DRIVE ({}) {}'.format(ColorTxt('32MiB').green.bold, ''))

        help_txt.append('/boot - 32MiB-512MiB ({}) {}'.format(
            ColorTxt('128MiB').green.bold,
            type_txt.format(' | '.join((
                ColorTxt('(83) Linux').cyan.bold,
                ColorTxt('(15) Linux filesystem').magenta.bold,
            ))) + ' ' + ColorTxt('(' + _('Рекомендуется') + ')').yellow.bold,
        ))
        help_txt.append(TWO_SPACE + 'FLASH DRIVE ({}) {}'.format(
            ColorTxt('32MiB').green.bold,
            type_txt.format(' | '.join((
                ColorTxt('(07) HPFS/NTFS/exFAT').cyan.bold,
                ColorTxt('(0B) W95 FAT32').cyan.bold,
                ColorTxt('(6) Microsoft basic data').magenta.bold,
            ))),
        ))
        help_txt.append(TWO_SPACE +
                        ColorTxt(_('Нужно сделать загрузочным!!!')).cyan.bold)

        help_txt.append('/ (root) - 4GiB-32GiB ({}) {}'.format(
            ColorTxt('32GiB').green.bold,
            type_txt.format(' | '.join((
                ColorTxt('(83) Linux').cyan.bold,
                ColorTxt('(18) Linux root (x86-64)').magenta.bold,
            ))) + ' ' + ColorTxt('(' + _('ОБЯЗАТЕЛЬНО!!!') + ')').red.bold,
        ))

        help_txt.append('/home - ({}) {}'.format(
            ColorTxt(_('все остальное место')).green.bold,
            type_txt.format(' | '.join((
                ColorTxt('(83) Linux').cyan.bold,
                ColorTxt('(20) Linux home').magenta.bold,
            ))) + ' ' + ColorTxt('(' + _('Рекомендуется') + ')').yellow.bold,
        ))
        help_txt.append(
            TWO_SPACE +
            _('10GiB на одного пользователя и 20GiB на бэкапы и кеш системы'))
        help_txt.append(TWO_SPACE + _(
            'Если установка на FLASH DRIVE, то можно не использовать отдельный раздел'
        ))

        help_txt.append(
            _('swap - RAM*2 ({}) {}').format(
                ColorTxt('{}-{} {}'.format(*default_size_swap())).green.bold,
                type_txt.format(' | '.join((
                    ColorTxt('(82) Linux swap / Solaris').cyan.bold,
                    ColorTxt('(14) Linux swap').magenta.bold,
                ))),
            ))
        help_txt.append(
            TWO_SPACE +
            _('Можно потом сделать swap в файл, если фс / (root) {}'.format(
                '|'.join(SWAP_FS_TYPES))))

        help_txt.append('')
        help_txt.append(_('Выберите устройство для разметки'))

        return self._dialog_menu(items, default, help_txt)
예제 #22
0
파일: m_main.py 프로젝트: AnTAVR/aai2
 def menu_item(self) -> Tuple[str, str]:
     return self.ID, ColorTxt(self.name).green.bold