From aff93e5cdaa2c16604f48ddb393d6b2bc7a1edc0 Mon Sep 17 00:00:00 2001 From: "Jinming Wu, Patrick" Date: Thu, 12 Aug 2021 22:31:27 +0800 Subject: [PATCH] system_setup: PEP8 linting fixes --- system_setup/client/client.py | 5 +- system_setup/client/controllers/__init__.py | 4 +- .../client/controllers/integration.py | 3 +- system_setup/client/controllers/overview.py | 2 - .../client/controllers/reconfiguration.py | 16 +-- system_setup/models/system_server.py | 7 +- system_setup/models/wslconf2.py | 19 ++-- system_setup/server/controllers/__init__.py | 8 +- system_setup/server/controllers/identity.py | 2 - system_setup/server/controllers/wslconf2.py | 29 ++--- system_setup/ui/views/__init__.py | 2 +- system_setup/ui/views/identity.py | 13 ++- system_setup/ui/views/integration.py | 31 +++--- system_setup/ui/views/overview.py | 11 +- system_setup/ui/views/reconfiguration.py | 100 +++++++++++++----- 15 files changed, 161 insertions(+), 91 deletions(-) diff --git a/system_setup/client/client.py b/system_setup/client/client.py index fd488d73..39d324da 100644 --- a/system_setup/client/client.py +++ b/system_setup/client/client.py @@ -29,13 +29,14 @@ class SystemSetupClient(SubiquityClient): snapd_socket_path = None controllers = [ - #"Serial", + # "Serial", "Welcome", "WSLIdentity", "Integration", "Overview", "Progress", ] + def __init__(self, opts): if opts.reconfigure: self.controllers = [ @@ -45,8 +46,6 @@ class SystemSetupClient(SubiquityClient): ] super().__init__(opts) - - def restart(self, remove_last_screen=True, restart_server=False): log.debug(f"restart {remove_last_screen} {restart_server}") if self.fg_proc is not None: diff --git a/system_setup/client/controllers/__init__.py b/system_setup/client/controllers/__init__.py index ad2307ab..79abf691 100644 --- a/system_setup/client/controllers/__init__.py +++ b/system_setup/client/controllers/__init__.py @@ -19,7 +19,8 @@ from .integration import IntegrationController from .overview import OverviewController from .reconfiguration import ReconfigurationController -from subiquity.client.controllers import (ProgressController, WelcomeController) +from subiquity.client.controllers import (ProgressController, + WelcomeController) __all__ = [ @@ -30,4 +31,3 @@ __all__ = [ 'OverviewController', 'ReconfigurationController', ] - diff --git a/system_setup/client/controllers/integration.py b/system_setup/client/controllers/integration.py index 07d2d1e8..223f7ae5 100644 --- a/system_setup/client/controllers/integration.py +++ b/system_setup/client/controllers/integration.py @@ -16,7 +16,8 @@ class IntegrationController(SubiquityTuiController): def run_answers(self): if all(elem in self.answers for elem in - ['custom_path', 'custom_mount_opt', 'gen_host', 'gen_resolvconf']): + ['custom_path', 'custom_mount_opt', + 'gen_host', 'gen_resolvconf']): integration = WSLConfiguration1Data( custom_path=self.answers['custom_path'], custom_mount_opt=self.answers['custom_mount_opt'], diff --git a/system_setup/client/controllers/overview.py b/system_setup/client/controllers/overview.py index 13acb1ec..029b95dd 100644 --- a/system_setup/client/controllers/overview.py +++ b/system_setup/client/controllers/overview.py @@ -1,13 +1,11 @@ import logging from subiquity.client.controller import SubiquityTuiController -from subiquitycore.utils import run_command from system_setup.ui.views.overview import OverviewView log = logging.getLogger('ubuntu_wsl_oobe.controllers.identity') - class OverviewController(SubiquityTuiController): async def make_ui(self): diff --git a/system_setup/client/controllers/reconfiguration.py b/system_setup/client/controllers/reconfiguration.py index 8631645e..8fba4021 100644 --- a/system_setup/client/controllers/reconfiguration.py +++ b/system_setup/client/controllers/reconfiguration.py @@ -15,10 +15,6 @@ import logging -import attr - -from subiquitycore.context import with_context - from subiquity.client.controller import SubiquityTuiController from subiquity.common.types import WSLConfiguration2Data from system_setup.ui.views.reconfiguration import ReconfigurationView @@ -35,14 +31,20 @@ class ReconfigurationController(SubiquityTuiController): def run_answers(self): if all(elem in self.answers for elem in - ['custom_path', 'custom_mount_opt', 'gen_host', 'gen_resolvconf', 'interop_enabled', 'interop_appendwindowspath', 'gui_theme', 'gui_followwintheme', 'legacy_gui', 'legacy_audio', 'adv_ip_detect', 'wsl_motd_news', 'automount', 'mountfstab']): + ['custom_path', 'custom_mount_opt', 'gen_host', + 'gen_resolvconf', 'interop_enabled', + 'interop_appendwindowspath', 'gui_theme', + 'gui_followwintheme', 'legacy_gui', + 'legacy_audio', 'adv_ip_detect', + 'wsl_motd_news', 'automount', 'mountfstab']): reconfiguration = WSLConfiguration2Data( custom_path=self.answers['custom_path'], custom_mount_opt=self.answers['custom_mount_opt'], gen_host=self.answers['gen_host'], gen_resolvconf=self.answers['gen_resolvconf'], interop_enabled=self.answers['interop_enabled'], - interop_appendwindowspath=self.answers['interop_appendwindowspath'], + interop_appendwindowspath=self + .answers['interop_appendwindowspath'], gui_theme=self.answers['gui_theme'], gui_followwintheme=self.answers['gui_followwintheme'], legacy_gui=self.answers['legacy_gui'], @@ -61,4 +63,4 @@ class ReconfigurationController(SubiquityTuiController): self.app.next_screen(self.endpoint.POST(reconf_data)) def cancel(self): - self.app.prev_screen() \ No newline at end of file + self.app.prev_screen() diff --git a/system_setup/models/system_server.py b/system_setup/models/system_server.py index 8568df0a..1e2b571f 100644 --- a/system_setup/models/system_server.py +++ b/system_setup/models/system_server.py @@ -18,7 +18,7 @@ import logging from subiquity.models.subiquity import SubiquityModel -from subiquitycore.utils import run_command, is_wsl +from subiquitycore.utils import is_wsl from subiquity.models.locale import LocaleModel @@ -41,6 +41,7 @@ ff02::1 ip6-allnodes ff02::2 ip6-allrouters """ + class SystemSetupModel(SubiquityModel): """The overall model for subiquity.""" @@ -91,8 +92,8 @@ class SystemSetupModel(SubiquityModel): } def configured(self, model_name): - # We need to override the parent class as *_MODEL_NAMES are global variables - # in server.py + # We need to override the parent class as + # *_MODEL_NAMES are global variables in server.py if model_name not in self.ALL_MODEL_NAMES: return self._events[model_name].set() diff --git a/system_setup/models/wslconf2.py b/system_setup/models/wslconf2.py index 5efee78f..3f846047 100644 --- a/system_setup/models/wslconf2.py +++ b/system_setup/models/wslconf2.py @@ -16,7 +16,6 @@ import logging import subprocess import attr -import json from subiquitycore.utils import run_command @@ -50,7 +49,8 @@ class WSLConfiguration2Model(object): def apply_settings(self, result, is_dry_run=False): d = {} - #TODO: placholder settings; should be dynamically assgined using ubuntu-wsl-integration + # TODO: placholder settings; should be dynamically assgined using + # ubuntu-wsl-integration d['custom_path'] = result.custom_path d['custom_mount_opt'] = result.custom_mount_opt d['gen_host'] = result.gen_host @@ -71,7 +71,8 @@ class WSLConfiguration2Model(object): run_command(["/usr/bin/ubuntuwsl", "reset", "-y"], stdout=subprocess.DEVNULL) # set the settings - #TODO: placholder settings; should be dynamically generated using ubuntu-wsl-integration + # TODO: placholder settings; should be dynamically generated using + # ubuntu-wsl-integration run_command(["/usr/bin/ubuntuwsl", "update", "WSL.automount.enabled", result.automount], stdout=subprocess.DEVNULL) @@ -100,7 +101,8 @@ class WSLConfiguration2Model(object): result.interop_appendwindowspath], stdout=subprocess.DEVNULL) run_command(["/usr/bin/ubuntuwsl", "update", - "ubuntu.GUI.followwintheme", result.gui_followwintheme], + "ubuntu.GUI.followwintheme", + result.gui_followwintheme], stdout=subprocess.DEVNULL) run_command(["/usr/bin/ubuntuwsl", "update", "ubuntu.GUI.theme", result.gui_theme], @@ -109,15 +111,16 @@ class WSLConfiguration2Model(object): "ubuntu.Interop.guiintergration", result.legacy_gui], stdout=subprocess.DEVNULL) run_command(["/usr/bin/ubuntuwsl", "update", - "ubuntu.Interop.audiointegration", result.legacy_audio], + "ubuntu.Interop.audiointegration", + result.legacy_audio], stdout=subprocess.DEVNULL) run_command(["/usr/bin/ubuntuwsl", "update", - "ubuntu.Interop.advancedipdetection", result.adv_ip_detect], + "ubuntu.Interop.advancedipdetection", + result.adv_ip_detect], stdout=subprocess.DEVNULL) run_command(["/usr/bin/ubuntuwsl", "update", "ubuntu.Motd.wslnewsenabled", result.wsl_motd_news], - stdout=subprocess.DEVNULL) - + stdout=subprocess.DEVNULL) @property def wslconf2(self): diff --git a/system_setup/server/controllers/__init__.py b/system_setup/server/controllers/__init__.py index d30820b7..3c52b268 100644 --- a/system_setup/server/controllers/__init__.py +++ b/system_setup/server/controllers/__init__.py @@ -13,7 +13,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from subiquity.server.controllers.cmdlist import EarlyController, LateController, ErrorController +from subiquity.server.controllers.cmdlist import ( + EarlyController, + LateController, + ErrorController, + ) from subiquity.server.controllers.locale import LocaleController from subiquity.server.controllers.reporting import ReportingController from subiquity.server.controllers.userdata import UserdataController @@ -31,4 +35,4 @@ __all__ = [ 'UserdataController', "WSLConfiguration1Controller", "WSLConfiguration2Controller", -] \ No newline at end of file +] diff --git a/system_setup/server/controllers/identity.py b/system_setup/server/controllers/identity.py index a6769b0c..2935170b 100644 --- a/system_setup/server/controllers/identity.py +++ b/system_setup/server/controllers/identity.py @@ -17,8 +17,6 @@ import logging import attr -from subiquitycore.context import with_context - from subiquity.common.types import IdentityData from subiquity.server.controllers.identity import IdentityController diff --git a/system_setup/server/controllers/wslconf2.py b/system_setup/server/controllers/wslconf2.py index 4b474c9e..ce65f39b 100644 --- a/system_setup/server/controllers/wslconf2.py +++ b/system_setup/server/controllers/wslconf2.py @@ -113,22 +113,24 @@ class WSLConfiguration2Controller(SubiquityController): if b in self.config_ref['ubuntu'][a]: data[self.config_ref['ubuntu'][a][b]] = a_x[b] if data: - yes_no_converter = lambda x: x == 'true' + def bool_converter(x): + return x == 'true' reconf_data = WSLConfiguration2Data( custom_path=data['custom_path'], custom_mount_opt=data['custom_mount_opt'], - gen_host=yes_no_converter(data['gen_host']), - gen_resolvconf=yes_no_converter(data['gen_resolvconf']), - interop_enabled=yes_no_converter(data['interop_enabled']), - interop_appendwindowspath=yes_no_converter(data['interop_appendwindowspath']), + gen_host=bool_converter(data['gen_host']), + gen_resolvconf=bool_converter(data['gen_resolvconf']), + interop_enabled=bool_converter(data['interop_enabled']), + interop_appendwindowspath=bool_converter( + data['interop_appendwindowspath']), gui_theme=data['gui_theme'], - gui_followwintheme=yes_no_converter(data['gui_followwintheme']), - legacy_gui=yes_no_converter(data['legacy_gui']), - legacy_audio=yes_no_converter(data['legacy_audio']), - adv_ip_detect=yes_no_converter(data['adv_ip_detect']), - wsl_motd_news=yes_no_converter(data['wsl_motd_news']), - automount=yes_no_converter(data['automount']), - mountfstab=yes_no_converter(data['mountfstab']), + gui_followwintheme=bool_converter(data['gui_followwintheme']), + legacy_gui=bool_converter(data['legacy_gui']), + legacy_audio=bool_converter(data['legacy_audio']), + adv_ip_detect=bool_converter(data['adv_ip_detect']), + wsl_motd_news=bool_converter(data['wsl_motd_news']), + automount=bool_converter(data['automount']), + mountfstab=bool_converter(data['mountfstab']), ) self.model.apply_settings(reconf_data, self.opts.dry_run) @@ -168,7 +170,8 @@ class WSLConfiguration2Controller(SubiquityController): data.gen_host = self.model.wslconf2.gen_host data.gen_resolvconf = self.model.wslconf2.gen_resolvconf data.interop_enabled = self.model.wslconf2.interop_enabled - data.interop_appendwindowspath = self.model.wslconf2.interop_appendwindowspath + data.interop_appendwindowspath = \ + self.model.wslconf2.interop_appendwindowspath data.gui_theme = self.model.wslconf2.gui_theme data.gui_followwintheme = self.model.wslconf2.gui_followwintheme data.legacy_gui = self.model.wslconf2.legacy_gui diff --git a/system_setup/ui/views/__init__.py b/system_setup/ui/views/__init__.py index 8ec74019..81db478e 100644 --- a/system_setup/ui/views/__init__.py +++ b/system_setup/ui/views/__init__.py @@ -23,4 +23,4 @@ __all__ = [ 'IntegrationView', 'OverviewView', 'ReconfigurationView', -] \ No newline at end of file +] diff --git a/system_setup/ui/views/identity.py b/system_setup/ui/views/identity.py index e4965a2e..4e5788f6 100644 --- a/system_setup/ui/views/identity.py +++ b/system_setup/ui/views/identity.py @@ -20,7 +20,11 @@ from urwid import ( from subiquity.common.types import IdentityData -from subiquity.ui.views.identity import IdentityForm, IdentityView, setup_password_validation +from subiquity.ui.views.identity import ( + IdentityForm, + IdentityView, + setup_password_validation, + ) from subiquitycore.ui.utils import screen from subiquitycore.utils import crypt_password from subiquitycore.view import BaseView @@ -32,10 +36,12 @@ class WSLIdentityForm(IdentityForm): realname = IdentityForm.realname username = IdentityForm.username - username.help = _("The username does not need to match your Windows username") + username.help = \ + _("The username does not need to match your Windows username") password = IdentityForm.password confirm_password = IdentityForm.confirm_password + class WSLIdentityView(BaseView): title = IdentityView.title excerpt = _("Please create a default UNIX user account. " @@ -61,7 +67,8 @@ class WSLIdentityView(BaseView): 'username': identity_data.username, } - # This is the different form model with IdentityView which prevents us from inheriting it + # This is the different form model with IdentityView + # which prevents us from inheriting it self.form = WSLIdentityForm([], initial) connect_signal(self.form, 'submit', self.done) diff --git a/system_setup/ui/views/integration.py b/system_setup/ui/views/integration.py index 3123a15e..aacb2af8 100644 --- a/system_setup/ui/views/integration.py +++ b/system_setup/ui/views/integration.py @@ -40,8 +40,11 @@ class IntegrationForm(Form): def __init__(self, initial): super().__init__(initial=initial) - custom_path = MountField(_("Mount Location"), help=_("Location for the automount")) - custom_mount_opt = StringField(_("Mount Option"), help=_("Mount option passed for the automount")) + custom_path = MountField(_("Mount Location"), + help=_("Location for the automount")) + custom_mount_opt = StringField(_("Mount Option"), + help=_("Mount option passed " + "for the automount")) gen_host = BooleanField(_("Enable Host Generation"), help=_( "Selecting enables /etc/host re-generation at every start")) gen_resolvconf = BooleanField(_("Enable resolv.conf Generation"), help=_( @@ -50,15 +53,18 @@ class IntegrationForm(Form): def validate_custom_path(self): p = self.custom_path.value if p != "" and (re.fullmatch(r"(/[^/ ]*)+/?", p) is None): - return _("Mount location must be a absolute UNIX path without space.") + return _("Mount location must be a absolute UNIX path" + " without space.") def validate_custom_mount_opt(self): o = self.custom_mount_opt.value # filesystem independent mount option - fsimo = [r"async", r"(no)?atime", r"(no)?auto", r"(fs|def|root)?context=\w+", r"(no)?dev", r"(no)?diratime", - r"dirsync", r"(no)?exec", r"group", r"(no)?iversion", r"(no)?mand", r"_netdev", r"nofail", - r"(no)?relatime", r"(no)?strictatime", r"(no)?suid", r"owner", r"remount", r"ro", r"rw", - r"_rnetdev", r"sync", r"(no)?user", r"users"] + fsimo = [r"async", r"(no)?atime", r"(no)?auto", + r"(fs|def|root)?context=\w+", r"(no)?dev", r"(no)?diratime", + r"dirsync", r"(no)?exec", r"group", r"(no)?iversion", + r"(no)?mand", r"_netdev", r"nofail", r"(no)?relatime", + r"(no)?strictatime", r"(no)?suid", r"owner", r"remount", + r"ro", r"rw", r"_rnetdev", r"sync", r"(no)?user", r"users"] # DrvFs filesystem mount option drvfsmo = r"case=(dir|force|off)|metadata|(u|g)id=\d+|(u|f|d)mask=\d+|" fso = "{0}{1}".format(drvfsmo, '|'.join(fsimo)) @@ -78,26 +84,25 @@ class IntegrationForm(Form): x = x and False if not x: return _("Invalid Input: {}Please check " - "https://docs.microsoft.com/en-us/windows/wsl/wsl-config#mount-options " - "for correct valid input").format(e_t) + "https://docs.microsoft.com/en-us/windows/wsl/" + "wsl-config#mount-options " + "for correct valid input").format(e_t) class IntegrationView(BaseView): title = _("Tweaks") - excerpt = _("In this page, you can tweak Ubuntu WSL to your needs. \n" - ) + excerpt = _("In this page, you can tweak Ubuntu WSL to your needs. \n") def __init__(self, controller, integration_data): self.controller = controller initial = { 'custom_path': integration_data.custom_path, - 'custom_mount_opt':integration_data.custom_mount_opt, + 'custom_mount_opt': integration_data.custom_mount_opt, 'gen_host': integration_data.gen_host, 'gen_resolvconf': integration_data.gen_resolvconf, } self.form = IntegrationForm(initial=initial) - connect_signal(self.form, 'submit', self.done) super().__init__( diff --git a/system_setup/ui/views/overview.py b/system_setup/ui/views/overview.py index 1234e661..5343360a 100644 --- a/system_setup/ui/views/overview.py +++ b/system_setup/ui/views/overview.py @@ -26,12 +26,15 @@ class OverviewView(BaseView): os.remove('/var/run/ubuntu_wsl_oobe_assigned_account') complete_text = _("Hi {username},\n" "You have complete the setup!\n\n" - "It is suggested to run the following command to update your Ubuntu " - "to the latest version:\n\n\n" + "It is suggested to run the following command" + " to update your Ubuntu to the latest version:" + "\n\n\n" " $ sudo apt update\n $ sudo apt upgrade\n\n\n" - "You can use the builtin `ubuntuwsl` command to manage your WSL settings:\n\n\n" + "You can use the builtin `ubuntuwsl` command to " + "manage your WSL settings:\n\n\n" " $ sudo ubuntuwsl ...\n\n\n" - "* All settings will take effect after first restart of Ubuntu.").format(username=user_name) + "* All settings will take effect after first " + "restart of Ubuntu.").format(username=user_name) super().__init__( screen( diff --git a/system_setup/ui/views/reconfiguration.py b/system_setup/ui/views/reconfiguration.py index 8a834c53..a85320b0 100644 --- a/system_setup/ui/views/reconfiguration.py +++ b/system_setup/ui/views/reconfiguration.py @@ -41,38 +41,82 @@ class ReconfigurationForm(Form): def __init__(self, initial): super().__init__(initial=initial) - #TODO: placholder settings UI; should be dynamically generated using ubuntu-wsl-integration - automount = BooleanField(_("Enable Auto-Mount"), - help=_("Whether the Auto-Mount freature is enabled. This feature allows you to mount Windows drive in WSL")) + # TODO: placholder settings UI; should be dynamically generated using + # ubuntu-wsl-integration + automount = BooleanField(_("Enable Auto-Mount"), + help=_("Whether the Auto-Mount freature is" + " enabled. This feature allows you " + "to mount Windows drive in WSL")) mountfstab = BooleanField(_("Mount `/etc/fstab`"), - help=_("Whether `/etc/fstab` will be mounted. The configuration file `/etc/fstab` contains the necessary information to automate the process of mounting partitions. ")) - custom_path = MountField(_("Auto-Mount Location"), help=_("Location for the automount")) - custom_mount_opt = StringField(_("Auto-Mount Option"), help=_("Mount option passed for the automount")) + help=_("Whether `/etc/fstab` will be mounted." + " The configuration file `/etc/fstab` " + "contains the necessary information to" + " automate the process of mounting " + "partitions. ")) + custom_path = MountField(_("Auto-Mount Location"), + help=_("Location for the automount")) + custom_mount_opt = StringField(_("Auto-Mount Option"), + help=_("Mount option passed for " + "the automount")) gen_host = BooleanField(_("Enable Host Generation"), help=_( "Selecting enables /etc/host re-generation at every start")) gen_resolvconf = BooleanField(_("Enable resolv.conf Generation"), help=_( "Selecting enables /etc/resolv.conf re-generation at every start")) - interop_enabled = BooleanField(_("Enable Interop"), help=_("Whether the interoperability is enabled")) - interop_appendwindowspath = BooleanField(_("Append Windows Path"), help=_("Whether Windows Path will be append in the PATH environment variable in WSL.")) - gui_theme = ChoiceField(_("GUI Theme"), help=_("This option changes the Ubuntu theme."), choices=["default", "light", "dark"]) - gui_followwintheme = BooleanField(_("Follow Windows Theme"), help=_("This option manages whether the Ubuntu theme follows the Windows theme; that is, when Windows uses dark theme, Ubuntu also uses dark theme. Requires WSL interoperability enabled. ")) - legacy_gui = BooleanField(_("Legacy GUI Integration"), help=_("This option enables the Legacy GUI Integration on Windows 10. Requires a Third-party X Server.")) - legacy_audio = BooleanField(_("Legacy Audio Integration"), help=_("This option enables the Legacy Audio Integration on Windows 10. Requires PulseAudio for Windows Installed.")) - adv_ip_detect = BooleanField(_("Advanced IP Detection"), help=_("This option enables advanced detection of IP by Windows IPv4 Address which is more reliable to use with WSL2. Requires WSL interoperability enabled.")) - wsl_motd_news = BooleanField(_("Enable WSL News"), help=_("This options allows you to control your MOTD News. Toggling it on allows you to see the MOTD.")) + interop_enabled = BooleanField(_("Enable Interop"), + help=_("Whether the interoperability is" + " enabled")) + interop_appendwindowspath = BooleanField(_("Append Windows Path"), + help=_("Whether Windows Path " + "will be append in the" + " PATH environment " + "variable in WSL.")) + gui_theme = ChoiceField(_("GUI Theme"), + help=_("This option changes the Ubuntu theme."), + choices=["default", "light", "dark"]) + gui_followwintheme = BooleanField(_("Follow Windows Theme"), + help=_("This option manages whether the" + " Ubuntu theme follows the " + "Windows theme; that is, when " + "Windows uses dark theme, " + "Ubuntu also uses dark theme." + " Requires WSL interoperability" + " enabled. ")) + legacy_gui = BooleanField(_("Legacy GUI Integration"), + help=_("This option enables the Legacy GUI " + "Integration on Windows 10. Requires" + " a Third-party X Server.")) + legacy_audio = BooleanField(_("Legacy Audio Integration"), + help=_("This option enables the Legacy " + "Audio Integration on Windows 10. " + "Requires PulseAudio for " + "Windows Installed.")) + adv_ip_detect = BooleanField(_("Advanced IP Detection"), + help=_("This option enables advanced " + "detection of IP by Windows " + "IPv4 Address which is more " + "reliable to use with WSL2. " + "Requires WSL interoperability" + " enabled.")) + wsl_motd_news = BooleanField(_("Enable WSL News"), + help=_("This options allows you to control" + " your MOTD News. Toggling it on " + "allows you to see the MOTD.")) def validate_custom_path(self): p = self.custom_path.value if p != "" and (re.fullmatch(r"(/[^/ ]*)+/?", p) is None): - return _("Mount location must be a absolute UNIX path without space.") + return _("Mount location must be a absolute UNIX path" + " without space.") def validate_custom_mount_opt(self): o = self.custom_mount_opt.value # filesystem independent mount option - fsimo = [r"async", r"(no)?atime", r"(no)?auto", r"(fs|def|root)?context=\w+", r"(no)?dev", r"(no)?diratime", - r"dirsync", r"(no)?exec", r"group", r"(no)?iversion", r"(no)?mand", r"_netdev", r"nofail", - r"(no)?relatime", r"(no)?strictatime", r"(no)?suid", r"owner", r"remount", r"ro", r"rw", - r"_rnetdev", r"sync", r"(no)?user", r"users"] + fsimo = [r"async", r"(no)?atime", r"(no)?auto", + r"(fs|def|root)?context=\w+", r"(no)?dev", r"(no)?diratime", + r"dirsync", r"(no)?exec", r"group", r"(no)?iversion", + r"(no)?mand", r"_netdev", r"nofail", r"(no)?relatime", + r"(no)?strictatime", r"(no)?suid", r"owner", r"remount", + r"ro", r"rw", r"_rnetdev", r"sync", r"(no)?user", r"users"] # DrvFs filesystem mount option drvfsmo = r"case=(dir|force|off)|metadata|(u|g)id=\d+|(u|f|d)mask=\d+|" fso = "{0}{1}".format(drvfsmo, '|'.join(fsimo)) @@ -92,24 +136,26 @@ class ReconfigurationForm(Form): x = x and False if not x: return _("Invalid Input: {}Please check " - "https://docs.microsoft.com/en-us/windows/wsl/wsl-config#mount-options " - "for correct valid input").format(e_t) + "https://docs.microsoft.com/en-us/windows/wsl/" + "wsl-config#mount-options " + "for correct valid input").format(e_t) + class ReconfigurationView(BaseView): title = _("Configuration") - excerpt = _("In this page, you can tweak Ubuntu WSL to your needs. \n" - ) + excerpt = _("In this page, you can tweak Ubuntu WSL to your needs. \n") def __init__(self, controller, integration_data): self.controller = controller initial = { 'custom_path': integration_data.custom_path, - 'custom_mount_opt':integration_data.custom_mount_opt, + 'custom_mount_opt': integration_data.custom_mount_opt, 'gen_host': integration_data.gen_host, 'gen_resolvconf': integration_data.gen_resolvconf, 'interop_enabled': integration_data.interop_enabled, - 'interop_appendwindowspath': integration_data.interop_appendwindowspath, + 'interop_appendwindowspath': + integration_data.interop_appendwindowspath, 'gui_theme': integration_data.gui_theme, 'gui_followwintheme': integration_data.gui_followwintheme, 'legacy_gui': integration_data.legacy_gui, @@ -120,7 +166,6 @@ class ReconfigurationView(BaseView): 'mountfstab': integration_data.mountfstab, } self.form = ReconfigurationForm(initial=initial) - connect_signal(self.form, 'submit', self.done) super().__init__( @@ -139,7 +184,8 @@ class ReconfigurationView(BaseView): gen_host=self.form.gen_host.value, gen_resolvconf=self.form.gen_resolvconf.value, interop_enabled=self.form.interop_enabled.value, - interop_appendwindowspath=self.form.interop_appendwindowspath.value, + interop_appendwindowspath=self.form + .interop_appendwindowspath.value, gui_theme=self.form.gui_theme.value, gui_followwintheme=self.form.gui_followwintheme.value, legacy_gui=self.form.legacy_gui.value,