/usr/lib/ubiquity/plugins/edubuntu-addon.py is in edubuntu-live 14.04.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | # -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright (C) 2010 Stephane Graber
# Author: Stephane Graber <stgraber@ubuntu.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
from ubiquity.plugin import *
from ubiquity import i18n
from ubiquity import misc
NAME = 'edubuntu-addon'
BEFORE = 'partman'
WEIGHT = 10
OEM = False
class PageBase(PluginUI):
pass
class PageGtk(PageBase):
plugin_title = 'ubiquity/text/edubuntu-addon_heading_label'
def __init__(self, controller, *args, **kwargs):
self.controller = controller
try:
from gi.repository import Gtk as gtk
import subprocess
builder = gtk.Builder()
builder.add_from_file(os.path.join(os.environ['UBIQUITY_GLADE'],
'edubuntu-addon.ui'))
builder.connect_signals(self)
self.controller.add_builder(builder)
self.page = builder.get_object('edubuntu-addon_window')
# Load required objects
self.description = builder.get_object('description')
self.fallback_install = builder.get_object('fallback_install')
self.fallback_title = builder.get_object('fallback_title')
self.fallback_description = builder.get_object('fallback_description')
self.separator = builder.get_object('separator1')
self.ltsp_hbox = builder.get_object('ltsp_hbox')
self.ltsp_install = builder.get_object('ltsp_install')
self.ltsp_title = builder.get_object('ltsp_title')
self.ltsp_description = builder.get_object('ltsp_description')
self.ltsp_interface = builder.get_object('ltsp_interface')
self.ltsp_interface_label = builder.get_object('ltsp_interface_label')
# Hide LTSP option when no .img file
if not os.path.exists("/cdrom/casper/ltsp.squashfs"):
self.separator.set_visible(False)
self.ltsp_hbox.set_visible(False)
# Populate drop-down
self.model_interface = gtk.ListStore(str)
with open('/dev/null', 'w') as devnull:
nmcli = subprocess.Popen(
['nmcli', '-t', '-f', 'DEVICE,TYPE', 'dev'],
stderr=devnull, stdout=subprocess.PIPE,
universal_newlines=True)
for line in sorted(nmcli.stdout.readlines()):
info=line.strip().split(':')
self.model_interface.append(["%s (%s)" % (info[0],info[1])])
nmcli.stdout.close()
self.ltsp_interface.set_model(self.model_interface)
cell = gtk.CellRendererText()
self.ltsp_interface.pack_start(cell, False)
self.ltsp_interface.add_attribute(cell,'text',0)
self.ltsp_interface.set_active(0)
except Exception as e:
self.debug('Could not create edubuntu-addon page: %s', e)
self.page = None
self.plugin_widgets = self.page
def plugin_translate(self, lang):
self.description.set_markup(self.controller.get_string('edubuntu-addon_description_label', lang))
self.fallback_install.set_property('label',self.controller.get_string('edubuntu-addon_fallback_install_label', lang))
self.fallback_title.set_markup("<span size=\"x-large\"><b>%s</b></span>" % self.controller.get_string('edubuntu-addon_fallback_title_label', lang))
self.fallback_description.set_markup(self.controller.get_string('edubuntu-addon_fallback_description_label', lang))
self.ltsp_install.set_property('label',self.controller.get_string('edubuntu-addon_ltsp_install_label', lang))
self.ltsp_title.set_markup("<span size=\"x-large\"><b>%s</b></span>" % self.controller.get_string('edubuntu-addon_ltsp_title_label', lang))
self.ltsp_description.set_markup(self.controller.get_string('edubuntu-addon_ltsp_description_label', lang))
self.ltsp_interface_label.set_markup("<b>%s </b>" % self.controller.get_string('edubuntu-addon_ltsp_interface_label', lang))
class Page(Plugin):
def Prepare(self):
self.ui.fallback_install.set_active(self.db.get('ubiquity/edubuntu-addon_fallback_install') == 'true')
self.ui.ltsp_install.set_active(self.db.get('ubiquity/edubuntu-addon_ltsp_install') == 'true')
self.ui.ltsp_interface.set_active(int(self.db.get('ubiquity/edubuntu-addon_ltsp_interface_index')))
def ok_handler(self):
self.preseed_bool('ubiquity/edubuntu-addon_fallback_install',self.ui.fallback_install.get_active())
self.preseed_bool('ubiquity/edubuntu-addon_ltsp_install',self.ui.ltsp_install.get_active())
self.preseed('ubiquity/edubuntu-addon_ltsp_interface',self.ui.model_interface[self.ui.ltsp_interface.get_active()][0].split(' ')[0])
self.preseed('ubiquity/edubuntu-addon_ltsp_interface_index',str(self.ui.ltsp_interface.get_active()))
Plugin.ok_handler(self)
|