本文整理汇总了Python中pyanaconda.i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize
def initialize(self, actions):
for (i, action) in enumerate(actions, start=1):
mountpoint = ""
if action.type in [ACTION_TYPE_DESTROY, ACTION_TYPE_RESIZE]:
typeString = """<span foreground='red'>%s</span>""" % \
escape_markup(action.type_desc.title())
else:
typeString = """<span foreground='green'>%s</span>""" % \
escape_markup(action.type_desc.title())
if action.obj == ACTION_OBJECT_FORMAT:
mountpoint = getattr(action.device.format, "mountpoint", "")
if hasattr(action.device, "description"):
desc = _("%(description)s (%(deviceName)s)") % {"deviceName": action.device.name,
"description": action.device.description}
serial = action.device.serial
elif hasattr(action.device, "disk"):
desc = _("%(deviceName)s on %(container)s") % {"deviceName": action.device.name,
"container": action.device.disk.description}
serial = action.device.disk.serial
else:
desc = action.device.name
serial = action.device.serial
self._store.append([i,
typeString,
action.object_type_string,
desc,
mountpoint,
serial])
示例2: status
def status(self):
if len(self.data.user.userList) == 0:
return _("No user will be created")
elif self._wheel.name 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
示例3: refresh
def refresh(self, args=None):
NormalTUISpoke.refresh(self, args)
# Join the initialization thread to block on it
# This print is foul. Need a better message display
print(_(PAYLOAD_STATUS_PROBING_STORAGE))
threadMgr.wait(THREAD_STORAGE_WATCHER)
# synchronize our local data store with the global ksdata
# Commment out because there is no way to select a disk right
# now without putting it in ksdata. Seems wrong?
#self.selected_disks = self.data.ignoredisk.onlyuse[:]
self.autopart = self.data.autopart.autopart
message = self._update_summary()
# loop through the disks and present them.
for disk in self.disks:
disk_info = self._format_disk_info(disk)
c = CheckboxWidget(title="%i) %s" % (self.disks.index(disk) + 1, disk_info),
completed=(disk.name in self.selected_disks))
self._window += [c, ""]
# if we have more than one disk, present an option to just
# select all disks
if len(self.disks) > 1:
c = CheckboxWidget(title="%i) %s" % (len(self.disks) + 1, _("Select all")),
completed=(self.selection == len(self.disks)))
self._window += [c, ""]
self._window += [TextWidget(message), ""]
return True
示例4: check_password_empty
def check_password_empty(self, inputcheck):
"""Check whether a password has been specified at all.
This check is used for both the password and the confirmation.
"""
# If the password was set by kickstart, skip the strength check
# pylint: disable=no-member
if self.input_kickstarted and not self.policy.changesok:
return InputCheck.CHECK_OK
# Skip the check if no password is required
if (not self.input_enabled) or self.input_kickstarted:
return InputCheck.CHECK_OK
# Also skip the check if the policy says that an empty password is fine
# pylint: disable=no-member
elif self.policy.emptyok:
return InputCheck.CHECK_OK
elif not self.get_input(inputcheck.input_obj):
# pylint: disable=no-member
if self.policy.strict:
return _(constants.PASSWORD_EMPTY_ERROR)
else:
if self.waive_clicks > 1:
return InputCheck.CHECK_OK
else:
return "%s %s" % (_(constants.PASSWORD_EMPTY_ERROR), _(constants.PASSWORD_DONE_TWICE))
else:
return InputCheck.CHECK_OK
示例5: _activated_device_msg
def _activated_device_msg(self, devname):
msg = _("Wired (%(interface_name)s) connected\n") \
% {"interface_name": devname}
ipv4config = nm.nm_device_ip_config(devname, version=4)
ipv6config = nm.nm_device_ip_config(devname, version=6)
if ipv4config and ipv4config[0]:
addr_str, prefix, gateway_str = ipv4config[0][0]
netmask_str = network.prefix2netmask(prefix)
dnss_str = ",".join(ipv4config[1])
else:
addr_str = dnss_str = gateway_str = netmask_str = ""
msg += _(" IPv4 Address: %(addr)s Netmask: %(netmask)s Gateway: %(gateway)s\n") % \
{"addr": addr_str, "netmask": netmask_str, "gateway": gateway_str}
msg += _(" DNS: %s\n") % dnss_str
if ipv6config and ipv6config[0]:
for ipv6addr in ipv6config[0]:
addr_str, prefix, gateway_str = ipv6addr
# Do not display link-local addresses
if not addr_str.startswith("fe80:"):
msg += _(" IPv6 Address: %(addr)s/%(prefix)d\n") % \
{"addr": addr_str, "prefix": prefix}
dnss_str = ",".join(ipv6config[1])
return msg
示例6: _update_summary
def _update_summary(self):
""" Update the summary based on the UI. """
count = 0
capacity = 0
free = Size(bytes=0)
# pass in our disk list so hidden disks' free space is available
free_space = self.storage.getFreeSpace(disks=self.disks)
selected = [d for d in self.disks if d.name in self.selected_disks]
for disk in selected:
capacity += disk.size
free += free_space[disk.name][0]
count += 1
summary = (P_("%d disk selected; %s capacity; %s free",
"%d disks selected; %s capacity; %s free",
count) % (count, str(Size(spec="%s MB" % capacity)), free))
summary_label = self.builder.get_object("summary_label")
summary_label.set_text(summary)
summary_label.set_sensitive(count > 0)
summary_button = self.builder.get_object("summary_button")
summary_button.set_visible(count > 0)
if len(self.disks) == 0:
self.set_warning(_("No disks detected. Please shut down the computer, connect at least one disk, and restart to complete installation."))
elif count == 0:
self.set_warning(_("No disks selected; please select at least one disk to install to."))
else:
self.clear_info()
示例7: connectToView
def connectToView(self):
"""Attempt to connect to self.vncconnecthost"""
maxTries = 10
self.log.info(_("Attempting to connect to vnc client on host %s..."), self.vncconnecthost)
if self.vncconnectport != "":
hostarg = self.vncconnecthost + ":" + self.vncconnectport
else:
hostarg = self.vncconnecthost
vncconfigcommand = [self.root+"/usr/bin/vncconfig", "-display", ":%s" % constants.X_DISPLAY_NUMBER, "-connect", hostarg]
for _i in range(maxTries):
vncconfp = iutil.startProgram(vncconfigcommand, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # vncconfig process
err = vncconfp.communicate()[1].decode("utf-8")
if err == '':
self.log.info(_("Connected!"))
return True
elif err.startswith("connecting") and err.endswith("failed\n"):
self.log.info(_("Will try to connect again in 15 seconds..."))
time.sleep(15)
continue
else:
log.critical(err)
iutil.ipmi_abort(scripts=self.anaconda.ksdata.scripts)
sys.exit(1)
self.log.error(P_("Giving up attempting to connect after %d try!\n",
"Giving up attempting to connect after %d tries!\n",
maxTries), maxTries)
return False
示例8: verify_partition_format_sizes
def verify_partition_format_sizes(storage, constraints, report_error, report_warning):
""" Verify that the size of the device is allowed by the format used.
:param storage: a storage to check
:param constraints: a dictionary of constraints
:param report_error: a function for error reporting
:param report_warning: a function for warning reporting
"""
# storage.mountpoints is a property that returns a new dict each time, so
# iterating over it is thread-safe.
filesystems = storage.mountpoints
for (mount, device) in filesystems.items():
problem = filesystems[mount].check_size()
if problem < 0:
report_error(_("Your %(mount)s partition is too small for "
"%(format)s formatting (allowable size is "
"%(minSize)s to %(maxSize)s)")
% {"mount": mount, "format": device.format.name,
"minSize": device.min_size, "maxSize": device.max_size})
elif problem > 0:
report_error(_("Your %(mount)s partition is too large for "
"%(format)s formatting (allowable size is "
"%(minSize)s to %(maxSize)s)")
% {"mount": mount, "format": device.format.name,
"minSize": device.min_size, "maxSize": device.max_size})
示例9: prompt
def prompt(self, args=None):
""" Customize default prompt. """
prompt = NormalTUISpoke.prompt(self, args)
prompt.set_message(_("Please select language support to install"))
# TRANSLATORS: 'b' to go back
prompt.add_option(C_("TUI|Spoke Navigation|Language Support", "b"), _("to return to language list"))
return prompt
示例10: input
def input(self, args, key):
"""Override input so that we can launch the VNC password spoke"""
try:
keyid = int(key) - 1
if 0 <= keyid < len(self._choices):
choice = self._choices[keyid]
if choice == _(USETEXT):
self._usevnc = False
else:
self._usevnc = True
newspoke = VNCPassSpoke(self.app, self.data, self.storage,
self.payload, self.instclass)
self.app.switch_screen_modal(newspoke)
self.apply()
self.close()
return INPUT_PROCESSED
except ValueError:
pass
# TRANSLATORS: 'q' to quit
if key.lower() == C_('TUI|Spoke Navigation', 'q'):
d = YesNoDialog(self.app, _(self.app.quit_message))
self.app.switch_screen_modal(d)
if d.answer:
iutil.ipmi_report(IPMI_ABORTED)
if can_touch_runtime_system("Quit and Reboot"):
execWithRedirect("systemctl", ["--no-wall", "reboot"])
else:
exit(1)
else:
return key
示例11: verify_root
def verify_root(storage, constraints, report_error, report_warning):
""" Verify the root.
:param storage: a storage to check
:param constraints: a dictionary of constraints
:param report_error: a function for error reporting
:param report_warning: a function for warning reporting
"""
root = storage.fsset.root_device
if root:
if root.size < constraints[STORAGE_MIN_ROOT]:
report_warning(_("Your root partition is less than %(size)s "
"which is usually too small to install "
"%(product)s.")
% {'size': constraints[STORAGE_MIN_ROOT],
'product': productName})
else:
report_error(_("You have not defined a root partition (/), "
"which is required for installation of %s"
" to continue.") % (productName,))
if storage.root_device and storage.root_device.format.exists:
e = storage.must_format(storage.root_device)
if e:
report_error(e)
示例12: _update_action_buttons
def _update_action_buttons(self, row):
obj = PartStoreRow(*row)
device = self.storage.devicetree.get_device_by_id(obj.id)
# Disks themselves may be editable in certain ways, but they are never
# shrinkable.
self._preserveButton.set_sensitive(obj.editable)
self._shrinkButton.set_sensitive(obj.editable and not device.is_disk)
self._deleteButton.set_sensitive(obj.editable)
self._resizeSlider.set_visible(False)
if not obj.editable:
return
# If the selected filesystem does not support shrinking, make that
# button insensitive.
self._shrinkButton.set_sensitive(device.resizable)
if device.resizable:
self._setup_slider(device, Size(obj.target))
# Then, disable the button for whatever action is currently selected.
# It doesn't make a lot of sense to allow clicking that.
if obj.action == _(PRESERVE):
self._preserveButton.set_sensitive(False)
elif obj.action == _(SHRINK):
self._shrinkButton.set_sensitive(False)
self._resizeSlider.set_visible(True)
elif obj.action == _(DELETE):
self._deleteButton.set_sensitive(False)
示例13: validate_mountpoint
def validate_mountpoint(mountpoint, used_mountpoints, strict=True):
if strict:
fake_mountpoints = []
else:
fake_mountpoints = ["swap", "biosboot", "prepboot"]
if mountpoint in used_mountpoints:
return _("That mount point is already in use. Try something else?")
elif not mountpoint:
return _("Please enter a valid mount point.")
elif mountpoint in system_mountpoints:
return _("That mount point is invalid. Try something else?")
elif (lowerASCII(mountpoint) not in fake_mountpoints and
((len(mountpoint) > 1 and mountpoint.endswith("/")) or
not mountpoint.startswith("/") or
" " in mountpoint or
re.search(r'/\.*/', mountpoint) or
re.search(r'/\.+$', mountpoint))):
# - does not end with '/' unless mountpoint _is_ '/'
# - starts with '/' except for "swap", &c
# - does not contain spaces
# - does not contain pairs of '/' enclosing zero or more '.'
# - does not end with '/' followed by one or more '.'
return _("That mount point is invalid. Try something else?")
else:
return ""
示例14: _doExecute
def _doExecute(self):
self._ready = False
hubQ.send_not_ready(self.__class__.__name__)
# on the off-chance dasdfmt is running, we can't proceed further
threadMgr.wait(constants.THREAD_DASDFMT)
hubQ.send_message(self.__class__.__name__, _("Saving storage configuration..."))
try:
doKickstartStorage(self.storage, self.data, self.instclass)
except (StorageError, KickstartValueError) as e:
log.error("storage configuration failed: %s", e)
StorageChecker.errors = str(e).split("\n")
hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration..."))
self.data.bootloader.bootDrive = ""
self.data.ignoredisk.drives = []
self.data.ignoredisk.onlyuse = []
self.storage.config.update(self.data)
self.storage.reset()
self.disks = getDisks(self.storage.devicetree)
# now set ksdata back to the user's specified config
applyDiskSelection(self.storage, self.data, self.selected_disks)
except BootLoaderError as e:
log.error("BootLoader setup failed: %s", e)
StorageChecker.errors = str(e).split("\n")
hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration..."))
self.data.bootloader.bootDrive = ""
else:
if self.autopart:
self.run()
finally:
resetCustomStorageData(self.data)
self._ready = True
hubQ.send_ready(self.__class__.__name__, True)
示例15: refresh
def refresh(self, required_space, auto_swap, disk_free, fs_free, autoPartType, encrypted):
self.autoPartType = autoPartType
self.autoPartTypeCombo = self.builder.get_object("options2_combo")
self.autoPartTypeCombo.set_active(self.autoPartType)
self.encrypted = encrypted
self.encryptCheckbutton = self.builder.get_object("encryption2_checkbutton")
self.encryptCheckbutton.set_active(self.encrypted)
sw_text = self._get_sw_needs_text(required_space, auto_swap)
label_text = _("%s The disks you've selected have the following "
"amounts of free space:") % sw_text
label = self.builder.get_object("options2_label1")
label.set_markup(label_text)
label.set_tooltip_text(_("Please wait... software metadata still loading."))
label.connect("activate-link", self._modify_sw_link_clicked)
self.disk_free_label = self.builder.get_object("options2_disk_free_label")
self.fs_free_label = self.builder.get_object("options2_fs_free_label")
self._set_free_space_labels(disk_free, fs_free)
label_text = _("<b>You don't have enough space available to install "
"%s</b>. You can shrink or remove existing partitions "
"via our guided reclaim space tool, or you can adjust your "
"partitions on your own in the custom partitioning "
"interface.") % productName
self.builder.get_object("options2_label2").set_markup(label_text)
self._add_modify_watcher("options2_label1")