2015-06-22 13:09:34 +00:00
|
|
|
# Copyright 2015 Canonical, Ltd.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-07-21 15:55:02 +00:00
|
|
|
""" Install Path
|
|
|
|
|
|
|
|
Provides high level options for Ubuntu install
|
|
|
|
|
|
|
|
"""
|
2015-06-23 17:09:26 +00:00
|
|
|
import logging
|
2015-07-21 15:55:02 +00:00
|
|
|
from urwid import (WidgetWrap, ListBox, Pile, BoxAdapter, emit_signal)
|
2015-06-22 13:09:34 +00:00
|
|
|
from subiquity.ui.lists import SimpleList
|
2015-06-22 15:15:44 +00:00
|
|
|
from subiquity.ui.buttons import confirm_btn, cancel_btn
|
2015-06-22 13:09:34 +00:00
|
|
|
from subiquity.ui.utils import Padding, Color
|
|
|
|
|
2015-06-23 17:09:26 +00:00
|
|
|
log = logging.getLogger('subiquity.installpathView')
|
|
|
|
|
|
|
|
|
2015-07-21 15:55:02 +00:00
|
|
|
class InstallpathModel:
|
|
|
|
""" Model representing install options
|
|
|
|
"""
|
|
|
|
|
|
|
|
install_paths = ['Install Ubuntu',
|
|
|
|
'Install MAAS Region Server',
|
|
|
|
'Install MAAS Cluster Server',
|
|
|
|
'Test installation media',
|
|
|
|
'Test machine memory']
|
|
|
|
selected_path = None
|
|
|
|
|
|
|
|
|
2015-06-22 13:09:34 +00:00
|
|
|
class InstallpathView(WidgetWrap):
|
2015-07-21 15:55:02 +00:00
|
|
|
def __init__(self, model, signal):
|
2015-06-23 17:09:26 +00:00
|
|
|
log.debug("In install path view")
|
2015-06-22 13:09:34 +00:00
|
|
|
self.model = model
|
2015-07-21 15:55:02 +00:00
|
|
|
self.signal = signal
|
2015-06-22 13:09:34 +00:00
|
|
|
self.items = []
|
2015-06-23 16:40:10 +00:00
|
|
|
self.body = [
|
2015-06-22 13:09:34 +00:00
|
|
|
Padding.center_79(self._build_model_inputs()),
|
2015-06-23 16:48:37 +00:00
|
|
|
Padding.line_break(""),
|
2015-06-23 16:40:10 +00:00
|
|
|
Padding.center_20(self._build_buttons()),
|
2015-06-22 13:09:34 +00:00
|
|
|
]
|
2015-06-23 16:40:10 +00:00
|
|
|
super().__init__(ListBox(self.body))
|
2015-06-22 13:09:34 +00:00
|
|
|
|
|
|
|
def _build_buttons(self):
|
|
|
|
self.buttons = [
|
|
|
|
Color.button_secondary(cancel_btn(on_press=self.cancel),
|
|
|
|
focus_map='button_secondary focus'),
|
|
|
|
]
|
|
|
|
return Pile(self.buttons)
|
|
|
|
|
|
|
|
def _build_model_inputs(self):
|
2015-06-22 15:15:44 +00:00
|
|
|
sl = []
|
|
|
|
for ipath in self.model.install_paths:
|
|
|
|
sl.append(Color.button_primary(confirm_btn(label=ipath,
|
|
|
|
on_press=self.confirm),
|
|
|
|
focus_map='button_primary focus'))
|
|
|
|
|
|
|
|
return BoxAdapter(SimpleList(sl),
|
|
|
|
height=len(sl))
|
2015-06-22 13:09:34 +00:00
|
|
|
|
|
|
|
def confirm(self, button):
|
2015-07-21 15:55:02 +00:00
|
|
|
emit_signal(self.signal, 'installpath:finish', button.label)
|
2015-06-22 13:09:34 +00:00
|
|
|
|
|
|
|
def cancel(self, button):
|
2015-07-21 15:55:02 +00:00
|
|
|
emit_signal(self.signal, 'welcome:show', None)
|