split welcome controller into locale (server) and welcome (client)
This commit is contained in:
parent
3c30e14313
commit
3367b41cf1
|
@ -3,6 +3,7 @@ subiquity/client/client.py
|
||||||
subiquity/client/controller.py
|
subiquity/client/controller.py
|
||||||
subiquity/client/controllers/__init__.py
|
subiquity/client/controllers/__init__.py
|
||||||
subiquity/client/controllers/progress.py
|
subiquity/client/controllers/progress.py
|
||||||
|
subiquity/client/controllers/welcome.py
|
||||||
subiquity/client/__init__.py
|
subiquity/client/__init__.py
|
||||||
subiquity/client/keycodes.py
|
subiquity/client/keycodes.py
|
||||||
subiquity/cmd/common.py
|
subiquity/cmd/common.py
|
||||||
|
@ -45,7 +46,6 @@ subiquity/controllers/ssh.py
|
||||||
subiquity/controllers/tests/__init__.py
|
subiquity/controllers/tests/__init__.py
|
||||||
subiquity/controllers/tests/test_filesystem.py
|
subiquity/controllers/tests/test_filesystem.py
|
||||||
subiquity/controllers/userdata.py
|
subiquity/controllers/userdata.py
|
||||||
subiquity/controllers/welcome.py
|
|
||||||
subiquity/controllers/zdev.py
|
subiquity/controllers/zdev.py
|
||||||
subiquitycore/async_helpers.py
|
subiquitycore/async_helpers.py
|
||||||
subiquitycore/contextlib38.py
|
subiquitycore/contextlib38.py
|
||||||
|
@ -124,6 +124,7 @@ subiquity/models/tests/test_subiquity.py
|
||||||
subiquity/server/controller.py
|
subiquity/server/controller.py
|
||||||
subiquity/server/controllers/__init__.py
|
subiquity/server/controllers/__init__.py
|
||||||
subiquity/server/controllers/install.py
|
subiquity/server/controllers/install.py
|
||||||
|
subiquity/server/controllers/locale.py
|
||||||
subiquity/server/dryrun.py
|
subiquity/server/dryrun.py
|
||||||
subiquity/server/errors.py
|
subiquity/server/errors.py
|
||||||
subiquity/server/__init__.py
|
subiquity/server/__init__.py
|
||||||
|
|
|
@ -90,6 +90,7 @@ class SubiquityClient(TuiApplication):
|
||||||
return SubiquityUI(self, self.help_menu)
|
return SubiquityUI(self, self.help_menu)
|
||||||
|
|
||||||
controllers = [
|
controllers = [
|
||||||
|
"Welcome",
|
||||||
"Progress",
|
"Progress",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .progress import ProgressController
|
from .progress import ProgressController
|
||||||
|
from .welcome import WelcomeController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'ProgressController',
|
'ProgressController',
|
||||||
|
'WelcomeController',
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from subiquity.client.controller import SubiquityTuiController
|
||||||
|
from subiquity.ui.views.welcome import WelcomeView
|
||||||
|
|
||||||
|
log = logging.getLogger('subiquity.client.controllers.welcome')
|
||||||
|
|
||||||
|
|
||||||
|
class WelcomeController(SubiquityTuiController):
|
||||||
|
|
||||||
|
endpoint_name = 'locale'
|
||||||
|
|
||||||
|
async def make_ui(self):
|
||||||
|
language = await self.endpoint.GET()
|
||||||
|
serial = self.app.opts.run_on_serial
|
||||||
|
if serial:
|
||||||
|
ips = await self.app.client.network.global_addresses.GET()
|
||||||
|
else:
|
||||||
|
ips = None
|
||||||
|
return WelcomeView(self, language, serial, ips)
|
||||||
|
|
||||||
|
def run_answers(self):
|
||||||
|
if 'lang' in self.answers:
|
||||||
|
self.done(self.answers['lang'])
|
||||||
|
|
||||||
|
def done(self, code):
|
||||||
|
log.debug("WelcomeController.done %s next_screen", code)
|
||||||
|
self.signal.emit_signal('l10n:language-selected', code)
|
||||||
|
self.app.next_screen(self.endpoint.POST(code))
|
||||||
|
|
||||||
|
def cancel(self):
|
||||||
|
# Can't go back from here!
|
||||||
|
pass
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from subiquity.common.api.defs import api
|
from subiquity.common.api.defs import api, simple_endpoint
|
||||||
from subiquity.common.types import (
|
from subiquity.common.types import (
|
||||||
ApplicationState,
|
ApplicationState,
|
||||||
ApplicationStatus,
|
ApplicationStatus,
|
||||||
|
@ -28,6 +28,7 @@ from subiquity.common.types import (
|
||||||
@api
|
@api
|
||||||
class API:
|
class API:
|
||||||
"""The API offered by the subiquity installer process."""
|
"""The API offered by the subiquity installer process."""
|
||||||
|
locale = simple_endpoint(str)
|
||||||
|
|
||||||
class meta:
|
class meta:
|
||||||
class status:
|
class status:
|
||||||
|
|
|
@ -30,7 +30,6 @@ from .reporting import ReportingController
|
||||||
from .snaplist import SnapListController
|
from .snaplist import SnapListController
|
||||||
from .ssh import SSHController
|
from .ssh import SSHController
|
||||||
from .userdata import UserdataController
|
from .userdata import UserdataController
|
||||||
from .welcome import WelcomeController
|
|
||||||
from .zdev import ZdevController
|
from .zdev import ZdevController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
@ -52,6 +51,5 @@ __all__ = [
|
||||||
'SnapListController',
|
'SnapListController',
|
||||||
'SSHController',
|
'SSHController',
|
||||||
'UserdataController',
|
'UserdataController',
|
||||||
'WelcomeController',
|
|
||||||
'ZdevController',
|
'ZdevController',
|
||||||
]
|
]
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .install import InstallController
|
from .install import InstallController
|
||||||
|
from .locale import LocaleController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'InstallController',
|
'InstallController',
|
||||||
|
'LocaleController',
|
||||||
]
|
]
|
||||||
|
|
|
@ -16,15 +16,16 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from subiquity.controller import SubiquityTuiController
|
from subiquity.common.apidef import API
|
||||||
from subiquity.ui.views.welcome import get_languages, WelcomeView
|
from subiquity.server.controller import SubiquityController
|
||||||
from subiquity.ui.views.help import get_global_addresses
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.controllers.welcome')
|
log = logging.getLogger('subiquity.server.controllers.locale')
|
||||||
|
|
||||||
|
|
||||||
class WelcomeController(SubiquityTuiController):
|
class LocaleController(SubiquityController):
|
||||||
|
|
||||||
|
endpoint = API.locale
|
||||||
|
|
||||||
autoinstall_key = model_name = "locale"
|
autoinstall_key = model_name = "locale"
|
||||||
autoinstall_schema = {'type': 'string'}
|
autoinstall_schema = {'type': 'string'}
|
||||||
|
@ -40,37 +41,8 @@ class WelcomeController(SubiquityTuiController):
|
||||||
lang = os.environ.get("LANG")
|
lang = os.environ.get("LANG")
|
||||||
if lang is not None and lang.endswith(".UTF-8"):
|
if lang is not None and lang.endswith(".UTF-8"):
|
||||||
lang = lang.rsplit('.', 1)[0]
|
lang = lang.rsplit('.', 1)[0]
|
||||||
for code, name in get_languages():
|
|
||||||
if code == lang:
|
|
||||||
self.model.switch_language(code)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
self.model.selected_language = lang
|
self.model.selected_language = lang
|
||||||
|
|
||||||
def make_ui(self):
|
|
||||||
language = self.model.selected_language
|
|
||||||
serial = self.app.opts.run_on_serial
|
|
||||||
if serial:
|
|
||||||
ips = get_global_addresses(self.app)
|
|
||||||
else:
|
|
||||||
ips = None
|
|
||||||
return WelcomeView(self, language, serial, ips)
|
|
||||||
|
|
||||||
def run_answers(self):
|
|
||||||
if 'lang' in self.answers:
|
|
||||||
self.done(self.answers['lang'])
|
|
||||||
|
|
||||||
def done(self, code):
|
|
||||||
log.debug("WelcomeController.done %s next_screen", code)
|
|
||||||
self.signal.emit_signal('l10n:language-selected', code)
|
|
||||||
self.model.switch_language(code)
|
|
||||||
self.configured()
|
|
||||||
self.app.next_screen()
|
|
||||||
|
|
||||||
def cancel(self):
|
|
||||||
# Can't go back from here!
|
|
||||||
pass
|
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
return self.model.selected_language
|
return self.model.selected_language
|
||||||
|
|
||||||
|
@ -79,3 +51,10 @@ class WelcomeController(SubiquityTuiController):
|
||||||
|
|
||||||
def make_autoinstall(self):
|
def make_autoinstall(self):
|
||||||
return self.model.selected_language
|
return self.model.selected_language
|
||||||
|
|
||||||
|
async def GET(self) -> str:
|
||||||
|
return self.model.selected_language
|
||||||
|
|
||||||
|
async def POST(self, data: str):
|
||||||
|
self.model.switch_language(data)
|
||||||
|
self.configured()
|
|
@ -112,6 +112,7 @@ class SubiquityServer(Application):
|
||||||
project = "subiquity"
|
project = "subiquity"
|
||||||
from subiquity.server import controllers as controllers_mod
|
from subiquity.server import controllers as controllers_mod
|
||||||
controllers = [
|
controllers = [
|
||||||
|
"Locale",
|
||||||
"Install",
|
"Install",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import urwid
|
||||||
|
|
||||||
from subiquitycore.testing import view_helpers
|
from subiquitycore.testing import view_helpers
|
||||||
|
|
||||||
from subiquity.controllers.welcome import WelcomeController
|
from subiquity.client.controllers.welcome import WelcomeController
|
||||||
from subiquity.ui.views.welcome import WelcomeView
|
from subiquity.ui.views.welcome import WelcomeView
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue