Example #1
0
    def __init__(self, controller):
        self.controller = controller
        self.spinner = Spinner(controller.loop)

        self.reboot_btn = Toggleable(
            ok_btn(_("Reboot Now"), on_press=self.reboot))
        self.exit_btn = cancel_btn(_("Exit To Shell"), on_press=self.quit)
        self.view_log_btn = other_btn(_("View full log"),
                                      on_press=self.view_log)

        self.event_listbox = ListBox()
        self.event_linebox = MyLineBox(self.event_listbox)
        self.event_buttons = button_pile([self.view_log_btn])
        event_body = [
            ('pack', Text("")),
            ('weight', 1, Padding.center_79(self.event_linebox, min_width=76)),
            ('pack', Text("")),
            ('pack', self.event_buttons),
            ('pack', Text("")),
        ]
        self.event_pile = Pile(event_body)

        self.log_listbox = ListBox()
        log_linebox = MyLineBox(self.log_listbox, _("Full installer output"))
        log_body = [
            ('weight', 1, log_linebox),
            ('pack',
             button_pile([other_btn(_("Close"), on_press=self.close_log)])),
        ]
        self.log_pile = Pile(log_body)

        super().__init__(self.event_pile)
Example #2
0
    def __init__(self, controller):
        self.controller = controller
        self.ongoing = {}  # context -> line containing a spinner

        self.reboot_btn = Toggleable(ok_btn(
            _("Reboot Now"), on_press=self.reboot))
        self.view_error_btn = cancel_btn(
            _("View error report"), on_press=self.view_error)
        self.view_log_btn = other_btn(
            _("View full log"), on_press=self.view_log)
        self.continue_btn = other_btn(
            _("Continue"), on_press=self.continue_)

        self.event_listbox = ListBox()
        self.event_linebox = MyLineBox(self.event_listbox)
        self.event_buttons = button_pile([self.view_log_btn])
        event_body = [
            ('weight', 1, Padding.center_79(self.event_linebox, min_width=76)),
            ('pack', Text("")),
            ('pack', self.event_buttons),
            ('pack', Text("")),
        ]
        self.event_pile = Pile(event_body)

        self.log_listbox = ListBox()
        log_linebox = MyLineBox(self.log_listbox, _("Full installer output"))
        log_body = [
            ('weight', 1, log_linebox),
            ('pack', button_pile([other_btn(_("Close"),
                                  on_press=self.close_log)])),
            ]
        self.log_pile = Pile(log_body)

        super().__init__(self.event_pile)
Example #3
0
    def __init__(self, controller):
        self.controller = controller
        self.spinner = Spinner(controller.loop)

        self.event_listwalker = SimpleFocusListWalker([])
        self.event_listbox = ListBox(self.event_listwalker)
        self.event_linebox = MyLineBox(self.event_listbox)
        self.event_buttons = button_pile([other_btn("View full log", on_press=self.view_log)])
        event_body = [
            ('pack', Text("")),
            ('weight', 1, Padding.center_79(self.event_linebox)),
            ('pack', Text("")),
            ('pack', self.event_buttons),
            ('pack', Text("")),
        ]
        self.event_pile = Pile(event_body)

        self.log_listwalker = SimpleFocusListWalker([])
        self.log_listbox = ListBox(self.log_listwalker)
        log_linebox = MyLineBox(self.log_listbox, _("Full installer output"))
        log_body = [
            ('weight', 1, log_linebox),
            ('pack', button_pile([other_btn(_("Close"), on_press=self.close_log)])),
            ]
        self.log_pile = Pile(log_body)

        super().__init__(self.event_pile)
