本文整理汇总了Python中ufwi_rpcd.common.tr函数的典型用法代码示例。如果您正苦于以下问题:Python tr函数的具体用法?Python tr怎么用?Python tr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, rules):
Menu.__init__(self)
window = rules.window
self.debug = window.debug
self.create_before = self.add(":/icons/add.png",
tr("Create before"), self.createAclBefore)
self.create_after = self.add(":/icons/add.png",
tr("Create after"), self.createAclAfter)
self.edit = self.add(":/icons/edit.png",
tr("Edit"), self.editAcl)
self.up = self.add(":/icons/up.png",
tr("Move up"), self.moveUp)
if window.compatibility.has_move_rule:
self.move_at = self.add(":/icons/updown.png",
tr("Move to line..."), self.moveAt)
else:
self.move_at = None
self.down = self.add(":/icons/down.png",
tr("Move down"), self.moveDown)
self.clone = self.add(":/icons/copy.png",
tr("Clone"), self.cloneAcl)
self.delete = self.add(":/icons/delete.png",
tr("Delete"), self.deleteAcl)
self.iptables = self.add(":/icons/apply_rules.png",
tr("Iptables rules"), self.iptablesRules)
self.ldap = self.add(":/icons/apply_rules.png",
tr("LDAP rules"), self.ldapRules)
self.rules = rules
self.rule_id = None
self.identifiers = None
示例2: test_ldap
def test_ldap(self):
dc, base, uri, filter, password = self.specific_config.generateTest()
if uri is None or uri == '':
QMessageBox.critical(
self,
"Missing data",
"Please fill URI field"
)
return
if dc is None:
dc == ''
filter, ok = QInputDialog.getText(
self,
tr("LDAP Filter"),
tr("Please enter a filter:"),
QLineEdit.Normal,
filter
)
if not ok:
return
async = self.mainwindow.client.async()
async.call(
'nuauth',
'testLDAP',
dc, base, uri, unicode(filter), password,
callback = self.success_test,
errback = self.error_test
)
示例3: _setethernetspeed
def _setethernetspeed(self, ethernet):
if ethernet.eth_auto:
cmd = "/usr/sbin/ethtool -s %s autoneg on" % ethernet.system_name
self.responsible.feedback(
tr("Setting up speed for interface %(DESCRIPTION)s: auto"),
DESCRIPTION=ethernet.fullName()
)
else:
args = {
'name': ethernet.system_name,
'duplex': "full" if ethernet.eth_duplex == Ethernet.FULL else "half",
'speed': ethernet.eth_speed
}
cmd = "/usr/sbin/ethtool -s %(name)s autoneg off speed "\
"%(speed)s duplex %(duplex)s" % args
self.responsible.feedback(
tr(
"Setting up speed for interface %(DESCRIPTION)s: "
"speed: %(SPEED)s, duplex: %(DUPLEX)s."),
DESCRIPTION=ethernet.fullName(),
SPEED=args['speed'],
DUPLEX=args['duplex']
)
process = createProcess(self, cmd.split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env={})
retcode, stdout, stderr = communicateProcess(self, process, 30)
if retcode == 0:
return
else:
self.responsible.feedback("Could not set speed.")
#Explicitely catched
raise EthernetSpeedError("Error while running [%s]." % cmd)
示例4: printServerTime
def printServerTime(self, time):
server_time = unicode(datetime.fromtimestamp(float(time)))
server_time = unicode(htmlBold(server_time))
html = tr("Server time: %s") % server_time
html = Html(html, escape=False)
self.addToInfoArea(html)
QMessageBox.information(self, tr("Server time"), tr("Server time: %s") % server_time)
示例5: _update_gui
def _update_gui(self):
if self.last_updated == ADStatus.UNKNOWN:
self.status_text.setText(ADStatus.UNKNOWN)
for widget in (
self.status_icon,
self.additional_info,
):
widget.hide()
return
if not self.status:
self.status_icon.show()
self.additional_info.hide()
self.status_icon.setPixmap(ADStatus.NOT_MEMBER_PIXMAP)
self.status_text.setText(ADStatus.NOT_MEMBER)
for widget in (
self.status_icon,
self.additional_info,
):
widget.show()
self.status_text.setText(
tr("AD information:")
)
info = (
tr("Domain name: %s") % self.realm,
tr("Parent server name: %s") % self.parent_server,
tr("Last updated: %s") % self.last_updated,
tr("EdenWall/Active Directory time delta: %s second(s)")
% self.time_offset,
)
self.additional_info.setText("\n".join(info))
示例6: isValid
def isValid(self):
self.message.setNoMessage()
self.error_message = ''
hasInvalidData = False
for widget in [self.dns1, self.dns2]:
if not widget.isValid():
hasInvalidData = True
error = "'%s' : must be '%s'<br />" % (widget.text(), widget.getFieldInfo())
self.error_message += error
self.message.setMessage('', "<ul>%s" % error, status=MessageArea.WARNING)
confs = {
tr("hostname"): self.qhostnamecfg.cfg,
tr("DNS"): self.qresolvcfg.cfg
}
for name, item in confs.iteritems():
if not item.isValid():
hasInvalidData = True
error = tr("%s configuration is invalid<br />") % name
self.message.setMessage('', error, status=MessageArea.WARNING)
self.error_message += error
if not hasInvalidData:
error = self.qresolvcfg.resolvcfg.isInvalid()
if error:
hasInvalidData = True
self.error_message = error
self.message.setMessage('', error, status=MessageArea.WARNING)
if hasInvalidData:
self.mainwindow.addToInfoArea(tr("'Hostname and DNS : invalid configuration'"))
return False
else:
return True
示例7: check_join
def check_join(logger, responsible):
"""
'net ads testjoin' should be sufficient in most cases.
'net rpc testjoin' is a fallback to 'net ads testjoin'
"""
responsible.feedback(tr("Checking that the group mappings exist."))
if not exists("/var/lib/samba/winbindd_idmap.tdb"):
raise NuauthException(NO_MAPPING_EXISTS, "The group mappings don't exist")
try:
cmd = ('/usr/bin/net', 'ads', 'testjoin')
runCommandAndCheck(logger, cmd)
except RunCommandError:
pass # another test
else:
responsible.feedback(tr("The junction to the Active Directory domain is functional"))
return # ok
try:
cmd = ('/usr/bin/net', 'rpc', 'testjoin')
runCommandAndCheck(logger, cmd)
except RunCommandError:
if responsible is not None:
responsible.feedback(
tr("No junction to an Active Directory domain.")
)
raise NuauthException(NUAUTH_INVALID_CONF,
"Domain not available")
responsible.feedback(tr("The junction to the Active Directory domain is functional"))
示例8: accept_suppression
def accept_suppression(dhcprange, parent_widget):
"""
The net we refer to is not available anymore, do we want this or not
Let the user choose.
"""
deletable_tr = tr("Consequence: the following DHCP range will be deleted:")
deletable_html = u"<ul>"
deletable_html += "<li>%s %s: %s > %s</li>" % (
deletable_tr,
unicode(dhcprange.net),
unicode(dhcprange.start),
unicode(dhcprange.end)
)
deletable_html += u"</ul>"
title = tr("DHCP configuration")
message_box = QMessageBox(parent_widget)
message_box.setWindowTitle(title)
message_box.setText(_GENERIC_TEXT)
message_box.setInformativeText(deletable_html)
message_box.setStandardButtons(
QMessageBox.Yes | QMessageBox.Cancel
)
clicked_button = message_box.exec_()
if clicked_button == QMessageBox.Yes:
return True, _DELETE_RANGE
return False
示例9: setupWindow
def setupWindow(self):
self.setButtons()
self.setContainer(self.list)
self.setMenu(UserGroupMenu(self,
tr("New user group"),
tr("Edit this user group"),
tr("Delete this user group")))
示例10: build
def build(self, description):
self.layout().addWidget(self.list)
cancel = QPushButton(QIcon(":/icons/wrong.png"), tr("Cancel"), self)
save = QPushButton(QIcon(":/icons/apply.png"), tr("OK"), self)
save.setDefault(True)
self.connect(cancel, SIGNAL("clicked()"), self.doClose)
self.connect(save, SIGNAL("clicked()"), self.doSave)
self.grid = QWidget(self)
self.setMinimumWidth(700)
QGridLayout(self.grid)
self.grid.layout().addWidget(save, 0, 0, Qt.AlignHCenter)
self.grid.layout().addWidget(cancel, 0, 1, Qt.AlignHCenter)
self.layout().addWidget(self.grid)
self.info.setReadOnly(True)
if description:
self.info.append(description)
else:
self.info.setVisible(False)
self.error.setReadOnly(True)
self.error.setVisible(False)
self.grid.layout().addWidget(self.info, 1, 0, 1, 0, Qt.AlignHCenter)
self.grid.layout().addWidget(self.error, 2, 0, 1, 0, Qt.AlignHCenter)
示例11: buildInterface
def buildInterface(self):
frame = QFrame()
layout = QVBoxLayout(frame)
self.setWidget(frame)
self.setWidgetResizable(True)
title = u'<h1>%s</h1>' % self.tr('EdenWall activation keys')
layout.addWidget(QLabel(title))
sn = "<strong>%s</strong>" % self.ID
self.IDLabel = QLabel(tr('This appliance serial number is %s.') % sn)
self.IDLabel.setTextInteractionFlags(
Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse)
sendLicenseButton = NuConfPageKit.createButton(
tr('Upload an activation key'), frame, self.mainwindow,
self.chooseAndSendFile, QIcon(":/icons/up"))
self.mainwindow.writeAccessNeeded(sendLicenseButton)
self.table = QTableWidget(0, 4, frame)
self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.table.setSelectionMode(QAbstractItemView.NoSelection)
self.table.horizontalHeader().setStretchLastSection(True)
self.table.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
self.table.setHorizontalHeaderLabels([
unicode(translate('MainWindow', 'Activation key owner')),
unicode(translate('MainWindow', 'Valid until')),
unicode(translate('MainWindow', 'Days left')),
unicode(translate('MainWindow', 'Type'))])
for widget in (self.IDLabel, sendLicenseButton, self.table):
layout.addWidget(widget)
layout.addStretch(100)
示例12: createInformation
def createInformation(self):
window = self.library.window
networks = window.object_libraries["resources"]
protocols = window.object_libraries["protocols"]
title = tr("Platform")
items = []
for item in self["items"]:
network = item["network"]
network = networks[network]
protocol = item["protocol"]
protocol = protocols[protocol]
html = "(%s, %s)" % (
network.createHTML(tooltip=True, icon=False),
protocol.createHTML(tooltip=True, icon=False),
)
html = Html(html, escape=False)
items.append(html)
items = BR.join(items)
interface = networks[self["interface"]]
options = [
(tr("Identifier"), self["id"]),
(tr("Interface"), interface.createHTML(tooltip=True)),
(tr("Items"), items),
(tr("References"), self.createReferencesHTML()),
]
return (title, options)
示例13: sort_label
def sort_label(self):
""" With my args, get a label to say on what field my list is ordered. """
if not self.args.has_key('sortby') or not arg_types.has_key(self.args['sortby']):
return tr('No sorting')
return tr(u'Sorted by %s') % (arg_types[self.args['sortby']].label)
示例14: release
def release(self, context, key):
self.thread_lock.acquire()
try:
key = self.cleanKey(key)
# Get the lock
if key in self.permanent_locks:
lock = self.permanent_locks[key]
else:
raise LockError(tr('The "%s" lock is not acquired!'), key)
# PersistentLock owned by another user?
if isinstance(lock, PersistentLock):
session = context.getSession()
lock_session = lock.getSession()
if lock_session != session:
raise LockError(
tr('The "%s" lock, owned by %s, can not be released!'),
key, unicode(lock_session.user))
elif isinstance(lock, ComponentLock):
if lock.getComponentName() != context.component.name:
raise LockError(
tr('The "%s" lock, owned by the %s component, can not be released!'),
key, unicode(lock.getComponentName()))
# Delete the lock
self.destroyLock(key)
finally:
self.thread_lock.release()
示例15: _edit_hostname
def _edit_hostname(self):
changeable = self.qhostnamecfg.hostnamecfg.changeable
if not self._can_edit_hostname:
QMessageBox.critical(
self,
_CANNOT_CHANGE_HOSTNAME_TITLE,
_CANNOT_CHANGE_HOSTNAME,
)
return
if changeable == CHANGE_DISCOURAGED:
if not self._continue_edit(
tr("About hostname change", "popup title"),
_HOSTNAME_CHANGE_DISCLAIMER
):
return
hostname, ok = self.__editFieldDialog(
tr("Edit hostname"),
tr("Enter new hostname"),
self.qhostnamecfg.hostnamecfg.hostname
)
if ok:
hostname = unicode(hostname).strip()
if hostname == self.qhostnamecfg.hostnamecfg.hostname:
return
self.qhostnamecfg.pre_modify()
self.qhostnamecfg.hostnamecfg.hostname = hostname
self.qhostnamecfg.post_modify()
self.setModified()