本文整理汇总了Python中simpleline.render.containers.ListColumnContainer.process_user_input方法的典型用法代码示例。如果您正苦于以下问题:Python ListColumnContainer.process_user_input方法的具体用法?Python ListColumnContainer.process_user_input怎么用?Python ListColumnContainer.process_user_input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simpleline.render.containers.ListColumnContainer
的用法示例。
在下文中一共展示了ListColumnContainer.process_user_input方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PartitionSchemeSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class PartitionSchemeSpoke(NormalTUISpoke):
""" Spoke to select what partitioning scheme to use on disk(s). """
category = SystemCategory
def __init__(self, data, storage, payload):
super().__init__(data, storage, payload)
self.title = N_("Partition Scheme Options")
self._container = None
self.part_schemes = OrderedDict()
self._auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING)
pre_select = self._auto_part_proxy.Type
supported_choices = get_supported_autopart_choices()
if supported_choices:
# Fallback value (eg when default is not supported)
self._selected_scheme_value = supported_choices[0][1]
for item in supported_choices:
self.part_schemes[item[0]] = item[1]
if item[1] == pre_select:
self._selected_scheme_value = item[1]
@property
def indirect(self):
return True
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1)
for scheme, value in self.part_schemes.items():
box = CheckboxWidget(title=_(scheme), completed=(value == self._selected_scheme_value))
self._container.add(box, self._set_part_scheme_callback, value)
self.window.add_with_separator(self._container)
message = _("Select a partition scheme configuration.")
self.window.add_with_separator(TextWidget(message))
def _set_part_scheme_callback(self, data):
self._selected_scheme_value = data
def input(self, args, key):
""" Grab the choice and update things. """
if not self._container.process_user_input(key):
# TRANSLATORS: 'c' to continue
if key.lower() == C_('TUI|Spoke Navigation', 'c'):
self.apply()
return InputState.PROCESSED_AND_CLOSE
else:
return super().input(args, key)
return InputState.PROCESSED_AND_REDRAW
def apply(self):
""" Apply our selections. """
self._auto_part_proxy.SetType(self._selected_scheme_value)
示例2: NTPServersSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class NTPServersSpoke(NormalTUISpoke):
category = LocalizationCategory
def __init__(self, data, storage, payload, time_spoke):
super().__init__(data, storage, payload)
self.title = N_("NTP configuration")
self._container = None
self._time_spoke = time_spoke
@property
def indirect(self):
return True
def _summary_text(self):
"""Return summary of NTP configuration."""
msg = _("NTP servers:")
if self._time_spoke.ntp_servers:
for status in format_ntp_status_list(self._time_spoke.ntp_servers):
msg += "\n%s" % status
else:
msg += _("no NTP servers have been configured")
return msg
def refresh(self, args=None):
super().refresh(args)
summary = self._summary_text()
self.window.add_with_separator(TextWidget(summary))
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
self._container.add(TextWidget(_("Add NTP server")), self._add_ntp_server)
# only add the remove option when we can remove something
if self._time_spoke.ntp_servers:
self._container.add(TextWidget(_("Remove NTP server")), self._remove_ntp_server)
self.window.add_with_separator(self._container)
def _add_ntp_server(self, data):
new_spoke = AddNTPServerSpoke(self.data, self.storage, self.payload, self._time_spoke)
ScreenHandler.push_screen_modal(new_spoke)
self.redraw()
def _remove_ntp_server(self, data):
new_spoke = RemoveNTPServerSpoke(self.data, self.storage, self.payload, self._time_spoke)
ScreenHandler.push_screen_modal(new_spoke)
self.redraw()
def input(self, args, key):
if self._container.process_user_input(key):
return InputState.PROCESSED
else:
return super().input(args, key)
def apply(self):
pass
示例3: RootSelectionSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class RootSelectionSpoke(NormalTUISpoke):
"""UI for selection of installed system root to be mounted."""
def __init__(self, roots):
super().__init__(data=None, storage=None, payload=None)
self.title = N_("Root Selection")
self._roots = roots
self._selection = roots[0]
self._container = None
@property
def selection(self):
"""The selected root fs to mount."""
return self._selection
@property
def indirect(self):
return True
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1)
for root in self._roots:
box = CheckboxWidget(
title="{} on {}".format(root.name, root.device.path),
completed=(self._selection == root)
)
self._container.add(box, self._select_root, root)
message = _("The following installations were discovered on your system.")
self.window.add_with_separator(TextWidget(message))
self.window.add_with_separator(self._container)
def _select_root(self, root):
self._selection = root
def prompt(self, args=None):
""" Override the default TUI prompt."""
prompt = Prompt()
prompt.add_continue_option()
return prompt
def input(self, args, key):
"""Override any input so we can launch rescue mode."""
if self._container.process_user_input(key):
return InputState.PROCESSED_AND_REDRAW
elif key == Prompt.CONTINUE:
return InputState.PROCESSED_AND_CLOSE
else:
return key
def apply(self):
"""Define the abstract method."""
pass
示例4: SpecifyRepoSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class SpecifyRepoSpoke(NormalTUISpoke, SourceSwitchHandler):
""" Specify the repo URL here if closest mirror not selected. """
category = SoftwareCategory
HTTP = 1
HTTPS = 2
FTP = 3
def __init__(self, data, storage, payload, instclass, protocol):
NormalTUISpoke.__init__(self, data, storage, payload, instclass)
SourceSwitchHandler.__init__(self)
self.title = N_("Specify Repo Options")
self.protocol = protocol
self._container = None
self._url = self.data.url.url
def refresh(self, args=None):
""" Refresh window. """
NormalTUISpoke.refresh(self, args)
self._container = ListColumnContainer(1)
dialog = Dialog(_("Repo URL"))
self._container.add(EntryWidget(dialog.title, self._url), self._set_repo_url, dialog)
self.window.add_with_separator(self._container)
def _set_repo_url(self, dialog):
self._url = dialog.run()
def input(self, args, key):
if self._container.process_user_input(key):
self.apply()
return InputState.PROCESSED_AND_REDRAW
else:
return NormalTUISpoke.input(self, args, key)
@property
def indirect(self):
return True
def apply(self):
""" Apply all of our changes. """
if self.protocol == SpecifyRepoSpoke.HTTP and not self._url.startswith("http://"):
url = "http://" + self._url
elif self.protocol == SpecifyRepoSpoke.HTTPS and not self._url.startswith("https://"):
url = "https://" + self._url
elif self.protocol == SpecifyRepoSpoke.FTP and not self._url.startswith("ftp://"):
url = "ftp://" + self._url
else:
# protocol either unknown or entry already starts with a protocol
# specification
url = self._url
self.set_source_url(url)
示例5: PartitionSchemeSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class PartitionSchemeSpoke(NormalTUISpoke):
""" Spoke to select what partitioning scheme to use on disk(s). """
category = SystemCategory
def __init__(self, data, storage, payload, instclass):
NormalTUISpoke.__init__(self, data, storage, payload, instclass)
self.title = N_("Partition Scheme Options")
self._container = None
self.part_schemes = OrderedDict()
pre_select = self.data.autopart.type or DEFAULT_AUTOPART_TYPE
for item in AUTOPART_CHOICES:
self.part_schemes[item[0]] = item[1]
if item[1] == pre_select:
self._selected_scheme_value = item[1]
@property
def indirect(self):
return True
def refresh(self, args=None):
NormalTUISpoke.refresh(self, args)
self._container = ListColumnContainer(1)
for scheme, value in self.part_schemes.items():
box = CheckboxWidget(title=_(scheme), completed=(value == self._selected_scheme_value))
self._container.add(box, self._set_part_scheme_callback, value)
self.window.add_with_separator(self._container)
message = _("Select a partition scheme configuration.")
self.window.add_with_separator(TextWidget(message))
def _set_part_scheme_callback(self, data):
self._selected_scheme_value = data
def input(self, args, key):
""" Grab the choice and update things. """
if not self._container.process_user_input(key):
# TRANSLATORS: 'c' to continue
if key.lower() == C_('TUI|Spoke Navigation', 'c'):
self.apply()
self.close()
return InputState.PROCESSED
else:
return super(PartitionSchemeSpoke, self).input(args, key)
self.redraw()
return InputState.PROCESSED
def apply(self):
""" Apply our selections. """
self.data.autopart.type = self._selected_scheme_value
示例6: NetworkSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
#.........这里部分代码省略.........
self.redraw()
self.apply()
def _configure_network_interface(self, data):
devname = data
ndata = network.ksdata_from_ifcfg(devname)
if not ndata:
# There is no ifcfg file for the device.
# Make sure there is just one connection for the device.
try:
nm.nm_device_setting_value(devname, "connection", "uuid")
except nm.SettingsNotFoundError:
log.debug("can't find any connection for %s", devname)
return
except nm.MultipleSettingsFoundError:
log.debug("multiple non-ifcfg connections found for %s", devname)
return
log.debug("dumping ifcfg file for in-memory connection %s", devname)
nm.nm_update_settings_of_device(devname, [['connection', 'id', devname, None]])
ndata = network.ksdata_from_ifcfg(devname)
new_spoke = ConfigureNetworkSpoke(self.data, self.storage,
self.payload, self.instclass, ndata)
ScreenHandler.push_screen_modal(new_spoke)
self.redraw()
if ndata.ip == "dhcp":
ndata.bootProto = "dhcp"
ndata.ip = ""
else:
ndata.bootProto = "static"
if not ndata.netmask:
self.errors.append(_("Configuration not saved: netmask missing in static configuration"))
return
if ndata.ipv6 == "ignore":
ndata.noipv6 = True
ndata.ipv6 = ""
else:
ndata.noipv6 = False
uuid = network.update_settings_with_ksdata(devname, ndata)
network.update_onboot_value(devname, ndata.onboot, ksdata=None, root_path="")
network.logIfcfgFiles("settings of %s updated in tui" % devname)
if ndata._apply:
self._apply = True
try:
nm.nm_activate_device_connection(devname, uuid)
except (nm.UnmanagedDeviceError, nm.UnknownConnectionError):
self.errors.append(_("Can't apply configuration, device activation failed."))
self.apply()
def input(self, args, key):
""" Handle the input. """
if self._container.process_user_input(key):
return InputState.PROCESSED
else:
return super(NetworkSpoke, self).input(args, key)
def apply(self):
"""Apply all of our settings."""
self._update_network_data()
log.debug("apply ksdata %s", self.data.network)
if self._apply:
self._apply = False
if ANACONDA_ENVIRON in flags.environs:
from pyanaconda.payload import payloadMgr
payloadMgr.restartThread(self.storage, self.data, self.payload,
self.instclass, checkmount=False)
def _update_network_data(self):
hostname = self.data.network.hostname
self.data.network.network = []
for i, name in enumerate(nm.nm_devices()):
if network.is_ibft_configured_device(name):
continue
nd = network.ksdata_from_ifcfg(name)
if not nd:
continue
if name in nm.nm_activated_devices():
nd.activate = True
else:
# First network command defaults to --activate so we must
# use --no-activate explicitly to prevent the default
if i == 0:
nd.activate = False
self.data.network.network.append(nd)
(valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
if valid:
hostname = self.hostname_dialog.value
else:
self.errors.append(_("Host name is not valid: %s") % error)
self.hostname_dialog.value = hostname
network.update_hostname_data(self.data, hostname)
示例7: SourceSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
#.........这里部分代码省略.........
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
if self.data.method.method == "harddrive" and \
get_mount_device(DRACUT_ISODIR) == get_mount_device(DRACUT_REPODIR):
message = _("The installation source is in use by the installer and cannot be changed.")
self.window.add_with_separator(TextWidget(message))
return
if args == self.SET_NETWORK_INSTALL_MODE:
if self.payload.mirrors_available:
self._container.add(TextWidget(_("Closest mirror")), self._set_network_close_mirror)
self._container.add(TextWidget("http://"), self._set_network_url, SpecifyRepoSpoke.HTTP)
self._container.add(TextWidget("https://"), self._set_network_url, SpecifyRepoSpoke.HTTPS)
self._container.add(TextWidget("ftp://"), self._set_network_url, SpecifyRepoSpoke.FTP)
self._container.add(TextWidget("nfs"), self._set_network_nfs)
else:
self.window.add(TextWidget(_("Choose an installation source type.")))
self._container.add(TextWidget(_("CD/DVD")), self._set_cd_install_source)
self._container.add(TextWidget(_("local ISO file")), self._set_iso_install_source)
self._container.add(TextWidget(_("Network")), self._set_network_install_source)
if self._hmc:
self._container.add(TextWidget(_("SE/HMC")), self._set_hmc_install_source)
self.window.add_with_separator(self._container)
# Set installation source callbacks
def _set_cd_install_source(self, data):
self.set_source_cdrom()
self.payload.install_device = self._cdrom
self.apply()
self.close()
def _set_hmc_install_source(self, data):
self.set_source_hmc()
self.apply()
self.close()
def _set_iso_install_source(self, data):
new_spoke = SelectDeviceSpoke(self.data,
self.storage, self.payload,
self.instclass)
ScreenHandler.push_screen_modal(new_spoke)
self.apply()
self.close()
def _set_network_install_source(self, data):
ScreenHandler.replace_screen(self, self.SET_NETWORK_INSTALL_MODE)
# Set network source callbacks
def _set_network_close_mirror(self, data):
self.set_source_closest_mirror()
self.apply()
self.close()
def _set_network_url(self, data):
new_spoke = SpecifyRepoSpoke(self.data, self.storage,
self.payload, self.instclass, data)
ScreenHandler.push_screen_modal(new_spoke)
self.apply()
self.close()
def _set_network_nfs(self, data):
self.set_source_nfs()
new_spoke = SpecifyNFSRepoSpoke(self.data, self.storage,
self.payload, self.instclass, self._error)
ScreenHandler.push_screen_modal(new_spoke)
self.apply()
self.close()
def input(self, args, key):
""" Handle the input; this decides the repo source. """
if not self._container.process_user_input(key):
return super().input(args, key)
return InputState.PROCESSED
@property
def ready(self):
""" Check if the spoke is ready. """
return (self._ready and
not threadMgr.get(THREAD_PAYLOAD) and
not threadMgr.get(THREAD_CHECK_SOFTWARE))
def apply(self):
""" Execute the selections made. """
# If askmethod was provided on the command line, entering the source
# spoke wipes that out.
if flags.askmethod:
flags.askmethod = False
# if we had any errors, e.g. from a previous attempt to set the source,
# clear them at this point
self._error = False
payloadMgr.restartThread(self.storage, self.data, self.payload, self.instclass,
checkmount=False)
示例8: SelectDeviceSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class SelectDeviceSpoke(NormalTUISpoke):
""" Select device containing the install source ISO file. """
category = SoftwareCategory
def __init__(self, data, storage, payload, instclass):
super().__init__(data, storage, payload, instclass)
self.title = N_("Select device containing the ISO file")
self._container = None
self._mountable_devices = self._get_mountable_devices()
self._device = None
@property
def indirect(self):
return True
def _sanitize_model(self, model):
return model.replace("_", " ")
def _get_mountable_devices(self):
disks = []
fstring = "%(model)s %(path)s (%(size)s MB) %(format)s %(label)s"
for dev in potentialHdisoSources(self.storage.devicetree):
# path model size format type uuid of format
dev_info = {"model": self._sanitize_model(dev.disk.model),
"path": dev.path,
"size": dev.size,
"format": dev.format.name or "",
"label": dev.format.label or dev.format.uuid or ""
}
disks.append([dev, fstring % dev_info])
return disks
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
# check if the storage refresh thread is running
if threadMgr.get(THREAD_STORAGE_WATCHER):
# storage refresh is running - just report it
# so that the user can refresh until it is done
# TODO: refresh once the thread is done ?
message = _(PAYLOAD_STATUS_PROBING_STORAGE)
self.window.add_with_separator(TextWidget(message))
# check if there are any mountable devices
if self._mountable_devices:
for d in self._mountable_devices:
self._container.add(TextWidget(d[1]), callback=self._select_mountable_device, data=d[0])
self.window.add_with_separator(self._container)
else:
message = _("No mountable devices found")
self.window.add_with_separator(TextWidget(message))
def _select_mountable_device(self, data):
self._device = data
new_spoke = SelectISOSpoke(self.data,
self.storage, self.payload,
self.instclass, self._device)
ScreenHandler.push_screen_modal(new_spoke)
self.close()
def input(self, args, key):
if self._container.process_user_input(key):
return InputState.PROCESSED
else:
# either the input was not a number or
# we don't have the disk for the given number
return super().input(args, key)
# Override Spoke.apply
def apply(self):
pass
示例9: ConfigureDeviceSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
#.........这里部分代码省略.........
message = _("Configuring device %s.") % self._iface
self.window.add_with_separator(TextWidget(message))
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv4_or_dhcp(self, user_input, report_func):
return IPV4_OR_DHCP_PATTERN_WITH_ANCHORS.match(user_input) is not None
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv4(self, user_input, report_func):
return IPV4_PATTERN_WITH_ANCHORS.match(user_input) is not None
@report_if_failed(message=NETMASK_ERROR_MSG)
def _check_netmask(self, user_input, report_func):
return IPV4_NETMASK_WITH_ANCHORS.match(user_input) is not None
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv6(self, user_input, report_func):
return network.check_ip_address(user_input, version=6)
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv6_config(self, user_input, report_func):
if user_input in ["auto", "dhcp", "ignore"]:
return True
addr, _slash, prefix = user_input.partition("/")
if prefix:
try:
if not 1 <= int(prefix) <= 128:
return False
except ValueError:
return False
return network.check_ip_address(addr, version=6)
@report_if_failed(message=IP_ERROR_MSG)
def _check_nameservers(self, user_input, report_func):
if user_input.strip():
addresses = [str.strip(i) for i in user_input.split(",")]
for ip in addresses:
if not network.check_ip_address(ip):
return False
return True
def _set_ipv4_or_dhcp(self, dialog):
self._data.ip = dialog.run()
def _set_netmask(self, dialog):
self._data.netmask = dialog.run()
def _set_ipv4_gateway(self, dialog):
self._data.gateway = dialog.run()
def _set_ipv6(self, dialog):
self._data.ipv6 = dialog.run()
def _set_ipv6_gateway(self, dialog):
self._data.ipv6gateway = dialog.run()
def _set_nameservers(self, dialog):
self._data.nameserver = dialog.run()
def _set_apply_handler(self, args):
self.apply_configuration = not self.apply_configuration
def _set_onboot_handler(self, args):
self._data.onboot = not self._data.onboot
def input(self, args, key):
if self._container.process_user_input(key):
return InputState.PROCESSED_AND_REDRAW
else:
# TRANSLATORS: 'c' to continue
if key.lower() == C_('TUI|Spoke Navigation', 'c'):
if self._data.ip != "dhcp" and not self._data.netmask:
self.errors.append(_("Configuration not saved: netmask missing in static configuration"))
else:
self.apply()
return InputState.PROCESSED_AND_CLOSE
else:
return super().input(args, key)
@property
def indirect(self):
return True
def apply(self):
"""Apply changes to NM connection."""
log.debug("updating connection %s:\n%s", self._connection_uuid,
self._connection.to_dbus(NM.ConnectionSerializationFlags.ALL))
self._data.update_connection(self._connection)
# ONBOOT workaround
s_con = self._connection.get_setting_connection()
s_con.set_property(NM.SETTING_CONNECTION_AUTOCONNECT, False)
self._connection.commit_changes(True, None)
log.debug("updated connection %s:\n%s", self._connection_uuid,
self._connection.to_dbus(NM.ConnectionSerializationFlags.ALL))
# ONBOOT workaround
self._set_onboot(self._connection_uuid, self._data.onboot)
示例10: MountPointAssignSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class MountPointAssignSpoke(NormalTUISpoke):
""" Assign mount points to block devices. """
category = SystemCategory
def __init__(self, data, storage, payload):
super().__init__(data, storage, payload)
self.title = N_("Assign mount points")
self._container = None
self._disk_select_proxy = STORAGE.get_proxy(DISK_SELECTION)
self._manual_part_proxy = STORAGE.get_proxy(MANUAL_PARTITIONING)
self._mount_info = self._gather_mount_info()
@property
def indirect(self):
return True
def refresh(self, args=None):
"""Refresh the window."""
super().refresh(args)
self._container = ListColumnContainer(2)
for info in self._mount_info:
widget = TextWidget(self._get_mount_info_description(info))
self._container.add(widget, self._configure_mount_info, info)
message = _(
"Choose device from above to assign mount point and set format.\n"
"Formats marked with * are new formats meaning ALL DATA on the "
"original format WILL BE LOST!"
)
self.window.add_with_separator(self._container)
self.window.add_with_separator(TextWidget(message))
def prompt(self, args=None):
prompt = super().prompt(args)
# TRANSLATORS: 's' to rescan devices
prompt.add_option(C_('TUI|Spoke Navigation|Partitioning', 's'), _("rescan devices"))
return prompt
def input(self, args, key):
""" Grab the choice and update things. """
if self._container.process_user_input(key):
return InputState.PROCESSED
# TRANSLATORS: 's' to rescan devices
if key.lower() == C_('TUI|Spoke Navigation|Partitioning', 's'):
self._rescan_devices()
return InputState.PROCESSED_AND_REDRAW
# TRANSLATORS: 'c' to continue
elif key.lower() == C_('TUI|Spoke Navigation', 'c'):
self.apply()
return super().input(args, key)
def apply(self):
""" Apply our selections. """
mount_points = []
for _device, data in self._mount_info:
if data[MOUNT_POINT_REFORMAT] or data[MOUNT_POINT_PATH]:
mount_points.append({
MOUNT_POINT_PATH: get_variant(Str, data[MOUNT_POINT_PATH] or "none"),
MOUNT_POINT_DEVICE: get_variant(Str, data[MOUNT_POINT_DEVICE]),
MOUNT_POINT_REFORMAT: get_variant(Bool, data[MOUNT_POINT_REFORMAT]),
MOUNT_POINT_FORMAT: get_variant(Str, data[MOUNT_POINT_FORMAT])
})
self._manual_part_proxy.SetMountPoints(mount_points)
def _gather_mount_info(self):
"""Gather info about mount points."""
selected_disks = self._disk_select_proxy.SelectedDisks
mount_points = self._manual_part_proxy.MountPoints
mount_info = []
for device in self.storage.devicetree.leaves:
# Is the device usable?
if device.protected or device.size == Size(0):
continue
# All device's disks have to be in selected disks.
device_disks = {d.name for d in device.disks}
if selected_disks and not set(selected_disks).issuperset(device_disks):
continue
# Append new info about this device.
data = self._get_mount_point_data(device, mount_points)
mount_info.append((device, data))
# Use the data only once.
if data in mount_points:
mount_points.remove(data)
return mount_info
#.........这里部分代码省略.........
示例11: PartTypeSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
#.........这里部分代码省略.........
# default to mount point assignment if it is already (partially)
# configured
self._do_mount_assign = self._orig_mount_assign
if not self._do_mount_assign:
self._init_mode = self._disk_init_proxy.InitializationMode
else:
self._init_mode = CLEAR_PARTITIONS_NONE
@property
def indirect(self):
return True
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1)
for part_type in self._part_type_list:
c = CheckboxWidget(title=_(part_type),
completed=(not self._do_mount_assign
and PARTTYPES[part_type] == self._init_mode)
)
self._container.add(c, self._select_partition_type_callback, part_type)
c = CheckboxWidget(title=_("Manually assign mount points"),
completed=self._do_mount_assign)
self._container.add(c, self._select_mount_assign)
self.window.add_with_separator(self._container)
message = _("Installation requires partitioning of your hard drive. "
"Select what space to use for the install target or "
"manually assign mount points.")
self.window.add_with_separator(TextWidget(message))
def _select_mount_assign(self, data=None):
self._init_mode = CLEAR_PARTITIONS_NONE
self._do_mount_assign = True
self.apply()
def _select_partition_type_callback(self, data):
self._do_mount_assign = False
self._init_mode = PARTTYPES[data]
self.apply()
def apply(self):
# kind of a hack, but if we're actually getting to this spoke, there
# is no doubt that we are doing autopartitioning, so set autopart to
# True. In the case of ks installs which may not have defined any
# partition options, autopart was never set to True, causing some
# issues. (rhbz#1001061)
if not self._do_mount_assign:
self._auto_part_proxy.SetEnabled(True)
self._manual_part_proxy.SetEnabled(False)
self._disk_init_proxy.SetInitializationMode(self._init_mode)
self._disk_init_proxy.SetInitializeLabelsEnabled(True)
else:
self._auto_part_proxy.SetEnabled(False)
self._manual_part_proxy.SetEnabled(True)
self._disk_init_proxy.SetInitializationMode(CLEAR_PARTITIONS_NONE)
self._disk_init_proxy.SetInitializeLabelsEnabled(False)
def _ensure_init_storage(self):
"""
If a different clearpart type was chosen or mount point assignment was
chosen instead, we need to reset/rescan storage to revert all changes
done by the previous run of doKickstartStorage() and get everything into
the initial state.
"""
# the only safe options are:
# 1) if nothing was set before (self._orig_clearpart_type is None) or
if self._orig_init_mode == CLEAR_PARTITIONS_DEFAULT:
return
# 2) mount point assignment was done before and user just wants to tweak it
if self._orig_mount_assign and self._do_mount_assign:
return
# else
print(_("Reverting previous configuration. This may take a moment..."))
reset_storage(self.storage, scan_all=True)
self._manual_part_proxy.SetMountPoints([])
def input(self, args, key):
"""Grab the choice and update things"""
if not self._container.process_user_input(key):
# TRANSLATORS: 'c' to continue
if key.lower() == C_('TUI|Spoke Navigation', 'c'):
self.apply()
self._ensure_init_storage()
if self._do_mount_assign:
new_spoke = MountPointAssignSpoke(self.data, self.storage, self.payload)
else:
new_spoke = PartitionSchemeSpoke(self.data, self.storage, self.payload)
ScreenHandler.push_screen_modal(new_spoke)
return InputState.PROCESSED_AND_CLOSE
else:
return super().input(args, key)
return InputState.PROCESSED_AND_REDRAW
示例12: UserSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
#.........这里部分代码省略.........
def _set_username(self, dialog):
self._user_data.name = dialog.run()
def _set_use_password(self, args):
self._use_password = not self._use_password
def _set_password(self, password_dialog):
password = password_dialog.run()
while password is None:
password = password_dialog.run()
self._user_data.password = password
def _set_administrator(self, args):
self._is_admin = not self._is_admin
def _set_groups(self, dialog):
self._groups = dialog.run()
def show_all(self):
NormalTUISpoke.show_all(self)
# if we have any errors, display them
while self.errors:
print(self.errors.pop())
@property
def completed(self):
""" Verify a user is created; verify pw is set if option checked. """
if len(self.data.user.userList) > 0:
if self._use_password and not bool(self._user_data.password or self._user_data.isCrypted):
return False
else:
return True
else:
return False
@property
def showable(self):
return not (self.completed and flags.automatedInstall
and self.data.user.seen and not self._policy.changesok)
@property
def mandatory(self):
""" Only mandatory if the root pw hasn't been set in the UI
eg. not mandatory if the root account was locked in a kickstart
"""
return not self._users_module.proxy.IsRootPasswordSet and not self._users_module.proxy.IsRootAccountLocked
@property
def status(self):
if len(self.data.user.userList) == 0:
return _("No user will be created")
elif self._use_password and not bool(self._user_data.password or self._user_data.isCrypted):
return _("You must set a password")
elif "wheel" in self.data.user.userList[0].groups:
return _("Administrator %s will be created") % self.data.user.userList[0].name
else:
return _("User %s will be created") % self.data.user.userList[0].name
def input(self, args, key):
if self._container.process_user_input(key):
self.apply()
return InputState.PROCESSED_AND_REDRAW
return super().input(args, key)
def apply(self):
if self._user_data.gecos and not self._user_data.name:
username = guess_username(self._user_data.gecos)
valid, msg = check_username(username)
if not valid:
self.errors.append(_("Invalid user name: %(name)s.\n%(error_message)s")
% {"name": username, "error_message": msg})
else:
self._user_data.name = guess_username(self._user_data.gecos)
self._user_data.groups = [g.strip() for g in self._groups.split(",") if g]
# Add or remove the user from wheel group
if self._is_admin and "wheel" not in self._user_data.groups:
self._user_data.groups.append("wheel")
elif not self._is_admin and "wheel" in self._user_data.groups:
self._user_data.groups.remove("wheel")
# Add or remove the user from userlist as needed
if self._create_user and (self._user_data not in self.data.user.userList and self._user_data.name):
self.data.user.userList.append(self._user_data)
elif (not self._create_user) and (self._user_data in self.data.user.userList):
self.data.user.userList.remove(self._user_data)
# encrypt and store password only if user entered anything; this should
# preserve passwords set via kickstart
if self._use_password and self._user_data.password and len(self._user_data.password) > 0:
self._user_data.password = self._user_data.password
self._user_data.isCrypted = True
# clear pw when user unselects to use pw
else:
self._user_data.password = ""
self._user_data.isCrypted = False
示例13: ConfigureNetworkSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
#.........这里部分代码省略.........
% {"auto": '"auto"', "dhcp": '"dhcp"', "ignore": '"ignore"'})
dialog = Dialog(title=msg, conditions=[self._check_ipv6_config])
self._container.add(EntryWidget(dialog.title, self.network_data.ipv6), self._set_ipv6, dialog)
dialog = Dialog(title=_("IPv6 default gateway"), conditions=[self._check_ipv6])
self._container.add(EntryWidget(dialog.title, self.network_data.ipv6gateway), self._set_ipv6_gateway, dialog)
dialog = Dialog(title=_("Nameservers (comma separated)"), conditions=[self._check_nameservers])
self._container.add(EntryWidget(dialog.title, self.network_data.nameserver), self._set_nameservers, dialog)
msg = _("Connect automatically after reboot")
w = CheckboxWidget(title=msg, completed=self.network_data.onboot)
self._container.add(w, self._set_onboot_handler)
msg = _("Apply configuration in installer")
w = CheckboxWidget(title=msg, completed=self.apply_configuration)
self._container.add(w, self._set_apply_handler)
self.window.add_with_separator(self._container)
message = _("Configuring device %s.") % self.network_data.device
self.window.add_with_separator(TextWidget(message))
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv4_or_dhcp(self, user_input, report_func):
return IPV4_OR_DHCP_PATTERN_WITH_ANCHORS.match(user_input) is not None
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv4(self, user_input, report_func):
return IPV4_PATTERN_WITH_ANCHORS.match(user_input) is not None
@report_if_failed(message=NETMASK_ERROR_MSG)
def _check_netmask(self, user_input, report_func):
return IPV4_NETMASK_WITH_ANCHORS.match(user_input) is not None
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv6(self, user_input, report_func):
return network.check_ip_address(user_input, version=6)
@report_if_failed(message=IP_ERROR_MSG)
def _check_ipv6_config(self, user_input, report_func):
if user_input in ["auto", "dhcp", "ignore"]:
return True
addr, _slash, prefix = user_input.partition("/")
if prefix:
try:
if not 1 <= int(prefix) <= 128:
return False
except ValueError:
return False
return network.check_ip_address(addr, version=6)
@report_if_failed(message=IP_ERROR_MSG)
def _check_nameservers(self, user_input, report_func):
if user_input.strip():
addresses = [str.strip(i) for i in user_input.split(",")]
for ip in addresses:
if not network.check_ip_address(ip):
return False
return True
def _set_ipv4_or_dhcp(self, dialog):
self.network_data.ip = dialog.run()
def _set_netmask(self, dialog):
self.network_data.netmask = dialog.run()
def _set_ipv4_gateway(self, dialog):
self.network_data.gateway = dialog.run()
def _set_ipv6(self, dialog):
self.network_data.ipv6 = dialog.run()
def _set_ipv6_gateway(self, dialog):
self.network_data.ipv6gateway = dialog.run()
def _set_nameservers(self, dialog):
self.network_data.nameserver = dialog.run()
def _set_apply_handler(self, args):
self.apply_configuration = not self.apply_configuration
def _set_onboot_handler(self, args):
self.network_data.onboot = not self.network_data.onboot
def input(self, args, key):
if self._container.process_user_input(key):
self.apply()
return InputState.PROCESSED_AND_REDRAW
else:
return super().input(args, key)
@property
def indirect(self):
return True
def apply(self):
""" Apply our changes. """
# save this back to network data, this will be applied in upper layer
pass
示例14: StorageSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
#.........这里部分代码省略.........
spoke, so add and return extra identifying information about them.
Since this is going to be ugly to do within the confines of the
CheckboxWidget, pre-format the display string right here.
"""
# show this info for all disks
format_str = "%s: %s (%s)" % (disk.model, disk.size, disk.name)
disk_attrs = []
# now check for/add info about special disks
if (isinstance(disk, MultipathDevice) or isinstance(disk, iScsiDiskDevice) or isinstance(disk, FcoeDiskDevice)):
if hasattr(disk, "wwid"):
disk_attrs.append(disk.wwid)
elif isinstance(disk, DASDDevice):
if hasattr(disk, "busid"):
disk_attrs.append(disk.busid)
elif isinstance(disk, ZFCPDiskDevice):
if hasattr(disk, "fcp_lun"):
disk_attrs.append(disk.fcp_lun)
if hasattr(disk, "wwpn"):
disk_attrs.append(disk.wwpn)
if hasattr(disk, "hba_id"):
disk_attrs.append(disk.hba_id)
# now append all additional attributes to our string
for attr in disk_attrs:
format_str += ", %s" % attr
return format_str
def input(self, args, key):
"""Grab the disk choice and update things"""
self.errors = []
if self._container.process_user_input(key):
self.redraw()
return InputState.PROCESSED
else:
# TRANSLATORS: 'c' to continue
if key.lower() == C_('TUI|Spoke Navigation', 'c'):
if self.selected_disks:
# check selected disks to see if we have any unformatted DASDs
# if we're on s390x, since they need to be formatted before we
# can use them.
if arch.is_s390():
_disks = [d for d in self.disks if d.name in self.selected_disks]
to_format = [d for d in _disks if d.type == "dasd" and
blockdev.s390.dasd_needs_format(d.busid)]
if to_format:
self.run_dasdfmt(to_format)
self.redraw()
return InputState.PROCESSED
# make sure no containers were split up by the user's disk
# selection
self.errors.extend(checkDiskSelection(self.storage,
self.selected_disks))
if self.errors:
# The disk selection has to make sense before we can
# proceed.
self.redraw()
return InputState.PROCESSED
new_spoke = AutoPartSpoke(self.data, self.storage,
self.payload, self.instclass)
ScreenHandler.push_screen_modal(new_spoke)
self.apply()
示例15: AskVNCSpoke
# 需要导入模块: from simpleline.render.containers import ListColumnContainer [as 别名]
# 或者: from simpleline.render.containers.ListColumnContainer import process_user_input [as 别名]
class AskVNCSpoke(NormalTUISpoke):
"""
.. inheritance-diagram:: AskVNCSpoke
:parts: 3
"""
title = N_("VNC")
# This spoke is kinda standalone, not meant to be used with a hub
# We pass in some fake data just to make our parents happy
def __init__(self, data, storage=None, payload=None, instclass=None, message=""):
super().__init__(data, storage, payload, instclass)
self.input_required = True
self.initialize_start()
self._container = None
# The TUI hasn't been initialized with the message handlers yet. Add an
# exception message handler so that the TUI exits if anything goes wrong
# at this stage.
loop = App.get_event_loop()
loop.register_signal_handler(ExceptionSignal, exception_msg_handler_and_exit)
self._message = message
self._usevnc = False
self.initialize_done()
@property
def indirect(self):
return True
def refresh(self, args=None):
super().refresh(args)
self.window.add_with_separator(TextWidget(self._message))
self._container = ListColumnContainer(1, spacing=1)
# choices are
# USE VNC
self._container.add(TextWidget(_(USEVNC)), self._use_vnc_callback)
# USE TEXT
self._container.add(TextWidget(_(USETEXT)), self._use_text_callback)
self.window.add_with_separator(self._container)
def _use_vnc_callback(self, data):
self._usevnc = True
new_spoke = VNCPassSpoke(self.data, self.storage,
self.payload, self.instclass)
ScreenHandler.push_screen_modal(new_spoke)
def _use_text_callback(self, data):
self._usevnc = False
def input(self, args, key):
"""Override input so that we can launch the VNC password spoke"""
if self._container.process_user_input(key):
self.apply()
return InputState.PROCESSED_AND_CLOSE
else:
# TRANSLATORS: 'q' to quit
if key.lower() == C_('TUI|Spoke Navigation', 'q'):
d = YesNoDialog(_(u"Do you really want to quit?"))
ScreenHandler.push_screen_modal(d)
if d.answer:
ipmi_abort(scripts=self.data.scripts)
if conf.system.can_reboot:
execWithRedirect("systemctl", ["--no-wall", "reboot"])
else:
sys.exit(1)
else:
return super().input(args, key)
def apply(self):
self.data.vnc.enabled = self._usevnc