~gilir/+junk/ubiquity-lxdm-autologin

« back to all changes in this revision

Viewing changes to ubiquity/plugins/ubi-summary.py

  • Committer: Julien Lavergne
  • Date: 2010-09-02 22:59:26 UTC
  • mfrom: (331.1.25 maverick)
  • Revision ID: gilir@ubuntu.com-20100902225926-pikufk0ha61z60ov
Merge upstream.

[ Colin Watson ]
* KDE frontend:
  - If the slideshow doesn't exist, hide self.ui.pageMode rather than
    self.page_mode (LP: #627549).
* Set Debug::identcdrom=true for apt-cdrom if installing from a
  non-ISO9660 filesystem, since otherwise apt-cdrom will include the free
  blocks count of /cdrom in its database which is unreliable on read-write
  filesystems, especially USB images with persistence enabled.  Thanks to
  Manoj Iyer for patient testing (LP: #627672).
[ Mario Limonciello ]
* Provides indicator-renderer (LP: #616165)
[ Evan Dandrea ]
* Disconnect and destroy QSocketNotifiers when the dbfilter finishes.
  Thanks Colin Watson (LP: #625586).
* add the check_hostname function back to ubi-usersetup (LP: #628317).
[ Mario Limonciello ]
* When using xfsettingsd, set the background to black first.
* Set release_notes_found to False initially to prevent a scenario it gets 
  accessed before being set when offline (LP: #628011).
[ Evan Dandrea ]
* Only set the label on the 'use entire disk' button if we're not
  going into the advanced partitioner (LP: #625258).
* Argh.  Missing import.
* Fix hostname error in KDE frontend (LP: #627489).  Guard against
  invalid hostnames in the GTK frontend.
* Create a new pipe for update-apt-cache.
[ Evan Dandrea ]
* Handle crashes in parallel debconffilters by failing the
  installation.
* Add a grub target device combobox on the GTK and KDE advanced
  partitioning pages.
* Bootloader handling is now done in ubi-partman.  Do not overwrite it
  with the default selection in plugininstall.
* Get rid of the quitting state variable and use the existing
  current_page construct (LP: #627284).
[ Mario Limonciello ]
* Add a new script that uses python-aptdaemon-gtk for oem-config removal.
* If running with only installable languages, don't offer "No Localization"
* If only one language is available, mark the language page as complete.
* Do not set up the Qt DBus main loop twice.  This was crashing on the
  prepare page.
* Stop Qt callbacks on the prepare and language pages once we have a
  result, matching the GTK behavior.
* Drop privileges before setting the background in the Qt portion of
  ubiquity-dm, otherwise .kde/share/config will be created as root.
* Beta freeze exception (LP: #625472).
[ Mario Limonciello ]
* If a plugin declares a title, but it's not fetched properly from debconf,
  hide the title bar rather than crash.
* Don't use "Ethernet" when indicating a user is connected to the network.
  (LP: #615104, #615035)
* Make sure finished_label reflects the derivative name rather than
  hardcoding to "Ubuntu".
* Set the buttons on the second autopartitioning screen appropriately
  to the choices on the first.
[ Colin Watson ]
* Update d-i/update-control for Dpkg::Deps changes in dpkg 1.15.6.
* Make ubiquity-frontend-gtk Architecture: any, due to
  /usr/lib/ubiquity/panel (LP: #616581).
* Remove build-locale on clean.
* Update build rules for changes in debian-installer-utils 1.78.
[ Jonathan Riddell ]
* Add prepare page to KDE frontend
* Update KDE Language page to closer follow GTK layout
* pixmaps/cd_in_tray.png moves to ubiquity.install-any and ubiquity replaces old
  ubiquity-frontend-gtk
* In debian/rules move usr/lib/ubiquity/ubiquity/cheese* back to
  ubiquity-frontend-gtk package, including it in ubiquity package brings in a lot
  of Gnome dependencies
* In ubi-language.py check if release notes can be accessed as well as checking
  for upgrade available and show correct label as appropriate
[ Evan Dandrea ]
* Add new non-free option text from Michael Forrest.
* Do not show the skip button by default.
* Make the keyboard guesser window modal again, making it closeable
  and accepting of input.
* Add back ready_text_label for the KDE frontend.
* Add parallel operation support to the KDE frontend, with help from
  Jonathan Riddell.
* Automatic update of included source packages: debian-installer-utils
  1.79ubuntu1, flash-kernel 2.28ubuntu8, partman-auto 91ubuntu4,
  partman-uboot 4, user-setup 1.28ubuntu8.
* Update translations from Launchpad.
* Don't show the warning text in ubi-warning until after it's translated.
* Hide the language plugin page if in greeter mode and advancing to keep the
  other pages from growing. (which seems what Evan was trying to do in r4183)
* Fix the cut off text on the warning page. (LP: #615034)
* For plugininstall, use the actual debconf database, not the parallel database.
* Redirect console blanking setterm command to /dev/console so it is effective
  with upstart.
* Show the proper derivative name for prepare_foss_disclaimer on stepPrepare.
* Fallback to NM icons if the wifi icons don't load (such as humanity missing).  
  If still fail, don't crash, just don't show icons.  (LP: #617696)
* Pass the output of wget calls into /dev/null to prevent files popping up in ~.
* If available, run xfsettingsd in ubiquity only mode.
* ubiquity-dm: wait for gsd to fork to prevent a race condition in setting
  ubiquity styles.
* Add missing imports for LabelledEntry, causing timezone and console_setup to
  not function in oem-config mode.
* Fix the partitioner trying to offer resize options in the GUI when it shouldn't.
  (LP: #617729)
* Revert additional changes to gtk_ui from r4183 that were causing the window to
  constantly resize and the auto partitioner to break.
* Automatic update of included source packages: flash-kernel
  2.28ubuntu5.
[ Mario Limonciello ]
* Drop the (now) unused install_window and references to it.
* Don't start the ubiquity panel on xfwm4.  It doesn't appear to work properly
  for now even with the proper indicators installed.
* Set the priority the prepare page higher to prevent timezone from being
  shown instead.
* Fix misc.get_release to return the proper data for non-ubuntu disks.
* Correct the text in the stepLanguage widgets to reflect ${RELEASE}
  rather than hardcoding to Ubuntu.
* depends on python-vte for GTK frontend (LP: #616272)
* depends on python-webkit for GTK frontend (LP: #616275)
[ Jonathan Riddell ]
* In ubi-wireless.py and ubi-prepare.py only load gtkwidgets.py when
  creating the GTKPage, else KDE frontend breaks
[ Mario Limonciello ]
* Also set the custom title when translating widgets.
* If there is at least one framebuffer device, fallback to fbdev rather
  than vesa for bulletproof X.
* Remove extra imports in ubiquity-dm.
* Add a new template ubiquity/force_failsafe_graphics intended to force
  installation to use vesa or fbdev, but not on the target system.  This is
  primarily intended for systems where the installation kernel has known
  graphics problems, but you are solving them in a post installation step.
* Fix packaging to install the new pieces introduced for the overhaul.
* debian/control: fix build-deps from redesign branch.
* install two new png files for the language page in the gtk frontend.
* Fix automatic mode in gtk_ui.
* Add a new controller function to allow disabling the progress_section
  of the Window for pages it doesn't make sense on that might be shown
  in automatic mode before the partitioner comes.
* Move the call to unmount_source back into install.py, it's only really
  used there for file copy, not by plugins.
* Update some DebconfFetchProgress calls to DebconfAcquireProgress calls.
* Run success cmd after plugininstall finishes.
* Correct a few more deprecated apt calls.
* Don't show the warning page or the prepare page in oem-config for now.
  The prepare page might make sense to re-enable, but will need a little
  different wording if so.
* Update deprecated use of get_release_name() to get_release().name.
* Mark timezone to come after both partman and language so that it shows
  up in oem-config too.
* Only run plugininstall after the last page in oem mode.
* If the slideshow doesn't exist, hide the page notebook rather than
  showing the webkit 404 page.
[ Bilal Akhtar ]
* debian/ubiquity.templates:
  - Add an underline symbol before the label of the install button
    to make it accessible with the Alt key. (LP: #492825)
[ Evan Dandrea ]
* Merge maverick-redesign branch.  Fingers crossed.
* Automatic update of included source packages: clock-setup
  0.103ubuntu1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*-
2
 
 
3
 
# Copyright (C) 2006, 2007, 2008 Canonical Ltd.
4
 
# Written by Colin Watson <cjwatson@ubuntu.com>.
5
 
#
6
 
# This program is free software; you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; either version 2 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 
20
 
import os
21
 
import textwrap
22
 
import subprocess
23
 
 
24
 
import debconf
25
 
 
26
 
from ubiquity.plugin import *
27
 
from ubiquity.misc import *
28
 
from ubiquity.casper import get_casper
29
 
 
30
 
from ubiquity import validation
31
 
 
32
 
NAME = 'summary'
33
 
AFTER = 'usersetup'
34
 
WEIGHT = 10
35
 
# Not useful in oem-config.
36
 
OEM = False
37
 
 
38
 
class PageBase(PluginUI):
39
 
    def __init__(self):
40
 
        self.grub_en = None
41
 
        self.summary_device = None
42
 
        self.popcon = None
43
 
        self.http_proxy_host = None
44
 
        self.http_proxy_port = 8080
45
 
 
46
 
    def set_summary_text(self):
47
 
        pass
48
 
 
49
 
class PageGtk(PageBase):
50
 
    plugin_is_install = True
51
 
    plugin_widgets = 'stepReady'
52
 
 
53
 
    def __init__(self, controller, *args, **kwargs):
54
 
        PageBase.__init__(self)
55
 
        self.controller = controller
56
 
 
57
 
        import gtk
58
 
        builder = gtk.Builder()
59
 
        controller.add_builder(builder)
60
 
        builder.add_from_file(os.path.join(os.environ['UBIQUITY_GLADE'], 'stepReady.ui'))
61
 
        builder.connect_signals(self)
62
 
        self.page = builder.get_object('stepReady')
63
 
        self.ready_text = builder.get_object('ready_text')
64
 
        self.grub_device_entry = builder.get_object('grub_device_entry')
65
 
        self.advanced_okbutton = builder.get_object('advanced_okbutton')
66
 
        self.bootloader_vbox = builder.get_object('bootloader_vbox')
67
 
        self.grub_enable = builder.get_object('grub_enable')
68
 
        self.grub_device_label = builder.get_object('grub_device_label')
69
 
        self.grub_device_entry = builder.get_object('grub_device_entry')
70
 
        self.popcon_vbox = builder.get_object('popcon_vbox')
71
 
        self.popcon_checkbutton = builder.get_object('popcon_checkbutton')
72
 
        self.proxy_host_entry = builder.get_object('proxy_host_entry')
73
 
        self.proxy_port_spinbutton = builder.get_object('proxy_port_spinbutton')
74
 
        self.advanced_dialog = builder.get_object('advanced_dialog')
75
 
        self.plugin_widgets = self.page
76
 
 
77
 
        self.grub_device_entry.connect('changed', self.grub_verify_loop,
78
 
            self.advanced_okbutton)
79
 
 
80
 
        # The default instantiation of GtkComboBoxEntry creates a
81
 
        # GtkCellRenderer, so reuse it.
82
 
        self.grub_device_entry.set_model(self.controller.grub_options)
83
 
        self.grub_device_entry.set_text_column(0)
84
 
        renderer = gtk.CellRendererText()
85
 
        self.grub_device_entry.pack_start(renderer, True)
86
 
        self.grub_device_entry.add_attribute(renderer, 'text', 1)
87
 
 
88
 
    def set_summary_text(self, text):
89
 
        import gtk
90
 
        for child in self.ready_text.get_children():
91
 
            self.ready_text.remove(child)
92
 
 
93
 
        ready_buffer = gtk.TextBuffer()
94
 
        ready_buffer.set_text(text)
95
 
        self.ready_text.set_buffer(ready_buffer)
96
 
 
97
 
    def grub_verify_loop(self, widget, okbutton):
98
 
        if widget is not None and widget.get_property('visible'):
99
 
            if validation.check_grub_device(widget.child.get_text()):
100
 
                okbutton.set_sensitive(True)
101
 
            else:
102
 
                okbutton.set_sensitive(False)
103
 
 
104
 
    def on_advanced_button_clicked(self, unused_button):
105
 
        import gtk
106
 
        display = False
107
 
        grub_en = self.controller.get_grub()
108
 
        summary_device = self.controller.get_summary_device()
109
 
 
110
 
        if grub_en is not None:
111
 
            display = True
112
 
            self.bootloader_vbox.show()
113
 
            self.grub_enable.set_active(grub_en)
114
 
        else:
115
 
            self.bootloader_vbox.hide()
116
 
            summary_device = None
117
 
 
118
 
        if summary_device is not None:
119
 
            display = True
120
 
            self.grub_device_label.show()
121
 
            self.grub_device_entry.show()
122
 
            self.grub_device_entry.child.set_text(summary_device)
123
 
            self.grub_device_entry.set_sensitive(grub_en)
124
 
            self.grub_device_label.set_sensitive(grub_en)
125
 
        else:
126
 
            self.grub_device_label.hide()
127
 
            self.grub_device_entry.hide()
128
 
 
129
 
        if self.popcon is not None:
130
 
            display = True
131
 
            self.popcon_vbox.show()
132
 
            self.popcon_checkbutton.set_active(self.popcon)
133
 
        else:
134
 
            self.popcon_vbox.hide()
135
 
 
136
 
        display = True
137
 
        if self.http_proxy_host:
138
 
            self.proxy_host_entry.set_text(self.http_proxy_host)
139
 
            self.proxy_port_spinbutton.set_sensitive(True)
140
 
        else:
141
 
            self.proxy_port_spinbutton.set_sensitive(False)
142
 
        self.proxy_port_spinbutton.set_value(self.http_proxy_port)
143
 
 
144
 
        # never happens at the moment because the HTTP proxy question is
145
 
        # always valid
146
 
        if not display:
147
 
            return
148
 
 
149
 
        response = self.advanced_dialog.run()
150
 
        self.advanced_dialog.hide()
151
 
        if response == gtk.RESPONSE_OK:
152
 
            if summary_device is not None:
153
 
                self.controller.set_summary_device(self.grub_device_entry.child.get_text())
154
 
            self.controller.set_popcon(self.popcon_checkbutton.get_active())
155
 
            self.controller.set_grub(self.grub_enable.get_active())
156
 
            self.controller.set_proxy_host(self.proxy_host_entry.get_text())
157
 
            self.controller.set_proxy_port(self.proxy_port_spinbutton.get_value_as_int())
158
 
        return True
159
 
 
160
 
    def toggle_grub(self, widget):
161
 
        if (widget is not None and widget.get_name() == 'grub_enable'):
162
 
            self.grub_device_entry.set_sensitive(widget.get_active())
163
 
            self.grub_device_label.set_sensitive(widget.get_active())
164
 
 
165
 
    def on_proxy_host_changed(self, widget):
166
 
        if widget is not None and widget.get_name() == 'proxy_host_entry':
167
 
            text = self.proxy_host_entry.get_text()
168
 
            self.proxy_port_spinbutton.set_sensitive(text != '')
169
 
 
170
 
 
171
 
class PageKde(PageBase):
172
 
    plugin_is_install = True
173
 
    plugin_breadcrumb = 'ubiquity/text/breadcrumb_summary'
174
 
 
175
 
    def __init__(self, controller, *args, **kwargs):
176
 
        PageBase.__init__(self)
177
 
 
178
 
        self.controller = controller
179
 
 
180
 
        from PyQt4 import uic
181
 
        from PyQt4.QtGui import QDialog
182
 
 
183
 
        self.plugin_widgets = uic.loadUi('/usr/share/ubiquity/qt/stepSummary.ui')
184
 
        self.advanceddialog = QDialog(self.plugin_widgets)
185
 
        uic.loadUi("/usr/share/ubiquity/qt/advanceddialog.ui", self.advanceddialog)
186
 
 
187
 
        self.advanceddialog.grub_enable.stateChanged.connect(self.toggle_grub)
188
 
        self.advanceddialog.proxy_host_entry.textChanged.connect(self.enable_proxy_spinbutton)
189
 
 
190
 
        self.plugin_widgets.advanced_button.clicked.connect(self.on_advanced_button_clicked)
191
 
        self.w = self.plugin_widgets
192
 
 
193
 
    def set_summary_text (self, text):
194
 
        text = text.replace("\n", "<br>")
195
 
        self.plugin_widgets.ready_text.setText(text)
196
 
 
197
 
    def set_grub_combo(self, options):
198
 
        ''' options gives us a possible list of install locations for the boot loader '''
199
 
        self.advanceddialog.grub_device_entry.clear()
200
 
        ''' options is from summary.py grub_options() '''
201
 
        for opt in options:
202
 
           self.advanceddialog.grub_device_entry.addItem(opt[0])
203
 
 
204
 
    def enable_proxy_spinbutton(self):
205
 
        self.advanceddialog.proxy_port_spinbutton.setEnabled(self.advanceddialog.proxy_host_entry.text() != '')
206
 
 
207
 
    def toggle_grub(self):
208
 
        grub_en = self.advanceddialog.grub_enable.isChecked()
209
 
        self.advanceddialog.grub_device_entry.setEnabled(grub_en)
210
 
        self.advanceddialog.grub_device_label.setEnabled(grub_en)
211
 
 
212
 
    def on_advanced_button_clicked(self):
213
 
 
214
 
        display = False
215
 
        grub_en = self.controller.get_grub()
216
 
        summary_device = self.controller.get_summary_device()
217
 
        self.advanceddialog.grub_device_entry.clear()
218
 
 
219
 
        if grub_en:
220
 
            self.advanceddialog.grub_enable.show()
221
 
            self.advanceddialog.grub_enable.setChecked(grub_en)
222
 
        else:
223
 
            self.advanceddialog.grub_enable.hide()
224
 
            summary_device = None
225
 
 
226
 
        if summary_device:
227
 
            display = True
228
 
            self.advanceddialog.bootloader_group_label.show()
229
 
            self.advanceddialog.grub_device_label.show()
230
 
            self.advanceddialog.grub_device_entry.show()
231
 
 
232
 
            # if the combo box does not yet have the target install device, add it
233
 
            # select current device
234
 
            summary_device = self.controller.get_summary_device()
235
 
            
236
 
            # by default select the summary device
237
 
            self.advanceddialog.grub_device_entry.addItem(summary_device)
238
 
            index = self.advanceddialog.grub_device_entry.count() - 1
239
 
            self.advanceddialog.grub_device_entry.setCurrentIndex(index)
240
 
 
241
 
            self.advanceddialog.grub_device_entry.setEnabled(grub_en)
242
 
            self.advanceddialog.grub_device_label.setEnabled(grub_en)
243
 
            
244
 
            for o in grub_options():
245
 
                if o[0] == summary_device:
246
 
                    continue
247
 
                self.advanceddialog.grub_device_entry.addItem(o[0])
248
 
        else:
249
 
            self.advanceddialog.bootloader_group_label.hide()
250
 
            self.advanceddialog.grub_device_label.hide()
251
 
            self.advanceddialog.grub_device_entry.hide()
252
 
 
253
 
        if self.popcon:
254
 
            display = True
255
 
            self.advanceddialog.popcon_group_label.show()
256
 
            self.advanceddialog.popcon_checkbutton.show()
257
 
            self.advanceddialog.popcon_checkbutton.setChecked(self.popcon)
258
 
        else:
259
 
            self.advanceddialog.popcon_group_label.hide()
260
 
            self.advanceddialog.popcon_checkbutton.hide()
261
 
 
262
 
        display = True
263
 
        if self.http_proxy_host:
264
 
            self.advanceddialog.proxy_port_spinbutton.setEnabled(True)
265
 
            self.advanceddialog.proxy_host_entry.setText(unicode(self.http_proxy_host))
266
 
        else:
267
 
            self.advanceddialog.proxy_port_spinbutton.setEnabled(False)
268
 
        self.advanceddialog.proxy_port_spinbutton.setValue(self.http_proxy_port)
269
 
 
270
 
        if not display:
271
 
            return
272
 
 
273
 
        response = self.advanceddialog.exec_()
274
 
        from PyQt4.QtGui import QDialog
275
 
        if response == QDialog.Accepted:
276
 
            if summary_device is not None:
277
 
                self.controller.set_summary_device(
278
 
                    unicode(self.advanceddialog.grub_device_entry.currentText()))
279
 
            self.controller.set_popcon(self.advanceddialog.popcon_checkbutton.isChecked())
280
 
            self.controller.set_grub(self.advanceddialog.grub_enable.isChecked())
281
 
            self.controller.set_proxy_host(unicode(self.advanceddialog.proxy_host_entry.text()))
282
 
            self.controller.set_proxy_port(self.advanceddialog.proxy_port_spinbutton.value())
283
 
 
284
 
def will_be_installed(pkg):
285
 
    try:
286
 
        casper_path = os.path.join(
287
 
            '/cdrom', get_casper('LIVE_MEDIA_PATH', 'casper').lstrip('/'))
288
 
        manifest = open(os.path.join(casper_path,
289
 
                                     'filesystem.manifest-desktop'))
290
 
        try:
291
 
            for line in manifest:
292
 
                if line.strip() == '' or line.startswith('#'):
293
 
                    continue
294
 
                if line.split()[0] == pkg:
295
 
                    return True
296
 
        finally:
297
 
            manifest.close()
298
 
    except IOError:
299
 
        return True
300
 
 
301
 
class Page(Plugin):
302
 
    def prepare(self):
303
 
        return ('/usr/share/ubiquity/summary', ['^ubiquity/summary.*'])
304
 
 
305
 
    def run(self, priority, question):
306
 
        if question.endswith('/summary'):
307
 
            text = ''
308
 
            wrapper = textwrap.TextWrapper(width=76)
309
 
            for line in self.extended_description(question).split("\n"):
310
 
                text += wrapper.fill(line) + "\n"
311
 
 
312
 
            self.ui.set_summary_text(text)
313
 
 
314
 
            try:
315
 
                install_bootloader = self.db.get('ubiquity/install_bootloader')
316
 
                self.frontend.set_grub(install_bootloader == 'true')
317
 
            except debconf.DebconfError:
318
 
                self.frontend.set_grub(None)
319
 
 
320
 
            if os.access('/usr/share/grub-installer/grub-installer', os.X_OK):
321
 
                self.frontend.set_summary_device(grub_default())
322
 
            else:
323
 
                self.frontend.set_summary_device(None)
324
 
 
325
 
            if will_be_installed('popularity-contest'):
326
 
                try:
327
 
                    participate = self.db.get('popularity-contest/participate')
328
 
                    self.frontend.set_popcon(participate == 'true')
329
 
                except debconf.DebconfError:
330
 
                    self.frontend.set_popcon(None)
331
 
            else:
332
 
                self.frontend.set_popcon(None)
333
 
 
334
 
            # This component exists only to gather some information and then
335
 
            # get out of the way.
336
 
            #return True
337
 
        return Plugin.run(self, priority, question)