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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
# DistUpgradeViewGtk.py
#
# Copyright (c) 2004-2006 Canonical
#
# Author: Michael Vogt <michael.vogt@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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
import pygtk
pygtk.require('2.0')
import gtk
import gtk.gdk
import gtk.glade
import vte
import gobject
import pango
import sys
import logging
import time
import subprocess
import apt
import apt_pkg
import os
from DistUpgradeApport import *
from DistUpgradeView import DistUpgradeView, FuzzyTimeToStr, estimatedDownloadTime, InstallProgress
from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp, bindtextdomain
import gettext
from gettext import gettext as _
def utf8(str):
return unicode(str, 'latin1').encode('utf-8')
class GtkCdromProgressAdapter(apt.progress.CdromProgress):
""" Report the cdrom add progress
Subclass this class to implement cdrom add progress reporting
"""
def __init__(self, parent):
self.status = parent.label_status
self.progress = parent.progressbar_cache
self.parent = parent
def update(self, text, step):
""" update is called regularly so that the gui can be redrawn """
if text:
self.status.set_text(text)
self.progress.set_fraction(step/float(self.totalSteps))
while gtk.events_pending():
gtk.main_iteration()
def askCdromName(self):
return (False, "")
def changeCdrom(self):
return False
class GtkOpProgress(apt.progress.OpProgress):
def __init__(self, progressbar):
self.progressbar = progressbar
#self.progressbar.set_pulse_step(0.01)
#self.progressbar.pulse()
def update(self, percent):
#if percent > 99:
# self.progressbar.set_fraction(1)
#else:
# self.progressbar.pulse()
self.progressbar.set_fraction(percent/100.0)
while gtk.events_pending():
gtk.main_iteration()
def done(self):
self.progressbar.set_text(" ")
class GtkFetchProgressAdapter(apt.progress.FetchProgress):
# FIXME: we really should have some sort of "we are at step"
# xy in the gui
# FIXME2: we need to thing about mediaCheck here too
def __init__(self, parent):
# if this is set to false the download will cancel
self.status = parent.label_status
self.progress = parent.progressbar_cache
self.parent = parent
def mediaChange(self, medium, drive):
#print "mediaChange %s %s" % (medium, drive)
msg = _("Please insert '%s' into the drive '%s'") % (medium,drive)
dialog = gtk.MessageDialog(parent=self.parent.window_main,
flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_QUESTION,
buttons=gtk.BUTTONS_OK_CANCEL)
dialog.set_markup(msg)
res = dialog.run()
#print res
dialog.destroy()
if res == gtk.RESPONSE_OK:
return True
return False
def start(self):
#self.progress.show()
self.progress.set_fraction(0)
self.status.show()
def stop(self):
self.progress.set_text(" ")
self.status.set_text(_("Fetching is complete"))
def pulse(self):
# FIXME: move the status_str and progress_str into python-apt
# (python-apt need i18n first for this)
apt.progress.FetchProgress.pulse(self)
self.progress.set_fraction(self.percent/100.0)
currentItem = self.currentItems + 1
if currentItem > self.totalItems:
currentItem = self.totalItems
if self.currentCPS > 0:
self.status.set_text(_("Fetching file %li of %li at %sb/s") % (currentItem, self.totalItems, apt_pkg.SizeToStr(self.currentCPS)))
self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(self.eta))
else:
self.status.set_text(_("Fetching file %li of %li") % (currentItem, self.totalItems))
self.progress.set_text(" ")
while gtk.events_pending():
gtk.main_iteration()
return True
class GtkInstallProgressAdapter(InstallProgress):
# timeout with no status change when the terminal is expanded
# automatically
TIMEOUT_TERMINAL_ACTIVITY = 240
def __init__(self,parent):
InstallProgress.__init__(self)
self._cache = None
self.label_status = parent.label_status
self.progress = parent.progressbar_cache
self.expander = parent.expander_terminal
self.term = parent._term
self.parent = parent
# setup the child waiting
reaper = vte.reaper_get()
reaper.connect("child-exited", self.child_exited)
# some options for dpkg to make it die less easily
apt_pkg.Config.Set("DPkg::Options::","--force-overwrite")
apt_pkg.Config.Set("DPkg::StopOnError","False")
def startUpdate(self):
self.finished = False
# FIXME: add support for the timeout
# of the terminal (to display something useful then)
# -> longer term, move this code into python-apt
self.label_status.set_text(_("Applying changes"))
self.progress.set_fraction(0.0)
self.progress.set_text(" ")
self.expander.set_sensitive(True)
self.term.show()
# if no libgnome2-perl is installed show the terminal
frontend="gnome"
if self._cache:
if not self._cache.has_key("libgnome2-perl") or \
not self._cache["libgnome2-perl"].isInstalled:
frontend = "dialog"
self.expander.set_expanded(True)
self.env = ["VTE_PTY_KEEP_FD=%s"% self.writefd,
"DEBIAN_FRONTEND=%s" % frontend,
"APT_LISTCHANGES_FRONTEND=none"]
# do a bit of time-keeping
self.start_time = 0.0
self.time_ui = 0.0
self.last_activity = 0.0
def error(self, pkg, errormsg):
InstallProgress.error(self, pkg, errormsg)
logging.error("got an error from dpkg for pkg: '%s': '%s'" % (pkg, errormsg))
#self.expander_terminal.set_expanded(True)
self.parent.dialog_error.set_transient_for(self.parent.window_main)
summary = _("Could not install '%s'") % pkg
msg = _("The upgrade aborts now. Please report this bug against the 'update-manager' "
"package and include the files in /var/log/dist-upgrade/ in the bugreport.")
markup="<big><b>%s</b></big>\n\n%s" % (summary, msg)
self.parent.dialog_error.realize()
self.parent.dialog_error.window.set_functions(gtk.gdk.FUNC_MOVE)
self.parent.label_error.set_markup(markup)
self.parent.textview_error.get_buffer().set_text(utf8(errormsg))
self.parent.scroll_error.show()
self.parent.dialog_error.run()
self.parent.dialog_error.hide()
def conffile(self, current, new):
logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current)
start = time.time()
#self.expander.set_expanded(True)
prim = _("Replace the customized configuration file\n'%s'?") % current
sec = _("You will lose any changes you have made to this "
"configuration file if you choose to replace it with "
"a newer version.")
markup = "<span weight=\"bold\" size=\"larger\">%s </span> \n\n%s" % (prim, sec)
self.parent.label_conffile.set_markup(markup)
self.parent.dialog_conffile.set_transient_for(self.parent.window_main)
# now get the diff
if os.path.exists("/usr/bin/diff"):
cmd = ["/usr/bin/diff", "-u", current, new]
diff = utf8(subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0])
self.parent.textview_conffile.get_buffer().set_text(diff)
else:
self.parent.textview_conffile.get_buffer().set_text(_("The 'diff' command was not found"))
res = self.parent.dialog_conffile.run()
self.parent.dialog_conffile.hide()
self.time_ui += time.time() - start
# if replace, send this to the terminal
if res == gtk.RESPONSE_YES:
self.term.feed_child("y\n")
else:
self.term.feed_child("n\n")
def fork(self):
pid = self.term.forkpty(envv=self.env)
if pid == 0:
# HACK to work around bug in python/vte and unregister the logging
# atexit func in the child
sys.exitfunc = lambda: True
return pid
def statusChange(self, pkg, percent, status):
# start the timer when the first package changes its status
if self.start_time == 0.0:
#print "setting start time to %s" % self.start_time
self.start_time = time.time()
self.progress.set_fraction(float(percent)/100.0)
self.label_status.set_text(status.strip())
# start showing when we gathered some data
if percent > 1.0:
self.last_activity = time.time()
self.activity_timeout_reported = False
delta = self.last_activity - self.start_time
# time wasted in conffile questions (or other ui activity)
delta -= self.time_ui
time_per_percent = (float(delta)/percent)
eta = (100.0 - percent) * time_per_percent
# only show if we have some sensible data (60sec < eta < 2days)
if eta > 61.0 and eta < (60*60*24*2):
self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(eta))
else:
self.progress.set_text(" ")
def child_exited(self, term, pid, status):
self.apt_status = os.WEXITSTATUS(status)
self.finished = True
def waitChild(self):
while not self.finished:
self.updateInterface()
return self.apt_status
def finishUpdate(self):
self.label_status.set_text("")
def updateInterface(self):
try:
InstallProgress.updateInterface(self)
except ValueError, e:
logging.error("got ValueError from InstallPrgoress.updateInterface. Line was '%s' (%s)" % (self.read, e))
# reset self.read so that it can continue reading and does not loop
self.read = ""
# check if we haven't started yet with packages, pulse then
if self.start_time == 0.0:
self.progress.pulse()
time.sleep(0.2)
# check about terminal activity
if self.last_activity > 0 and \
(self.last_activity + self.TIMEOUT_TERMINAL_ACTIVITY) < time.time():
if not self.activity_timeout_reported:
logging.warning("no activity on terminal for %s seconds (%s)" % (self.TIMEOUT_TERMINAL_ACTIVITY, self.label_status.get_text()))
self.activity_timeout_reported = True
self.parent.expander_terminal.set_expanded(True)
while gtk.events_pending():
gtk.main_iteration()
time.sleep(0.02)
class DistUpgradeVteTerminal(object):
def __init__(self, parent, term):
self.term = term
self.parent = parent
def call(self, cmd):
def wait_for_child(widget):
#print "wait for child finished"
self.finished=True
self.term.show()
self.term.connect("child-exited", wait_for_child)
self.parent.expander_terminal.set_expanded(True)
self.term.fork_command(command=cmd[0],argv=cmd)
self.finished = False
while not self.finished:
while gtk.events_pending():
gtk.main_iteration()
time.sleep(0.1)
del self.finished
class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp):
" gtk frontend of the distUpgrade tool "
def __init__(self, datadir=None):
if not datadir:
localedir=os.path.join(os.getcwd(),"mo")
gladedir=os.getcwd()
else:
localedir="/usr/share/locale/update-manager"
gladedir=os.path.join(datadir, "glade")
# FIXME: i18n must be somewhere relative do this dir
try:
bindtextdomain("update-manager", localedir)
gettext.textdomain("update-manager")
except Exception, e:
logging.warning("Error setting locales (%s)" % e)
icons = gtk.icon_theme_get_default()
try:
gtk.window_set_default_icon(icons.load_icon("update-manager", 32, 0))
except gobject.GError, e:
logging.debug("error setting default icon, ignoring (%s)" % e)
pass
SimpleGladeApp.__init__(self, gladedir+"/DistUpgrade.glade",
None, domain="update-manager")
self.prev_step = 0 # keep a record of the latest step
# we dont use this currently
#self.window_main.set_keep_above(True)
self.icontheme = gtk.icon_theme_get_default()
# we keep a reference pngloader around so that its in memory
# -> this avoid the issue that during the dapper->edgy upgrade
# the loaders move from /usr/lib/gtk/2.4.0/loaders to 2.10.0
self.pngloader = gtk.gdk.PixbufLoader("png")
try:
self.svgloader = gtk.gdk.PixbufLoader("svg")
except gobject.GError, e:
logging.warning("svg pixbuf loader failed (%s)" % e)
pass
self.window_main.realize()
self.window_main.window.set_functions(gtk.gdk.FUNC_MOVE)
self._opCacheProgress = GtkOpProgress(self.progressbar_cache)
self._fetchProgress = GtkFetchProgressAdapter(self)
self._cdromProgress = GtkCdromProgressAdapter(self)
self._installProgress = GtkInstallProgressAdapter(self)
# details dialog
self.details_list = gtk.ListStore(gobject.TYPE_STRING)
column = gtk.TreeViewColumn("")
render = gtk.CellRendererText()
column.pack_start(render, True)
column.add_attribute(render, "markup", 0)
self.treeview_details.append_column(column)
self.treeview_details.set_model(self.details_list)
self.vscrollbar_terminal.set_adjustment(self._term.get_adjustment())
# work around bug in VteTerminal here
self._term.realize()
# Use italic style in the status labels
attrlist=pango.AttrList()
attr = pango.AttrStyle(pango.STYLE_ITALIC, 0, -1)
attrlist.insert(attr)
self.label_status.set_property("attributes", attrlist)
# reasonable fault handler
sys.excepthook = self._handleException
def _handleException(self, type, value, tb):
# we handle the exception here, hand it to apport and run the
# apport gui manually after it because we kill u-m during the upgrade
# to prevent it from poping up for reboot notifications or FF restart
# notifications or somesuch
import traceback
lines = traceback.format_exception(type, value, tb)
logging.error("not handled expection:\n%s" % "\n".join(lines))
# we can't be sure that apport will run in the middle of a upgrade
# so we still show a error message here
apport_crash(type, value, tb)
if not run_apport():
self.error(_("A fatal error occured"),
_("Please report this as a bug (if you haven't already) and include the"
"files /var/log/dist-upgrade/main.log and "
"/var/log/dist-upgrade/apt.log "
"in your report. The upgrade aborts now.\n"
"Your original sources.list was saved in "
"/etc/apt/sources.list.distUpgrade."),
"\n".join(lines))
sys.exit(1)
def getTerminal(self):
return DistUpgradeVteTerminal(self, self._term)
def create_terminal(self, arg1,arg2,arg3,arg4):
" helper to create a vte terminal "
self._term = vte.Terminal()
self._term.set_font_from_string("monospace 10")
self._term.connect("contents-changed", self._term_content_changed)
self._terminal_lines = []
try:
self._terminal_log = open("/var/log/dist-upgrade/term.log","w")
except IOError:
# if something goes wrong (permission denied etc), use stdout
self._terminal_log = sys.stdout
return self._term
def _term_content_changed(self, term):
" called when the *visible* part of the terminal changes "
# get the current visible text,
current_text = self._term.get_text(lambda a,b,c,d: True)
# see what we have currently and only print stuff that wasn't
# visible last time
new_lines = []
for line in current_text.split("\n"):
new_lines.append(line)
if not line in self._terminal_lines:
self._terminal_log.write(line+"\n")
self._terminal_log.flush()
self._terminal_lines = new_lines
def getFetchProgress(self):
return self._fetchProgress
def getInstallProgress(self, cache):
self._installProgress._cache = cache
return self._installProgress
def getOpCacheProgress(self):
return self._opCacheProgress
def getCdromProgress(self):
return self._cdromProgress
def updateStatus(self, msg):
self.label_status.set_text("%s" % msg)
def hideStep(self, step):
image = getattr(self,"image_step%i" % step)
label = getattr(self,"label_step%i" % step)
image.hide()
label.hide()
def abort(self):
size = gtk.ICON_SIZE_MENU
step = self.prev_step
if step > 0:
image = getattr(self,"image_step%i" % step)
arrow = getattr(self,"arrow_step%i" % step)
image.set_from_stock(gtk.STOCK_CANCEL, size)
image.show()
arrow.hide()
def setStep(self, step):
if self.icontheme.rescan_if_needed():
logging.debug("icon theme changed, re-reading")
# first update the "previous" step as completed
size = gtk.ICON_SIZE_MENU
attrlist=pango.AttrList()
if self.prev_step:
image = getattr(self,"image_step%i" % self.prev_step)
label = getattr(self,"label_step%i" % self.prev_step)
arrow = getattr(self,"arrow_step%i" % self.prev_step)
label.set_property("attributes",attrlist)
image.set_from_stock(gtk.STOCK_APPLY, size)
image.show()
arrow.hide()
self.prev_step = step
# show the an arrow for the current step and make the label bold
image = getattr(self,"image_step%i" % step)
label = getattr(self,"label_step%i" % step)
arrow = getattr(self,"arrow_step%i" % step)
arrow.show()
image.hide()
attr = pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)
attrlist.insert(attr)
label.set_property("attributes",attrlist)
def information(self, summary, msg, extended_msg=None):
self.dialog_information.set_transient_for(self.window_main)
msg = "<big><b>%s</b></big>\n\n%s" % (summary,msg)
self.label_information.set_markup(msg)
if extended_msg != None:
buffer = self.textview_information.get_buffer()
buffer.set_text(extended_msg)
self.scroll_information.show()
else:
self.scroll_information.hide()
self.dialog_information.realize()
self.dialog_information.window.set_functions(gtk.gdk.FUNC_MOVE)
self.dialog_information.run()
self.dialog_information.hide()
while gtk.events_pending():
gtk.main_iteration()
def error(self, summary, msg, extended_msg=None):
self.dialog_error.set_transient_for(self.window_main)
#self.expander_terminal.set_expanded(True)
msg="<big><b>%s</b></big>\n\n%s" % (summary, msg)
self.label_error.set_markup(msg)
if extended_msg != None:
buffer = self.textview_error.get_buffer()
buffer.set_text(extended_msg)
self.scroll_error.show()
else:
self.scroll_error.hide()
self.dialog_error.realize()
self.dialog_error.window.set_functions(gtk.gdk.FUNC_MOVE)
self.dialog_error.run()
self.dialog_error.hide()
return False
def confirmChanges(self, summary, changes, downloadSize, actions=None):
# FIXME: add a whitelist here for packages that we expect to be
# removed (how to calc this automatically?)
DistUpgradeView.confirmChanges(self, summary, changes, downloadSize)
pkgs_remove = len(self.toRemove)
pkgs_inst = len(self.toInstall)
pkgs_upgrade = len(self.toUpgrade)
msg = ""
if pkgs_remove > 0:
# FIXME: make those two seperate lines to make it clear
# that the "%" applies to the result of ngettext
msg += gettext.ngettext("%d package is going to be removed.",
"%d packages are going to be removed.",
pkgs_remove) % pkgs_remove
msg += " "
if pkgs_inst > 0:
msg += gettext.ngettext("%d new package is going to be "
"installed.",
"%d new packages are going to be "
"installed.",pkgs_inst) % pkgs_inst
msg += " "
if pkgs_upgrade > 0:
msg += gettext.ngettext("%d package is going to be upgraded.",
"%d packages are going to be upgraded.",
pkgs_upgrade) % pkgs_upgrade
msg +=" "
if downloadSize > 0:
msg += _("\n\nYou have to download a total of %s. ") %\
apt_pkg.SizeToStr(downloadSize)
msg += estimatedDownloadTime(downloadSize)
msg += "."
if (pkgs_upgrade + pkgs_inst + pkgs_remove) > 100:
msg += "\n\n%s" % _("Fetching and installing the upgrade can take several hours and "\
"cannot be canceled at any time later.")
msg += "\n\n<b>%s</b>" % _("To prevent data loss close all open "\
"applications and documents.")
# Show an error if no actions are planned
if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1:
# FIXME: this should go into DistUpgradeController
summary = _("Your system is up-to-date")
msg = _("There are no upgrades available for your system. "
"The upgrade will now be canceled.")
self.error(summary, msg)
return False
if actions != None:
self.button_cancel_changes.set_use_stock(False)
self.button_cancel_changes.set_use_underline(True)
self.button_cancel_changes.set_label(actions[0])
self.button_confirm_changes.set_label(actions[1])
self.label_summary.set_markup("<big><b>%s</b></big>" % summary)
self.label_changes.set_markup(msg)
# fill in the details
self.details_list.clear()
for rm in self.toRemove:
self.details_list.append([_("<b>Remove %s</b>") % rm])
for inst in self.toInstall:
self.details_list.append([_("Install %s") % inst])
for up in self.toUpgrade:
self.details_list.append([_("Upgrade %s") % up])
self.treeview_details.scroll_to_cell((0,))
self.dialog_changes.set_transient_for(self.window_main)
self.dialog_changes.realize()
self.dialog_changes.window.set_functions(gtk.gdk.FUNC_MOVE)
res = self.dialog_changes.run()
self.dialog_changes.hide()
if res == gtk.RESPONSE_YES:
return True
return False
def askYesNoQuestion(self, summary, msg, default='No'):
msg = "<big><b>%s</b></big>\n\n%s" % (summary,msg)
dialog = gtk.MessageDialog(parent=self.window_main,
flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_QUESTION,
buttons=gtk.BUTTONS_YES_NO)
if default == 'No':
dialog.set_default_response(gtk.RESPONSE_NO)
else:
dialog.set_default_response(gtk.RESPONSE_YES)
dialog.set_markup(msg)
res = dialog.run()
dialog.destroy()
if res == gtk.RESPONSE_YES:
return True
return False
def confirmRestart(self):
self.dialog_restart.set_transient_for(self.window_main)
self.dialog_restart.realize()
self.dialog_restart.window.set_functions(gtk.gdk.FUNC_MOVE)
res = self.dialog_restart.run()
self.dialog_restart.hide()
if res == gtk.RESPONSE_YES:
return True
return False
def on_window_main_delete_event(self, widget, event):
self.dialog_cancel.set_transient_for(self.window_main)
self.dialog_cancel.realize()
self.dialog_cancel.window.set_functions(gtk.gdk.FUNC_MOVE)
res = self.dialog_cancel.run()
self.dialog_cancel.hide()
if res == gtk.RESPONSE_CANCEL:
#FIXME: this does not work correctly and leaves a stalled
# dist-upgrade.py process
self.destroy()
return True
if __name__ == "__main__":
view = DistUpgradeViewGtk()
fp = GtkFetchProgressAdapter(view)
ip = GtkInstallProgressAdapter(view)
cache = apt.Cache()
for pkg in sys.argv[1:]:
if cache[pkg].isInstalled:
cache[pkg].markDelete()
else:
cache[pkg].markInstall()
cache.commit(fp,ip)
gtk.main()
sys.exit(0)
#sys.exit(0)
ip.conffile("TODO","TODO~")
view.getTerminal().call(["dpkg","--configure","-a"])
#view.getTerminal().call(["ls","-R","/usr"])
view.error("short","long",
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
)
view.confirmChanges("xx",[], 100)
|