def __init__(self, controller): self.controller = controller found_disk = False found_ok_disk = False for disk in controller.model.all_disks(): found_disk = True if disk.size > 6 * (2**30): found_ok_disk = True break if found_ok_disk: self.form = GuidedForm(model=controller.model) connect_signal(self.form, 'submit', self.done) connect_signal(self.form, 'cancel', self.cancel) super().__init__( self.form.as_screen(focus_buttons=False, excerpt=_(subtitle))) elif found_disk: super().__init__( screen([Text(rewrap(_(no_big_disks)))], [other_btn(_("OK"), on_press=self.manual)])) else: super().__init__(screen([Text(rewrap(_(no_disks)))], []))
def make_serial_choices(self): ssh_password = get_installer_password(self.controller.opts.dry_run) ips = get_global_addresses(self.controller.app) btns = [ other_btn(label="Switch to rich mode", on_press=self.enable_rich), forward_btn(label="Continue in basic mode", on_press=self.choose_language, user_arg='C'), ] widgets = [ Text(""), Text(rewrap(SERIAL_TEXT)), Text(""), ] if ssh_password and ips: widgets.append(Text(rewrap(SSH_TEXT))) widgets.append(Text("")) btns.insert( 1, other_btn(label="View SSH instructions", on_press=self.ssh_help, user_arg=ssh_password)) widgets.extend([ button_pile(btns), ]) lb = ListBox(widgets) return screen(lb, buttons=None)
def __init__(self, parent, title, text): widgets = [ Text(rewrap(text)), Text(""), button_pile([close_btn(parent)]), ] super().__init__(title, widgets, 0, 2)
def __init__(self, app): rows = [] keys = GLOBAL_KEYS if app.opts.run_on_serial: keys += SERIAL_GLOBAL_HELP_KEYS for key, text in keys: rows.append(TableRow([Text(_(key)), Text(_(text))])) if app.opts.dry_run: dro = _('(dry-run only)') for key, text in DRY_RUN_KEYS: rows.append(TableRow([Text(_(key)), Text(_(text) + ' ' + dro)])) table = TablePile(rows, spacing=2, colspecs={1: ColSpec(can_shrink=True)}) widgets = [ Pile([ ('pack', Text(rewrap(GLOBAL_KEY_HELP))), ('pack', Text("")), ('pack', table), ]), Text(""), button_pile([close_btn(app, self)]), ] super().__init__(_("Shortcut Keys"), widgets, 0, 2)
def make_serial(self): self.rich_btn = forward_btn(label="Continue in rich mode", on_press=self.rich_mode) self.basic_btn = forward_btn(label="Continue in basic mode", on_press=self.basic_mode) btns = [self.rich_btn, self.basic_btn] widgets = [ Text(""), Text(rewrap(SERIAL_TEXT)), Text(""), ] if self.ssh_info: widgets.append(Text(rewrap(SSH_TEXT))) widgets.append(Text("")) btns.append( other_btn(label="View SSH instructions", on_press=self.ssh_help)) return screen(widgets, btns)
def __init__(self, controller, disks): self.controller = controller if disks: if any(disk.ok_for_guided for disk in disks): self.form = GuidedForm(disks=disks) connect_signal(self.form, 'submit', self.done) connect_signal(self.form, 'cancel', self.cancel) super().__init__( self.form.as_screen(focus_buttons=False, excerpt=_(subtitle))) else: super().__init__( screen([Text(rewrap(_(no_big_disks)))], [other_btn(_("OK"), on_press=self.manual)])) else: super().__init__(screen([Text(rewrap(_(no_disks)))], []))
def __init__(self, app): self.app = app self.shell_btn = other_btn(_("Switch to a shell"), on_press=self._debug_shell) self.close_btn = other_btn(_("Close"), on_press=self._close) widgets = [ Text(rewrap(_(CLOUD_INIT_FAIL_TEXT))), Text(''), button_pile([self.shell_btn, self.close_btn]), ] super().__init__("", widgets, stretchy_index=0, focus_index=2)
def ssh_help_texts(ips, password): texts = [_(SSH_HELP_PROLOGUE), ""] if len(ips) > 0: if len(ips) > 1: texts.append(rewrap(_(SSH_HELP_MULTIPLE_ADDRESSES))) texts.append("") for ip in ips: texts.append(Text("installer@" + str(ip), align='center')) else: texts.append(_(SSH_HELP_ONE_ADDRESSES).format(ip=str(ips[0]))) texts.append("") texts.append(rewrap(_(SSH_HELP_EPILOGUE).format(password=password))) texts.append("") texts.append(Text(host_key_info())) else: texts.append("") texts.append(_(SSH_HELP_NO_ADDRESSES)) return texts
def __init__(self, app, tty): self.app = app self.btn = Toggleable( other_btn(_("Switch to a shell"), on_press=self._debug_shell)) self.btn.enabled = False self.app.aio_loop.call_later(0.5, self._enable) widgets = [ Text(rewrap(_(running_text).format(tty=tty))), Text(''), button_pile([self.btn]), ] super().__init__("", widgets, stretchy_index=0, focus_index=2)
def __init__(self, app, title, *texts): widgets = [] for text in texts: if isinstance(text, str): text = Text(rewrap(text)) widgets.append(text) widgets.extend([ Text(""), button_pile([close_btn(app, self)]), ]) super().__init__(title, widgets, 0, len(widgets) - 1)
def __init__(self, app): self.app = app widgets = [ Text(rewrap(_(confirmation_text))), Text(""), button_pile([ cancel_btn(_("No"), on_press=self.cancel), danger_btn(_("Continue"), on_press=self.ok)]), ] super().__init__( _("Confirm destructive action"), widgets, stretchy_index=0, focus_index=2)
def update_for_wlan_support_install_state(self, state): if state == "NOT_NEEDED": return if self.error_showing: start_i = 2 else: start_i = 0 if self.wlan_support_install_state_showing: end_i = start_i + 2 else: end_i = start_i self.wlan_support_install_state_showing = True text = wlan_support_install_state_texts[state] self.bottom.contents[start_i:end_i] = [ (Text(rewrap(text), align='center'), self.bottom.options()), (Text(""), self.bottom.options()), ]
def __init__(self, app, parent): rows = [] for key, text in GLOBAL_KEYS: rows.append(TableRow([Text(_(key)), Text(_(text))])) if app.opts.dry_run: for key, text in DRY_RUN_KEYS: rows.append(TableRow([Text(_(key)), Text(_(text))])) table = TablePile(rows, spacing=2, colspecs={1: ColSpec(can_shrink=True)}) widgets = [ Pile([ ('pack', Text(rewrap(GLOBAL_KEY_HELP))), ('pack', Text("")), ('pack', table), ]), Text(""), button_pile([close_btn(parent)]), ] super().__init__(_("Shortcut Keys"), widgets, 0, 2)
def _pile_elements(self): btns = self.btns.copy() widgets = [ Text(rewrap(_(error_report_intros[self.report.kind]))), Text(""), ] self.spinner.stop() if self.report.state == ErrorReportState.DONE: widgets.append(btns['view']) widgets.append(Text("")) widgets.append(Text(rewrap(_(submit_text)))) widgets.append(Text("")) if self.report.uploader: if self.upload_pb is None: self.upload_pb = self.pb(self.report.uploader) widgets.append(self.upload_pb) else: if self.report.oops_id: widgets.append(btns['submitted']) else: widgets.append(btns['submit']) self.upload_pb = None fs_label, fs_loc = self.report.persistent_details if fs_label is not None: location_text = _( "The error report has been saved to\n\n {loc}\n\non the " "filesystem with label {label!r}.").format( loc=fs_loc, label=fs_label) widgets.extend([ Text(""), Text(location_text), ]) else: text, spin = error_report_state_descriptions[self.report.state] widgets.append(Text(rewrap(_(text)))) if spin: self.spinner.start() widgets.extend([ Text(""), self.spinner]) if self.report.uploader: widgets.extend([Text(""), btns['cancel']]) elif self.interrupting: if self.report.state != ErrorReportState.INCOMPLETE: text, btn_names = error_report_options[self.report.kind] if text: widgets.extend([Text(""), Text(rewrap(_(text)))]) for b in btn_names: widgets.extend([Text(""), btns[b]]) else: widgets.extend([ Text(""), btns['close'], ]) return widgets
def local_help(self): return (_("Help on guided storage configuration"), rewrap(_(HELP)))
def __init__(self, parent, disk, partition=None): self.disk = disk self.partition = partition self.model = parent.model self.controller = parent.controller self.parent = parent max_size = disk.free_for_partitions initial = {} label = _("Create") if isinstance(disk, LVM_VolGroup): lvm_names = {p.name for p in disk.partitions()} else: lvm_names = None if self.partition: if partition.flag in ["bios_grub", "prep"]: label = None initial['mount'] = None elif partition.flag == "boot" and not partition.grub_device: label = None else: label = _("Save") initial['size'] = humanize_size(self.partition.size) max_size += self.partition.size if partition.flag != "boot": initial.update(initial_data_for_fs(self.partition.fs())) else: if partition.fs() and partition.fs().mount(): initial['mount'] = '/boot/efi' else: initial['mount'] = None if isinstance(disk, LVM_VolGroup): initial['name'] = partition.name lvm_names.remove(partition.name) else: initial['fstype'] = 'ext4' if isinstance(disk, LVM_VolGroup): x = 0 while True: name = 'lv-{}'.format(x) if name not in lvm_names: break x += 1 initial['name'] = name self.form = PartitionForm(self.model, max_size, initial, lvm_names, partition) if not isinstance(disk, LVM_VolGroup): self.form.remove_field('name') if label is not None: self.form.buttons.base_widget[0].set_label(label) else: del self.form.buttons.base_widget.contents[0] self.form.buttons.base_widget[0].set_label(_("OK")) if partition is not None: if partition.flag == "boot": if partition.original_fstype(): opts = [ Option( (_("Use existing fat32 filesystem"), True, None)), Option(("---", False)), Option((_("Reformat as fresh fat32 filesystem"), True, "fat32")), ] self.form.fstype.widget.options = opts if partition.fs().preserve: self.form.fstype.widget.index = 0 else: self.form.fstype.widget.index = 2 if not self.partition.grub_device: self.form.fstype.enabled = False self.form.mount.enabled = False else: opts = [Option(("fat32", True))] self.form.fstype.widget.options = opts self.form.fstype.widget.index = 0 self.form.mount.enabled = False self.form.fstype.enabled = False elif partition.flag in ["bios_grub", "prep"]: self.form.mount.enabled = False self.form.fstype.enabled = False self.form.size.enabled = False if partition.preserve: self.form.name.enabled = False self.form.size.enabled = False connect_signal(self.form, 'submit', self.done) connect_signal(self.form, 'cancel', self.cancel) rows = [] focus_index = 0 if partition is not None: if self.partition.flag == "boot": if self.partition.grub_device: desc = _(configured_boot_partition_description) if self.partition.preserve: desc += _(boot_partition_description_reformat) else: desc += _(boot_partition_description_size) else: focus_index = 2 desc = _(unconfigured_boot_partition_description) rows.extend([ Text(rewrap(desc)), Text(""), ]) elif self.partition.flag == "bios_grub": if self.partition.device.grub_device: middle = _(configured_bios_grub_partition_middle) else: middle = _(unconfigured_bios_grub_partition_middle) desc = _(bios_grub_partition_description).format(middle=middle) rows.extend([ Text(rewrap(desc)), Text(""), ]) focus_index = 2 elif self.partition.flag == "prep": if self.partition.grub_device: desc = _(configured_prep_partition_description) else: desc = _(unconfigured_prep_partition_description) rows.extend([ Text(rewrap(desc)), Text(""), ]) focus_index = 2 rows.extend(self.form.as_rows()) self.form.form_pile = Pile(rows) widgets = [ self.form.form_pile, Text(""), self.form.buttons, ] if partition is None: if isinstance(disk, LVM_VolGroup): add_name = _("logical volume") else: add_name = _("{} partition").format( disk.ptable_for_new_partition().upper()) title = _("Adding {} to {}").format(add_name, disk.label) else: if isinstance(disk, LVM_VolGroup): desc = _("logical volume {}").format(partition.name) else: desc = partition.short_label title = _("Editing {} of {}").format(desc, disk.label) super().__init__(title, widgets, 0, focus_index)