Example #4
0
    def __init__(self, controller, netdev_infos):
        self.controller = controller
        self.dev_name_to_table = {}
        self.cur_netdev_names = []
        self.error = Text("", align='center')

        self.device_colspecs = {
            0: ColSpec(rpad=1),
            3: ColSpec(min_width=15),
            4: ColSpec(can_shrink=True, rpad=1),
        }

        self.heading_table = TablePile([
            TableRow([
                Color.info_minor(Text(header)) for header in [
                    "",
                    "NAME",
                    "TYPE",
                    "NOTES",
                    "",
                ]
            ])
        ],
                                       spacing=2,
                                       colspecs=self.device_colspecs)

        self.device_pile = Pile([self.heading_table])

        for dev_info in netdev_infos:
            self.new_link(dev_info)

        self._create_bond_btn = menu_btn(_("Create bond"),
                                         on_press=self._create_bond)
        bp = button_pile([self._create_bond_btn])
        bp.align = 'left'

        rows = [
            self.device_pile,
            bp,
        ]

        self.buttons = button_pile([
            done_btn("TBD", on_press=self.done),  # See _route_watcher
            back_btn(_("Back"), on_press=self.cancel),
        ])
        self.bottom = Pile([
            ('pack', self.buttons),
        ])

        self.error_showing = False

        super().__init__(
            screen(rows=rows,
                   buttons=self.bottom,
                   focus_buttons=True,
                   excerpt=_(self.excerpt)))
Example #5
0
    def __init__(self, parent, obj):
        self.parent = parent
        self.obj = obj

        title = _("Confirm deletion of {}").format(obj.desc())

        lines = [
            _("Do you really want to delete {}?").format(obj.label),
            "",
        ]
        fs = obj.fs()
        if fs is not None:
            m = fs.mount()
            if m is not None:
                lines.append(
                    _("It is formatted as {fstype} and mounted at "
                      "{path}").format(fstype=fs.fstype, path=m.path))
            else:
                lines.append(
                    _("It is formatted as {fstype} and not mounted.").format(
                        fstype=fs.fstype))
        else:
            lines.append(_("It is not formatted or mounted."))
        delete_btn = danger_btn(label=_("Delete"), on_press=self.confirm)
        widgets = [
            Text("\n".join(lines)),
            Text(""),
            button_pile([
                delete_btn,
                other_btn(label=_("Cancel"), on_press=self.cancel),
            ]),
        ]
        super().__init__(title, widgets, 0, 2)
Example #6
0
 def __init__(self, controller):
     self.controller = controller
     super().__init__(screen(
         rows=[],
         buttons=button_pile([done_btn("OK", on_press=self.confirm)]),
         focus_buttons=True,
         excerpt=self.excerpt))
Example #7
0
 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)
Example #8
0
 def __init__(self, model, controller):
     self.model = model
     self.controller = controller
     cancel = cancel_btn(_("Cancel"), on_press=self.cancel)
     disks = []
     for disk in self.model.all_disks():
         label = "%-42s %s" % (disk.label, humanize_size(
             disk.size).rjust(9))
         if disk.size >= model.lower_size_limit:
             disk_btn = forward_btn(label,
                                    on_press=self.choose_disk,
                                    user_arg=disk)
         else:
             disk_btn = Color.info_minor(Text("  " + label))
         disks.append(disk_btn)
     body = Pile([
         ('pack', Text("")),
         ('pack',
          Padding.center_70(Text(_("Choose the disk to install to:")))),
         ('pack', Text("")),
         Padding.center_70(ListBox(disks)),
         ('pack', Text("")),
         ('pack', button_pile([cancel])),
         ('pack', Text("")),
     ])
     super().__init__(body)
Example #9
0
 def __init__(self, model, controller, method):
     self.model = model
     self.controller = controller
     self.method = method
     cancel = cancel_btn(_("Cancel"), on_press=self.cancel)
     rows = []
     for disk in self.model.all_disks():
         if disk.size >= dehumanize_size("6G"):
             disk_btn = ClickableIcon(disk.label)
             connect_signal(
                 disk_btn, 'click', self.choose_disk, disk)
             attr = Color.done_button
         else:
             disk_btn = Text("  "+disk.label)
             attr = Color.info_minor
         rows.append(attr(TableRow([
             Text('['),
             disk_btn,
             Text(humanize_size(disk.size), align='right'),
             Text('\N{BLACK RIGHT-POINTING SMALL TRIANGLE}'),
             Text(']'),
             ])))
     super().__init__(screen(
         TableListBox(rows, spacing=1, colspecs={
             1: ColSpec(can_shrink=True, min_width=20, rpad=2),
             2: ColSpec(min_width=9),
             }),
         button_pile([cancel]),
         focus_buttons=False,
         excerpt=(
             excerpts[method]
             + "\n\n"
             + _("Choose the disk to install to:"))))
Example #10
0
    def check_state_available(self, sender=None):
        self.spinner.stop()

        rows = [
            Text(_("You can read the release notes for each version at:")),
            Text(""),
            Text("https://github.com/CanonicalLtd/subiquity/releases",
                 align='center'),
            Text(""),
            Text(
                _("If you choose to update, the update will be downloaded "
                  "and the installation will continue from here."), ),
        ]

        buttons = button_pile([
            done_btn(_("Update to the new installer"), on_press=self.update),
            done_btn(_("Continue without updating"), on_press=self.done),
            other_btn(_("Back"), on_press=self.cancel),
        ])
        buttons.base_widget.focus_position = 1

        excerpt = _(self.available_excerpt).format(
            current=self.controller.status.current_snap_version,
            new=self.controller.status.new_snap_version)

        self.title = self.available_title
        self.controller.ui.set_header(self.available_title)
        self._w = screen(rows, buttons, excerpt=excerpt)
        if 'update' in self.controller.answers:
            if self.controller.answers['update']:
                self.update()
            else:
                self.controller.app.aio_loop.call_soon(self.controller.done)
Example #11
0
    def __init__(self, model, controller, opts):
        self.model = model
        self.controller = controller
        self.opts = opts

        self.form = KeyboardForm()
        opts = []
        for layout, desc in model.layouts.items():
            opts.append(Option((desc, True, layout)))
        opts.sort(key=lambda o: o.label)
        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)
        connect_signal(self.form.layout.widget, "select", self.select_layout)
        self.form.layout.widget._options = opts
        setting = model.setting.for_ui()
        try:
            self.form.layout.widget.value = setting.layout
            self.form.variant.widget.value = setting.variant
        except AttributeError:
            # Don't crash on pre-existing invalid config.
            pass

        lb_contents = self.form.as_rows(self)
        if not self.opts.run_on_serial:
            lb_contents.extend([
                Text(""),
                button_pile([
                    other_btn(label=_("Identify keyboard"),
                              on_press=self.detect)
                ]),
            ])
        super().__init__(screen(lb_contents, self.form.buttons))
Example #12
0
    def __init__(self, parent, thing, delete_func):
        self.parent = parent
        self.thing = thing
        self.delete_func = delete_func

        title = _("Confirm deletion of {}").format(thing.desc())

        lines = [
            _("Do you really want to delete {}?").format(thing.label),
        ]
        if isinstance(thing, Partition):
            lines.append("")
            if thing.fs():
                fs = thing.fs()
                desc = _("It is formatted as {}").format(fs.fstype)
                if fs.mount():
                    desc += _(" and mounted at {}.").format(fs.mount().path)
                else:
                    desc += _(" and not mounted.")
            else:
                desc = _("It is not formatted.")
            lines.append(desc)
        else:
            raise Exception("deletion of {} not yet supported".format(
                thing.desc()))
        widgets = [
            Text("\n".join(lines)),
            Text(""),
            button_pile([
                danger_btn(label=_("Delete"), on_press=self.confirm),
                other_btn(label=_("Cancel"), on_press=self.cancel),
            ]),
        ]
        super().__init__(title, widgets, 0, 2)
