diff --git a/po/POTFILES.in b/po/POTFILES.in
index c149c731..529a6ab5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@ subiquity/client/client.py
subiquity/client/controller.py
subiquity/client/controllers/__init__.py
subiquity/client/controllers/progress.py
+subiquity/client/controllers/welcome.py
subiquity/client/__init__.py
subiquity/client/keycodes.py
subiquity/cmd/common.py
@@ -45,7 +46,6 @@ subiquity/controllers/ssh.py
subiquity/controllers/tests/__init__.py
subiquity/controllers/tests/test_filesystem.py
subiquity/controllers/userdata.py
-subiquity/controllers/welcome.py
subiquity/controllers/zdev.py
subiquitycore/async_helpers.py
subiquitycore/contextlib38.py
@@ -124,6 +124,7 @@ subiquity/models/tests/test_subiquity.py
subiquity/server/controller.py
subiquity/server/controllers/__init__.py
subiquity/server/controllers/install.py
+subiquity/server/controllers/locale.py
subiquity/server/dryrun.py
subiquity/server/errors.py
subiquity/server/__init__.py
diff --git a/subiquity/client/client.py b/subiquity/client/client.py
index 652f4b4d..6f455572 100644
--- a/subiquity/client/client.py
+++ b/subiquity/client/client.py
@@ -90,6 +90,7 @@ class SubiquityClient(TuiApplication):
return SubiquityUI(self, self.help_menu)
controllers = [
+ "Welcome",
"Progress",
]
diff --git a/subiquity/client/controllers/__init__.py b/subiquity/client/controllers/__init__.py
index 24de8e16..0ec38317 100644
--- a/subiquity/client/controllers/__init__.py
+++ b/subiquity/client/controllers/__init__.py
@@ -14,7 +14,9 @@
# along with this program. If not, see .
from .progress import ProgressController
+from .welcome import WelcomeController
__all__ = [
'ProgressController',
+ 'WelcomeController',
]
diff --git a/subiquity/client/controllers/welcome.py b/subiquity/client/controllers/welcome.py
new file mode 100644
index 00000000..23f63b38
--- /dev/null
+++ b/subiquity/client/controllers/welcome.py
@@ -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 .
+
+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
diff --git a/subiquity/common/apidef.py b/subiquity/common/apidef.py
index 299ae9e4..0724bc96 100644
--- a/subiquity/common/apidef.py
+++ b/subiquity/common/apidef.py
@@ -15,7 +15,7 @@
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 (
ApplicationState,
ApplicationStatus,
@@ -28,6 +28,7 @@ from subiquity.common.types import (
@api
class API:
"""The API offered by the subiquity installer process."""
+ locale = simple_endpoint(str)
class meta:
class status:
diff --git a/subiquity/controllers/__init__.py b/subiquity/controllers/__init__.py
index 25a94520..0cb6a676 100644
--- a/subiquity/controllers/__init__.py
+++ b/subiquity/controllers/__init__.py
@@ -30,7 +30,6 @@ from .reporting import ReportingController
from .snaplist import SnapListController
from .ssh import SSHController
from .userdata import UserdataController
-from .welcome import WelcomeController
from .zdev import ZdevController
__all__ = [
@@ -52,6 +51,5 @@ __all__ = [
'SnapListController',
'SSHController',
'UserdataController',
- 'WelcomeController',
'ZdevController',
]
diff --git a/subiquity/server/controllers/__init__.py b/subiquity/server/controllers/__init__.py
index ee88e0f1..63777d40 100644
--- a/subiquity/server/controllers/__init__.py
+++ b/subiquity/server/controllers/__init__.py
@@ -14,7 +14,9 @@
# along with this program. If not, see .
from .install import InstallController
+from .locale import LocaleController
__all__ = [
'InstallController',
+ 'LocaleController',
]
diff --git a/subiquity/controllers/welcome.py b/subiquity/server/controllers/locale.py
similarity index 54%
rename from subiquity/controllers/welcome.py
rename to subiquity/server/controllers/locale.py
index 5dc50079..c73f71bf 100644
--- a/subiquity/controllers/welcome.py
+++ b/subiquity/server/controllers/locale.py
@@ -16,15 +16,16 @@
import logging
import os
-from subiquity.controller import SubiquityTuiController
-from subiquity.ui.views.welcome import get_languages, WelcomeView
-from subiquity.ui.views.help import get_global_addresses
+from subiquity.common.apidef import API
+from subiquity.server.controller import SubiquityController
-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_schema = {'type': 'string'}
@@ -40,36 +41,7 @@ class WelcomeController(SubiquityTuiController):
lang = os.environ.get("LANG")
if lang is not None and lang.endswith(".UTF-8"):
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
-
- 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
+ self.model.selected_language = lang
def serialize(self):
return self.model.selected_language
@@ -79,3 +51,10 @@ class WelcomeController(SubiquityTuiController):
def make_autoinstall(self):
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()
diff --git a/subiquity/server/server.py b/subiquity/server/server.py
index 404a8a06..63badf4c 100644
--- a/subiquity/server/server.py
+++ b/subiquity/server/server.py
@@ -112,6 +112,7 @@ class SubiquityServer(Application):
project = "subiquity"
from subiquity.server import controllers as controllers_mod
controllers = [
+ "Locale",
"Install",
]
diff --git a/subiquity/ui/views/tests/test_welcome.py b/subiquity/ui/views/tests/test_welcome.py
index c88ae501..0bb83f03 100644
--- a/subiquity/ui/views/tests/test_welcome.py
+++ b/subiquity/ui/views/tests/test_welcome.py
@@ -4,7 +4,7 @@ import urwid
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