本文整理汇总了Python中ubiquity.misc.get_release函数的典型用法代码示例。如果您正苦于以下问题:Python get_release函数的具体用法?Python get_release怎么用?Python get_release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_release函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_language_selection_changed
def on_language_selection_changed(self):
lang = self.selected_language()
if not lang:
return
# strip encoding; we use UTF-8 internally no matter what
lang = lang.split('.')[0]
self.controller.translate(lang)
if not self.only:
release = misc.get_release()
install_medium = misc.get_install_medium()
install_medium = i18n.get_string(install_medium, lang)
for widget in (self.page.try_install_text_label,
self.page.try_ubuntu,
self.page.install_ubuntu,
self.page.alpha_warning_label):
text = widget.text()
text = text.replace('${RELEASE}', release.name)
text = text.replace('${MEDIUM}', install_medium)
text = text.replace('Ubuntu', 'Kubuntu')
widget.setText(text)
self.update_release_notes_label()
for w in self.widgetHidden:
w.show()
self.widgetHidden = []
示例2: changed
def changed(self, entry):
from gi.repository import Gtk, GObject, GLib, Soup
text = misc.utf8(self.city_entry.get_text())
if not text:
return
# TODO if the completion widget has a selection, return? How do we
# determine this?
if text in self.geoname_cache:
model = self.geoname_cache[text]
self.city_entry.get_completion().set_model(model)
else:
model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING,
GObject.TYPE_STRING, GObject.TYPE_STRING,
GObject.TYPE_STRING)
if self.geoname_session is None:
self.geoname_session = Soup.SessionAsync()
url = _geoname_url % (quote(text), misc.get_release().version)
message = Soup.Message.new('GET', url)
message.request_headers.append('User-agent', 'Ubiquity/1.0')
self.geoname_session.abort()
if self.geoname_timeout_id is not None:
GLib.source_remove(self.geoname_timeout_id)
self.geoname_timeout_id = \
GLib.timeout_add_seconds(2, self.geoname_timeout,
(text, model))
self.geoname_session.queue_message(message, self.geoname_cb,
(text, model))
示例3: plugin_translate
def plugin_translate(self, lang):
PreparePageBase.plugin_translate(self, lang)
release = misc.get_release()
from gi.repository import Gtk
for widget in [self.prepare_foss_disclaimer]:
text = i18n.get_string(Gtk.Buildable.get_name(widget), lang)
text = text.replace('${RELEASE}', release.name)
widget.set_label(text)
示例4: test_get_release
def test_get_release(self, mock_open):
magic = mock.MagicMock(spec=io.TextIOBase)
magic.__enter__.return_value = magic
mock_open.return_value = magic
magic.readline.return_value = _disk_info
release = misc.get_release()
self.assertEqual(release.name, 'Ubuntu Server')
self.assertEqual(release.version, '10.04.1 LTS')
示例5: plugin_translate
def plugin_translate(self, lang):
PreparePageBase.plugin_translate(self, lang)
release = misc.get_release()
from gi.repository import Gtk
for widget in [self.prepare_download_updates,
self.label_required_space,
self.label_free_space]:
text = i18n.get_string(Gtk.Buildable.get_name(widget), lang)
text = text.replace('${RELEASE}', release.name)
widget.set_label(text)
示例6: plugin_translate
def plugin_translate(self, lang):
PreparePageBase.plugin_translate(self, lang)
#gtk does the ${RELEASE} replace for the title in gtk_ui but we do it per plugin because our title widget is per plugin
#also add Bold here (not sure how the gtk side keeps that formatting)
release = misc.get_release()
for widget in (self.page.prepare_heading_label, self.page.prepare_best_results, self.page.prepare_foss_disclaimer):
text = widget.text()
text = text.replace('${RELEASE}', release.name)
text = text.replace('Ubuntu', 'Kubuntu')
text = "<b>" + text + "</b>"
widget.setText(text)
示例7: plugin_translate
def plugin_translate(self, lang):
PreparePageBase.plugin_translate(self, lang)
# gtk does the ${RELEASE} replace for the title in gtk_ui but we do
# it per plugin because our title widget is per plugin
release = misc.get_release()
widgets = (
self.page.prepare_heading_label,
self.page.prepare_best_results,
self.page.prepare_foss_disclaimer,
)
for widget in widgets:
text = widget.text()
text = text.replace('${RELEASE}', release.name)
text = text.replace('Ubuntu', 'Linux Mint')
widget.setText(text)
示例8: changed
def changed(entry):
text = entry.get_text()
if not text:
return
# TODO if the completion widget has a selection, return? How do we determine this?
if text in changed.cache:
model = changed.cache[text]
else:
# fetch
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING)
changed.cache[text] = model
# TODO benchmark this
results = [(name, self.tzdb.get_loc(city))
for (name, city) in
[(x[0], x[1]) for x in self.zones
if x[0].lower().split('(', 1)[-1] \
.startswith(text.lower())]]
for result in results:
# We use name rather than loc.human_zone for i18n.
# TODO this looks pretty awful for US results:
# United States (New York) (United States)
# Might want to match the debconf format.
name, loc = result
model.append([name, '', loc.human_country,
loc.latitude, loc.longitude])
try:
import urllib2, urllib, json
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Ubiquity/1.0')]
url = opener.open(_geoname_url %
(urllib.quote(text), misc.get_release().version))
for result in json.loads(url.read()):
model.append([result['name'],
result['admin1'],
result['country'],
result['latitude'],
result['longitude']])
except Exception, e:
print 'exception:', e
示例9: setupChoices
def setupChoices(self, choices, extra_options, resize_choice,
manual_choice, biggest_free_choice, use_device_choice,
lvm_choice, crypto_choice):
self._clearInfo()
self.resizeChoice = resize_choice
self.manualChoice = manual_choice
self.useDeviceChoice = use_device_choice
self.extra_options = extra_options
self.lvm_choice = lvm_choice
self.crypto_choice = crypto_choice
# remove any previous autopartition selections
for child in self.autopart_selection_frame.children():
if isinstance(child, QtGui.QWidget):
child.setParent(None)
del child
for child in self.barsFrame.children():
if isinstance(child, QtGui.QWidget):
self.barsFrame.layout().removeWidget(child)
child.setParent(None)
del child
release_name = misc.get_release().name
bId = 0
if 'resize' in extra_options:
button = QtGui.QRadioButton(
self.resizeChoice, self.autopart_selection_frame)
self.autopart_selection_frame.layout().addWidget(button)
self.autopartition_buttongroup.addButton(button, bId)
self.autopartitionTexts.append(resize_choice)
button.clicked.connect(self.controller.setNextButtonTextInstallNow)
bId += 1
disks = []
for disk_id in extra_options['resize']:
# information about what can be resized
unused, min_size, max_size, pref_size, \
resize_path, unused, unused = \
extra_options['resize'][disk_id]
for text, path in extra_options['use_device'][1].items():
path = path[0]
if path.rsplit('/', 1)[1] == disk_id:
bar_frame = QtGui.QFrame()
bar_frame.setLayout(QtGui.QVBoxLayout())
bar_frame.setVisible(False)
bar_frame.layout().setSpacing(0)
self.barsFrame.layout().addWidget(bar_frame)
self.bar_frames.append(bar_frame)
disks.append((text, bar_frame))
self.resizeSize = pref_size
dev = self.diskLayout[disk_id]
before_bar = PartitionsBar()
after_bar = PartitionsBar()
for p in dev:
before_bar.addPartition(p[0], int(p[1]), p[3])
after_bar.addPartition(p[0], int(p[1]), p[3])
after_bar.setResizePartition(
resize_path, min_size, max_size, pref_size,
release_name)
after_bar.partitionResized.connect(
self.on_partitionResized)
addBars(bar_frame, before_bar, after_bar)
self.disks.append(disks)
# TODO biggest_free_choice
# Use entire disk.
button = QtGui.QRadioButton(
self.useDeviceChoice, self.autopart_selection_frame)
self.autopartitionTexts.append(self.useDeviceChoice)
self.autopart_selection_frame.layout().addWidget(button)
self.autopartition_buttongroup.addButton(button, bId)
button.clicked.connect(self.controller.setNextButtonTextInstallNow)
bId += 1
disks = []
for text, path in extra_options['use_device'][1].items():
path = path[0]
bar_frame = QtGui.QFrame()
bar_frame.setLayout(QtGui.QVBoxLayout())
bar_frame.setVisible(False)
bar_frame.layout().setSpacing(0)
self.barsFrame.layout().addWidget(bar_frame)
self.bar_frames.append(bar_frame)
disks.append((text, bar_frame))
dev = self.diskLayout[path.rsplit('/', 1)[1]]
before_bar = PartitionsBar()
after_bar = PartitionsBar()
for p in dev:
before_bar.addPartition(p.device, int(p.size), p.filesystem)
#.........这里部分代码省略.........
示例10: apply_debconf_branding
def apply_debconf_branding(self):
release = misc.get_release()
for template in ['ubiquity/text/required_space',
'ubiquity/text/free_space']:
self.db.subst(template, 'RELEASE', release.name)
示例11: test_get_release_fail
def test_get_release_fail(self, mock_open):
mock_open.side_effect = Exception('Pow!')
release = misc.get_release()
self.assertEqual(release.name, 'Ubuntu')
self.assertEqual(release.version, '')
示例12: setupChoices
def setupChoices (self, choices, extra_options, resize_choice,
manual_choice, biggest_free_choice, use_device_choice):
self._clearInfo()
self.resizeChoice = resize_choice
self.manualChoice = manual_choice
self.useDeviceChoice = use_device_choice
self.extra_options = extra_options
# remove any previous autopartition selections
for child in self.autopart_selection_frame.children():
if isinstance(child, QtGui.QWidget):
child.setParent(None)
del child
for child in self.barsFrame.children():
if isinstance(child, QtGui.QWidget):
self.barsFrame.layout().removeWidget(child)
child.setParent(None)
del child
release_name = misc.get_release().name
bId = 0
if 'resize' in extra_options:
button = QtGui.QRadioButton(self.resizeChoice, self.autopart_selection_frame)
self.autopart_selection_frame.layout().addWidget(button)
self.autopartition_buttongroup.addButton(button, bId)
self.autopartitionTexts.append(resize_choice)
button.clicked.connect(self.controller.setNextButtonTextInstallNow)
bId += 1
disks = []
for disk_id in extra_options['resize']:
# information about what can be resized
unused, min_size, max_size, pref_size, \
resize_path, unused, unused = \
extra_options['resize'][disk_id]
for text, path in extra_options['use_device'][1].items():
path = path[0]
if path.rsplit('/', 1)[1] == disk_id:
bar_frame = QtGui.QFrame()
bar_frame.setLayout(QtGui.QVBoxLayout())
bar_frame.setVisible(False)
bar_frame.layout().setSpacing(0)
self.barsFrame.layout().addWidget(bar_frame)
self.bar_frames.append(bar_frame)
disks.append((text, bar_frame))
self.resizeSize = pref_size
dev = self.diskLayout[disk_id]
before_bar = PartitionsBar()
after_bar = PartitionsBar()
for p in dev:
before_bar.addPartition(p[0], int(p[1]), p[3])
after_bar.addPartition(p[0], int(p[1]), p[3])
after_bar.setResizePartition(resize_path,
min_size, max_size, pref_size, release_name)
after_bar.partitionResized.connect(self.on_partitionResized)
addBars(bar_frame, before_bar, after_bar)
self.disks.append(disks)
# TODO biggest_free_choice
# Use entire disk.
button = QtGui.QRadioButton(self.useDeviceChoice, self.autopart_selection_frame)
self.autopartitionTexts.append(self.useDeviceChoice)
self.autopart_selection_frame.layout().addWidget(button)
self.autopartition_buttongroup.addButton(button, bId)
button.clicked.connect(self.controller.setNextButtonTextInstallNow)
bId += 1
disks = []
for text, path in extra_options['use_device'][1].items():
path = path[0]
bar_frame = QtGui.QFrame()
bar_frame.setLayout(QtGui.QVBoxLayout())
bar_frame.setVisible(False)
bar_frame.layout().setSpacing(0)
self.barsFrame.layout().addWidget(bar_frame)
self.bar_frames.append(bar_frame)
disks.append((text, bar_frame))
dev = self.diskLayout[path.rsplit('/', 1)[1]]
before_bar = PartitionsBar()
after_bar = PartitionsBar()
for p in dev:
before_bar.addPartition(p.device, int(p.size), p.filesystem)
if before_bar.diskSize > 0:
after_bar.addPartition(release_name, before_bar.diskSize, 'auto')
else:
after_bar.addPartition(release_name, 1, 'auto')
addBars(bar_frame, before_bar, after_bar)
self.disks.append(disks)
#.........这里部分代码省略.........