Example #13
0
 def __init__(self, parent, title, text):
     widgets = [
         Text(rewrap(text)),
         Text(""),
         button_pile([close_btn(parent)]),
     ]
     super().__init__(title, widgets, 0, 2)
Example #14
0
 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)
Example #15
0
    def __init__(self, parent, obj):
        self.parent = parent
        self.obj = obj

        delete_ok, reason = can_delete(obj)
        if delete_ok:
            title = _("Confirm deletion of {}").format(obj.desc())

            lines = [
                _("Do you really want to delete {}?").format(obj.label),
                "",
            ]
            new_lines, delete_funcs = delete_consequences(
                self.parent.controller, obj)
            lines.extend(new_lines)
            self.delete_funcs = delete_funcs
        else:
            title = "Cannot delete {}".format(obj.desc())
            lines = [
                _("Cannot delete {} because {}").format(obj.label, reason)
            ]
        delete_btn = danger_btn(label=_("Delete"), on_press=self.confirm)
        if not delete_ok:
            delete_btn = WidgetDisable(
                Color.info_minor(delete_btn.original_widget))
        widgets = [
            Text("\n".join(lines)),
            Text(""),
            button_pile([
                delete_btn,
                other_btn(label=_("Cancel"), on_press=self.cancel),
            ]),
        ]
        super().__init__(title, widgets, 0, 2)
Example #16
0
 def __init__(self, app):
     self.app = app
     rows = [
         TableRow([
             Text(""),
             Text(_("DATE")),
             Text(_("KIND")),
             Text(_("STATUS")),
             Text(""),
         ])
     ]
     self.report_to_row = {}
     self.app.error_reporter.load_reports()
     for report in self.app.error_reporter.reports:
         connect_signal(report, "changed", self._report_changed, report)
         r = self.report_to_row[report] = self.row_for_report(report)
         rows.append(r)
     self.table = TablePile(rows, colspecs={1: ColSpec(can_shrink=True)})
     widgets = [
         Text(_("Select an error report to view:")),
         Text(""),
         self.table,
         Text(""),
         button_pile([close_btn(self)]),
     ]
     super().__init__("", widgets, 2, 2)
Example #17
0
 def __init__(self, controller):
     self.controller = controller
     super().__init__(Pile([
         ListBox([Text('')]), # need to have a listbox or something else "stretchy" here or urwid complains.
         ('pack', button_pile([ok_btn("OK", on_press=self.confirm)])),
         ('pack', Text("")),
         ], focus_item=1))
Example #18
0
    def __init__(self, model, controller, opts, loop):
        self.model = model
        self.controller = controller
        self.opts = opts
        self.loop = loop
        self.items = []
        self.email = EmailEditor()
        self.error = Text("", align="center")
        self.progress = Text("", align="center")

        body = [
            ('pack', Text("")),
            ListBox([
                self._build_model_inputs(),
                Padding.line_break(""),
                Padding.center_79(
                    Color.info_minor(
                        Text("If you do not have an account, visit "
                             "https://login.ubuntu.com to create one."))),
                Padding.line_break(""),
                Padding.center_90(Color.info_error(self.error)),
                Padding.center_90(self.progress),
            ]),
            ('pack',
             Pile([
                 ('pack', Text("")),
                 button_pile(self._build_buttons()),
                 ('pack', Text("")),
             ])),
        ]
        super().__init__(Pile(body))
Example #19
0
    def __init__(self, controller):
        self.controller = controller
        user_name = ""
        with open('/var/lib/ubuntu-wsl/assigned_account', 'r') as f:
            user_name = f.read()
        complete_text = _(
            "Hi {username},\n"
            "You have complete the setup!\n\n"
            "It is suggested to run the following command to update your Ubuntu "
            "to the latest version:\n\n\n"
            "  $ sudo apt update\n  $ sudo apt upgrade\n\n\n"
            "You can use the builtin `ubuntuwsl` command to manage your WSL settings:\n\n\n"
            "  $ sudo ubuntuwsl ...\n\n\n"
            "* All settings will take effect after first restart of Ubuntu."
        ).format(username=user_name)

        super().__init__(
            screen(
                rows=[],
                buttons=button_pile([
                    done_btn(_("Done"), on_press=self.confirm),
                ]),
                focus_buttons=True,
                excerpt=complete_text,
            ))
