some self-review

This commit is contained in:
Michael Hudson-Doyle 2018-05-31 12:31:02 +12:00
parent 738d8e11c7
commit 19dd965461
6 changed files with 23 additions and 65 deletions

View File

@ -83,7 +83,6 @@ def parse_options(argv):
help=("Load snap details from examples/snaps instead of store. "
"See examples/snaps/README.md for more."))
parser.add_argument(
# will change default to server when that exists
'--snap-section', action='store', default='server',
help=("Show snaps from this section of the store in the snap "
"list screen."))

View File

@ -79,7 +79,7 @@ class InstallProgressController(BaseController):
else:
self._snap_config_done = True
def curtin_error(self, log_text=None):
def curtin_error(self):
log.debug('curtin_error')
self.install_state = InstallState.ERROR
self.progress_view.spinner.stop()

View File

@ -71,7 +71,7 @@ class SnapListModel:
def load_info_data(self, data):
info = data['result'][0]
snap = self._snaps_by_name.get(info['name'], None)
snap = self._snaps_by_name.get(info['name'])
if snap is None:
return
channel_map = info['channels']

View File

@ -87,7 +87,8 @@ class SubiquityModel:
}
if self.snaplist.to_install:
cmds = []
for snap_name, selection in self.snaplist.to_install.items():
for snap_name, selection in sorted(
self.snaplist.to_install.items()):
cmd = ['snap', 'install', '--channel=' + selection.channel]
if selection.is_classic:
cmd.append('--classic')

View File

@ -22,7 +22,6 @@ from urwid import (
from subiquitycore.view import BaseView
from subiquitycore.ui.buttons import cancel_btn, ok_btn, other_btn
from subiquitycore.ui.container import Columns, ListBox, Pile
from subiquitycore.ui.stretchy import Stretchy
from subiquitycore.ui.utils import button_pile, Padding
from subiquity.ui.spinner import Spinner
@ -38,44 +37,6 @@ class MyLineBox(LineBox):
return ""
class AskForRetryStretchy(Stretchy):
def __init__(self, parent, watcher, snap_name, explanation):
self.parent = parent
self.watcher = watcher
if explanation is None:
widgets = [
Text(_('Downloading the snap "{}" failed for an unknown '
'reason.').format(snap_name)),
]
stretchy_index = 0
else:
widgets = [
Text(_('Downloading the snap "{}" failed with the following '
'output:').format(snap_name)),
Text(""),
Text(explanation),
]
stretchy_index = 2
retry = other_btn(
label=_("Try again"),
on_press=self.cont, user_arg=True)
give_up = other_btn(
label=_("Give up on this snap"),
on_press=self.cont, user_arg=False)
widgets.extend([
Text(""),
Text(_("Would you like to try to download this snap again?")),
Text(""),
button_pile([retry, give_up]),
])
title = _('Downloading "{}" failed.').format(snap_name)
super().__init__(title, widgets, stretchy_index, len(widgets) - 1)
def cont(self, sender, retry_cur):
self.parent.remove_overlay()
self.parent.controller.resume_snap_downloads(self.watcher, retry_cur)
class ProgressView(BaseView):
def __init__(self, controller):
self.controller = controller
@ -148,10 +109,6 @@ class ProgressView(BaseView):
self.event_pile.focus_position = 3
p.focus_position = 1
def ask_for_retry_snap(self, watcher, snap_name, explanation):
self.show_stretchy_overlay(
AskForRetryStretchy(self, watcher, snap_name, explanation))
def reboot(self, btn):
self.controller.reboot()

View File

@ -103,26 +103,28 @@ class SnapInfoView(WidgetWrap):
is_classic=csi.confinement == "classic"))
self.channels.append(Color.menu_button(Columns([
(channel_width, btn),
(max_version, Text(csi.version)),
(max_revision, Text("({})".format(csi.revision))),
(max_size, Text(humanize_size(csi.size))),
('pack', Text(notes)),
(max_version, Text(csi.version)),
(max_revision, Text("({})".format(csi.revision))),
(max_size, Text(humanize_size(csi.size))),
('pack', Text(notes)),
], dividechars=1)))
self.lb_channels = NoTabCyclingListBox(self.channels)
title = Columns([
Text(snap.name),
('pack', Text(
_("Publisher: {}").format(snap.publisher),
align='right')),
], dividechars=1)
contents = [
('pack', Columns([
Text(snap.name),
('pack', Text(
_("Publisher: {}").format(snap.publisher),
align='right')),
], dividechars=1)),
('pack', Text("")),
('pack', Text(snap.summary)),
('pack', Text("")),
self.lb_description,
('pack', Text("")),
('pack', title),
('pack', Text("")),
('pack', Text(snap.summary)),
('pack', Text("")),
(10, self.lb_description), # overwritten in render()
('pack', Text("")),
('weight', 1, self.lb_channels),
]
self.description_index = contents.index(self.lb_description)
@ -178,14 +180,13 @@ class FetchingInfo(WidgetWrap):
# | text |
# 12 34
self.width = len(text) + 4
cancel = cancel_btn(label=_("Cancel"), on_press=self.close)
super().__init__(
LineBox(
Pile([
('pack', Text(' ' + text)),
('pack', self.spinner),
('pack', button_pile([
cancel_btn(label=_("Cancel"), on_press=self.close),
])),
('pack', button_pile([cancel])),
])))
def close(self, sender=None):