console_conf: add an app for the recovery chooser

Add an app and hook it up with the rest of elements.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
This commit is contained in:
Maciej Borzecki 2020-03-24 11:51:15 +01:00
parent 8d2f1f9a8b
commit f6ea3bc960
1 changed files with 32 additions and 1 deletions

View File

@ -18,8 +18,9 @@ import logging
from subiquitycore.core import Application from subiquitycore.core import Application
from console_conf.models.console_conf import ConsoleConfModel from console_conf.models.console_conf import ConsoleConfModel
from console_conf.models.systems import RecoverySystemsModel
log = logging.getLogger('console_conf.core') log = logging.getLogger("console_conf.core")
class ConsoleConf(Application): class ConsoleConf(Application):
@ -35,3 +36,33 @@ class ConsoleConf(Application):
"Network", "Network",
"Identity", "Identity",
] ]
class RecoveryChooser(Application):
from console_conf.palette import COLORS, STYLES, STYLES_MONO
project = "console_conf"
controllers = [
"RecoveryChooserWelcome",
"RecoveryChooser",
"RecoveryChooserConfirm",
]
def __init__(self, opts, chooser_input, chooser_output):
"""Takes the options and raw input/output streams for communicating with the
chooser parent process.
"""
self._chooser_output = chooser_output
# make_model is used by super()'s constructor, but we need to use the
# instance data
self.make_model = lambda: RecoverySystemsModel.from_systems_stream(
chooser_input
)
super().__init__(opts)
def respond(self, choice):
"""Produce a response to the parent process"""
self.base_model.to_response_stream(choice, self._chooser_output)