Example #20
0
    def __init__(self, model, controller, opts):
        self.model = model
        self.controller = controller
        self.signal = controller.signal
        self.opts = opts
        self.items = []

        self.form = IdentityForm()
        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form.confirm_password.widget, 'change',
                       self._check_password)

        self.ssh_import_confirmed = True

        body = Pile([
            ('pack', Text("")),
            Padding.center_90(ListBox([self.form.as_rows(self)])),
            ('pack',
             Pile([
                 ('pack', Text("")),
                 button_pile([self.form.done_btn]),
                 ('pack', Text("")),
             ],
                  focus_item=1)),
        ])
        super().__init__(body)
Example #21
0
    def __init__(self, parent, result, key_material, fingerprints):
        self.parent = parent
        self.result = result
        self.key_material = key_material

        ok = ok_btn(label=_("Yes"), on_press=self.ok)
        cancel = cancel_btn(label=_("No"), on_press=self.cancel)

        if len(fingerprints) > 1:
            title = _("Confirm SSH keys")
            header = _("Keys with the following fingerprints were fetched. "
                       "Do you want to use them?")
        else:
            title = _("Confirm SSH key")
            header = _("A key with the following fingerprint was fetched. "
                       "Do you want to use it?")

        fingerprints = Pile(
            [Text(fingerprint) for fingerprint in fingerprints])

        super().__init__(title, [
            Text(header),
            Text(""),
            fingerprints,
            Text(""),
            button_pile([ok, cancel]),
        ], 2, 4)
Example #22
0
    def __init__(self, model, controller):
        self.model = model
        self.controller = controller
        self.dev_to_row = {}
        self.cur_netdevs = []
        self.error = Text("", align='center')
        self.device_table = TablePile(self._build_model_inputs(),
                                      spacing=2,
                                      colspecs={
                                          0: ColSpec(rpad=1),
                                          4: ColSpec(can_shrink=True, rpad=1),
                                      })

        self._create_bond_btn = menu_btn(_("Create bond"),
                                         on_press=self._create_bond)
        bp = button_pile([self._create_bond_btn])
        bp.align = 'left'

        self.listbox = ListBox([self.device_table] + [
            bp,
        ])
        self.bottom = Pile([
            Text(""),
            self._build_buttons(),
            Text(""),
        ])
        self.error_showing = False

        self.frame = Pile([('pack', Text("")),
                           ('pack', Padding.center_79(Text(_(self.excerpt)))),
                           ('pack', Text("")),
                           Padding.center_90(self.listbox),
                           ('pack', self.bottom)])
        self.frame.set_focus(self.bottom)
        super().__init__(self.frame)
Example #23
0
    def __init__(self, parent, setting):
        self.parent = parent
        self.setting = setting
        self.selector = Selector(toggle_options)
        self.selector.value = 'alt_shift_toggle'
        if self.parent.model.setting.toggle:
            try:
                self.selector.value = self.parent.model.setting.toggle
            except AttributeError:
                pass

        widgets = [
            Text(_(toggle_text)),
            Text(""),
            Padding.center_79(
                Columns([
                    ('pack', Text(_("Shortcut: "))),
                    Color.string_input(self.selector),
                ])),
            Text(""),
            button_pile([
                ok_btn(label=_("OK"), on_press=self.ok),
                cancel_btn(label=_("Cancel"), on_press=self.cancel),
            ]),
        ]
        super().__init__(_("Select layout toggle"),
                         widgets,
                         stretchy_index=0,
                         focus_index=4)
Example #24
0
    def __init__(self, parent, obj):
        self.parent = parent
        self.obj = obj

        lines = [
            Text(
                _("Do you really want to delete the {desc} {label}?").format(
                    desc=obj.desc(), label=obj.label)),
            Text(""),
        ]
        stretchy_index = 0
        fs = obj.fs()
        if fs is not None:
            m = fs.mount()
            if m is not None:
                lines.append(
                    Text(
                        _("It is formatted as {fstype} and mounted at "
                          "{path}").format(fstype=fs.fstype, path=m.path)))
            else:
                lines.append(
                    Text(
                        _("It is formatted as {fstype} and not mounted.").
                        format(fstype=fs.fstype)))
        elif hasattr(obj, 'partitions') and len(obj.partitions()) > 0:
            n = len(obj.partitions())
            if obj.type == "lvm_volgroup":
                if n == 1:
                    things = _("logical volume")
                else:
                    things = _("logical volumes")
            else:
                if n == 1:
                    things = _("partition")
                else:
                    things = _("partitions")
            lines.append(
                Text(
                    _("It contains {n} {things}:").format(n=n, things=things)))
            lines.append(Text(""))
            stretchy_index = len(lines)
            rows = []
            for p, cells in summarize_device(obj):
                if p not in [None, obj]:
                    rows.append(TableRow(cells))
            lines.append(TablePile(rows))
        else:
            lines.append(Text(_("It is not formatted or mounted.")))

        delete_btn = danger_btn(label=_("Delete"), on_press=self.confirm)
        widgets = lines + [
            Text(""),
            button_pile([
                delete_btn,
                other_btn(label=_("Cancel"), on_press=self.cancel),
            ]),
        ]
        super().__init__("", widgets, stretchy_index, len(lines) + 1)
Example #25
0
    def _build_buttons(self):
        cancel = cancel_btn(_("Cancel"), on_press=self.cancel)
        done = done_btn(_("Done"), on_press=self.done)

        buttons = [
            done,
            cancel,
        ]
        return button_pile(buttons)
Example #26
0
 def make_body(self):
     return Pile([
             Text(_("Keyboard detection starting. You will be asked a series of questions about your keyboard. Press escape at any time to go back to the previous screen.")),
             Text(""),
             button_pile([
                 ok_btn(label=_("OK"), on_press=self.ok),
                 ok_btn(label=_("Cancel"), on_press=self.cancel),
                 ]),
             ])
Example #27
0
    def _build_buttons(self):
        back = back_btn(_("Back"), on_press=self.cancel)
        done = done_btn(_("Done"), on_press=self.done)

        buttons = button_pile([done, back])

        buttons.base_widget.focus_position = 0

        return buttons
Example #28
0
 def __init__(self, step_count, cancel_func):
     self.cancel_func = cancel_func
     button = cancel_btn(_("Cancel"), on_press=self.do_cancel)
     self.bar = ProgressBar(normal='progress_incomplete',
                            complete='progress_complete',
                            current=0,
                            done=step_count)
     box = LineBox(Pile([self.bar, button_pile([button])]),
                   title=_("Applying network config"))
     super().__init__(box)
Example #29
0
 def __init__(self, parent, name, nic_info):
     self.parent = parent
     widgets = [
         Text(nic_info),
         Text(""),
         button_pile([done_btn(_("Close"), on_press=self.close)]),
         ]
     # {device} is the name of a network device
     title = _("Info for {device}").format(device=name)
     super().__init__(title, widgets, 0, 2)
Example #30
0
 def __init__(self, controller):
     self.controller = controller
     super().__init__(
         screen([
             Text(_(fail_text)),
             Text(""),
             button_pile([
                 other_btn(_("Show Error Report"), on_press=self.show_error)
             ]),
         ], [other_btn(_("Back"), on_press=self.cancel)]))