2021-08-31 10:54:15 +00:00
|
|
|
""" WSLConfigurationAdvanced View
|
2021-07-22 16:49:12 +00:00
|
|
|
|
2021-08-31 11:26:49 +00:00
|
|
|
WSLConfigurationAdvanced provides user with options with additional settings
|
|
|
|
for advanced configuration.
|
2021-07-22 16:49:12 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
import re
|
|
|
|
|
|
|
|
from urwid import connect_signal
|
2023-07-25 21:26:25 +00:00
|
|
|
|
2021-07-22 16:49:12 +00:00
|
|
|
from subiquity.common.types import WSLConfigurationAdvanced
|
|
|
|
from subiquitycore.ui.form import BooleanField, Form, WantsToKnowFormField, simple_field
|
|
|
|
from subiquitycore.ui.interactive import StringEditor
|
|
|
|
from subiquitycore.ui.utils import screen
|
|
|
|
from subiquitycore.view import BaseView
|
|
|
|
|
|
|
|
|
|
|
|
class MountEditor(StringEditor, WantsToKnowFormField):
|
|
|
|
def keypress(self, size, key):
|
|
|
|
"""restrict what chars we allow for mountpoints"""
|
|
|
|
|
|
|
|
mountpoint = r"[a-zA-Z0-9_/\.\-]"
|
|
|
|
if re.match(mountpoint, key) is None:
|
|
|
|
return False
|
|
|
|
|
|
|
|
return super().keypress(size, key)
|
|
|
|
|
|
|
|
|
|
|
|
MountField = simple_field(MountEditor)
|
|
|
|
StringField = simple_field(StringEditor)
|
|
|
|
|
|
|
|
|
2021-08-31 10:54:15 +00:00
|
|
|
class WSLConfigurationAdvancedForm(Form):
|
2021-07-22 16:49:12 +00:00
|
|
|
def __init__(self, initial):
|
|
|
|
super().__init__(initial=initial)
|
|
|
|
|
2021-10-04 10:55:25 +00:00
|
|
|
automount_enabled = BooleanField(
|
|
|
|
_("Enable Auto-Mount"),
|
2022-03-16 11:23:46 +00:00
|
|
|
help=_(
|
|
|
|
"Whether the Auto-Mount feature is enabled. "
|
2021-10-04 10:55:25 +00:00
|
|
|
"This feature allows you to mount Windows drive"
|
|
|
|
" in WSL."
|
2023-07-25 21:26:25 +00:00
|
|
|
),
|
2021-10-04 10:55:25 +00:00
|
|
|
)
|
|
|
|
automount_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. "
|
|
|
|
),
|
2023-07-25 21:26:25 +00:00
|
|
|
)
|
2021-10-04 10:55:25 +00:00
|
|
|
interop_enabled = BooleanField(
|
|
|
|
_("Enable Interop"), help=_("Whether the interoperability is enabled")
|
2023-07-25 21:26:25 +00:00
|
|
|
)
|
2021-10-04 10:55:25 +00:00
|
|
|
interop_appendwindowspath = BooleanField(
|
|
|
|
_("Append Windows Path"),
|
|
|
|
help=_(
|
|
|
|
"Whether Windows Path will be append in the"
|
|
|
|
" PATH environment variable in WSL."
|
2023-07-25 21:26:25 +00:00
|
|
|
),
|
2021-10-04 10:55:25 +00:00
|
|
|
)
|
2022-04-07 08:55:30 +00:00
|
|
|
# systemd_enabled = \
|
|
|
|
# BooleanField(_("Enable Systemd"),
|
|
|
|
# help=_("EXPERIMENTAL - Whether systemd should be"
|
|
|
|
# " activated at boot time."))
|
2021-07-22 16:49:12 +00:00
|
|
|
|
|
|
|
|
2021-08-31 10:54:15 +00:00
|
|
|
class WSLConfigurationAdvancedView(BaseView):
|
2021-09-06 02:36:57 +00:00
|
|
|
title = _("WSL Configuration - Advanced options")
|
|
|
|
excerpt = _(
|
|
|
|
"In this page, you can configure Ubuntu WSL advanced options your needs. \n"
|
2021-08-31 11:26:49 +00:00
|
|
|
)
|
2021-07-22 16:49:12 +00:00
|
|
|
|
2021-08-31 10:54:15 +00:00
|
|
|
def __init__(self, controller, configuration_data):
|
2021-07-22 16:49:12 +00:00
|
|
|
self.controller = controller
|
|
|
|
|
|
|
|
initial = {
|
2021-10-05 01:38:10 +00:00
|
|
|
"interop_enabled": configuration_data.interop_enabled,
|
2021-08-31 10:54:15 +00:00
|
|
|
"interop_appendwindowspath": configuration_data.interop_appendwindowspath,
|
2021-10-05 01:38:10 +00:00
|
|
|
"automount_enabled": configuration_data.automount_enabled,
|
|
|
|
"automount_mountfstab": configuration_data.automount_mountfstab,
|
2022-04-07 08:55:30 +00:00
|
|
|
# 'systemd_enabled':
|
|
|
|
# configuration_data.systemd_enabled,
|
2021-07-22 16:49:12 +00:00
|
|
|
}
|
2021-08-31 10:54:15 +00:00
|
|
|
self.form = WSLConfigurationAdvancedForm(initial=initial)
|
2021-07-22 16:49:12 +00:00
|
|
|
|
|
|
|
connect_signal(self.form, "submit", self.done)
|
|
|
|
super().__init__(
|
|
|
|
screen(
|
|
|
|
self.form.as_rows(),
|
|
|
|
[self.form.done_btn],
|
|
|
|
focus_buttons=True,
|
|
|
|
excerpt=self.excerpt,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
def done(self, result):
|
2021-08-31 10:54:15 +00:00
|
|
|
self.controller.done(
|
|
|
|
WSLConfigurationAdvanced(
|
2021-10-05 01:38:10 +00:00
|
|
|
interop_enabled=self.form.interop_enabled.value,
|
2021-08-12 14:31:27 +00:00
|
|
|
interop_appendwindowspath=self.form.interop_appendwindowspath.value,
|
2021-10-05 01:38:10 +00:00
|
|
|
automount_enabled=self.form.automount_enabled.value,
|
|
|
|
automount_mountfstab=self.form.automount_mountfstab.value,
|
2022-04-07 08:55:30 +00:00
|
|
|
# systemd_enabled=self.form
|
|
|
|
# .systemd_enabled.value,
|
2023-07-25 21:26:25 +00:00
|
|
|
)
|
2022-04-07 08:55:30 +00:00
|
|
|
)
|