From 2125acffe6a618af4e23ec95a4da97430c44ff8f Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Tue, 26 Oct 2021 15:37:24 -0300 Subject: [PATCH] WSL Locale controller is not needed anymore. - With 'prefill' working, calling Powershell to find Windows locale is not required anymore. - Since `f21986be` subiquity's default locale controller respects mode.selected_language initialization. --- system_setup/common/wsl_utils.py | 25 ------------------ system_setup/server/controllers/__init__.py | 4 +-- system_setup/server/controllers/locale.py | 29 --------------------- system_setup/server/server.py | 2 +- 4 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 system_setup/server/controllers/locale.py diff --git a/system_setup/common/wsl_utils.py b/system_setup/common/wsl_utils.py index 9ed0cf9c..4fdea685 100644 --- a/system_setup/common/wsl_utils.py +++ b/system_setup/common/wsl_utils.py @@ -36,31 +36,6 @@ def is_reconfigure(is_dryrun): return not is_dryrun and if_normaluser -def get_windows_locale(): - windows_locale_failed_msg = ( - "Cannot determine Windows locale, fallback to default." - " Reason of failure: " - ) - - try: - process = subprocess.run(["powershell.exe", "-NonInteractive", - "-NoProfile", "-Command", - "(Get-Culture).Name"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - if process.returncode: - log.info(windows_locale_failed_msg + - process.stderr.decode("utf-8")) - return None - - tmp_code = process.stdout.rstrip().decode("utf-8") - tmp_code = tmp_code.replace("-", "_") - return tmp_code - except OSError as e: - log.info(windows_locale_failed_msg + e.strerror) - return None - - def convert_if_bool(value): if value.lower() in ('true', 'false'): return value.lower() == 'true' diff --git a/system_setup/server/controllers/__init__.py b/system_setup/server/controllers/__init__.py index 0a544932..71989801 100644 --- a/system_setup/server/controllers/__init__.py +++ b/system_setup/server/controllers/__init__.py @@ -20,8 +20,8 @@ from subiquity.server.controllers.cmdlist import ( ) from subiquity.server.controllers.reporting import ReportingController from subiquity.server.controllers.userdata import UserdataController +from subiquity.server.controllers.locale import LocaleController from .identity import WSLIdentityController -from .locale import WSLLocaleController from .wslconfbase import WSLConfigurationBaseController from .wslconfadvanced import WSLConfigurationAdvancedController from .configure import ConfigureController @@ -32,7 +32,7 @@ __all__ = [ 'ErrorController', 'WSLIdentityController', 'LateController', - 'WSLLocaleController', + 'LocaleController', 'ReportingController', 'SetupShutdownController', 'UserdataController', diff --git a/system_setup/server/controllers/locale.py b/system_setup/server/controllers/locale.py deleted file mode 100644 index c0feaff8..00000000 --- a/system_setup/server/controllers/locale.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2021 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 os -from system_setup.common.wsl_utils import get_windows_locale -from subiquity.server.controllers.locale import LocaleController - - -class WSLLocaleController(LocaleController): - - def start(self): - win_lang = get_windows_locale() - self.model.selected_language = os.environ.get("LANG") \ - or self.autoinstall_default - if win_lang: - self.model.selected_language = win_lang + ".UTF-8" - self.app.aio_loop.create_task(self.configured()) diff --git a/system_setup/server/server.py b/system_setup/server/server.py index a38e67ce..fb3aa6df 100644 --- a/system_setup/server/server.py +++ b/system_setup/server/server.py @@ -45,7 +45,7 @@ class SystemSetupServer(SubiquityServer): "Early", "Reporting", "Error", - "WSLLocale", + "Locale", "WSLIdentity", "WSLConfigurationBase", "WSLConfigurationAdvanced",