~mvo/update-manager/not-automatic

« back to all changes in this revision

Viewing changes to UpdateManager/UpdateManager.py

  • Committer: Michael Vogt
  • Date: 2009-02-16 12:09:28 UTC
  • Revision ID: michael.vogt@ubuntu.com-20090216120928-xrcylim4xrcvo8bq
make backports lower priority than distro updates, ensure that the autoamtic dependency is higher version than the regular one

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
from gettext import gettext as _
69
69
from gettext import ngettext
70
70
 
 
71
 
71
72
from Core.utils import *
72
 
from Common.SimpleGladeApp import SimpleGladeApp
73
 
from Common.UpdateList import UpdateList
74
 
from Common.HelpViewer import HelpViewer
75
 
from Common.MyCache import MyCache, NotEnoughFreeSpaceError
 
73
from Core.UpdateList import UpdateList
 
74
from Core.MyCache import MyCache, NotEnoughFreeSpaceError
 
75
from Core.MetaRelease import Dist
76
76
 
77
77
from DistUpgradeFetcher import DistUpgradeFetcherGtk
78
78
from ChangelogViewer import ChangelogViewer
79
 
 
80
 
from Core.MetaRelease import Dist
 
79
from SimpleGladeApp import SimpleGladeApp
 
80
from HelpViewer import HelpViewer
81
81
from MetaReleaseGObject import MetaRelease
82
82
 
83
83
#import pdb
106
106
 
107
107
class UpdateManager(SimpleGladeApp):
108
108
 
109
 
  def __init__(self, datadir):
 
109
  def __init__(self, datadir, options):
110
110
    self.setupDbus()
111
111
    gtk.window_set_default_icon_name("update-manager")
112
112
 
118
118
    self.window_main.set_sensitive(False)
119
119
    self.window_main.grab_focus()
120
120
    self.button_close.grab_focus()
121
 
 
122
121
    self.dl_size = 0
123
122
 
124
123
    # create text view
176
175
 
177
176
    self.gconfclient = gconf.client_get_default()
178
177
    init_proxy(self.gconfclient)
179
 
 
 
178
    try:
 
179
        self.show_versions = self.gconfclient.get_bool("/apps/update-manager/show_versions")
 
180
    except gobject.GError, e:
 
181
        self.show_versions = False
 
182
    # get progress object
 
183
    self.progress = GtkProgress.GtkOpProgress(self.dialog_cacheprogress,
 
184
                                              self.progressbar_cache,
 
185
                                              self.label_cache,
 
186
                                              self.window_main)
180
187
    # restore state
181
188
    self.restore_state()
 
189
    if options.no_focus_on_map:
 
190
        self.window_main.set_focus_on_map(False)
 
191
        self.progress._window.set_focus_on_map(False)
182
192
    self.window_main.show()
183
193
 
184
194
  def install_column_view_func(self, cell_layout, renderer, model, iter):
302
312
      if self.expander_details.get_expanded():
303
313
        lock = thread.allocate_lock()
304
314
        lock.acquire()
305
 
        t=thread.start_new_thread(self.cache.get_changelog,(name,lock))
 
315
        t=thread.start_new_thread(self.cache.get_news_and_changelog,(name,lock))
306
316
        changes_buffer.set_text("%s\n" % _("Downloading list of changes..."))
307
317
        iter = changes_buffer.get_iter_at_line(1)
308
318
        anchor = changes_buffer.create_child_anchor(iter)
319
329
        # download finished (or canceld, or time-out)
320
330
        button.hide()
321
331
        button.disconnect(id);
322
 
 
 
332
    # display NEWS.Debian first, then the changelog
 
333
    changes = ""
 
334
    srcpkg = self.cache[name].sourcePackageName
 
335
    if self.cache.all_news.has_key(name):
 
336
        changes += self.cache.all_news[name]
323
337
    if self.cache.all_changes.has_key(name):
324
 
      changes = self.cache.all_changes[name]
325
 
      self.set_changes_buffer(changes_buffer, changes[0], name, changes[1])
 
338
        changes += self.cache.all_changes[name]
 
339
    if changes:
 
340
        self.set_changes_buffer(changes_buffer, changes, name, srcpkg)
326
341
 
327
342
  def show_context_menu(self, widget, event):
328
343
    """
431
446
          if self._get_last_apt_get_update_text() is not None:
432
447
              text_label_main = self._get_last_apt_get_update_text()
433
448
      else:
434
 
          text_header = "<big><b>%s</b></big>" % \
435
 
                        (ngettext("You can install %s update.",
436
 
                                  "You can install %s updates.", 
437
 
                                  num_updates) % \
438
 
                                  num_updates)
 
449
          # show different text on first run (UX team suggestion)
 
450
          firstrun = self.gconfclient.get_bool("/apps/update-manager/first_run")
 
451
          if firstrun:
 
452
              text_header = "<big><b>%s</b></big>" % _("Welcome to Ubuntu")
 
453
              text_label_main = _("These software updates have been issued since Ubuntu was released. If you don't want to install them now, choose \"Update Manager\" from the Administration Menu later.")
 
454
              self.gconfclient.set_bool("/apps/update-manager/first_run", False)
 
455
          else:
 
456
              text_header = "<big><b>%s</b></big>" % _("Software updates are available for this computer")
 
457
              text_label_main = _("If you don't want to install them now, choose \"Update Manager\" from the Administration menu later.")
439
458
          text_download = _("Download size: %s") % humanize_size(self.dl_size)
440
459
          self.notebook_details.set_sensitive(True)
441
460
          self.treeview_update.set_sensitive(True)
559
578
      iter = self.store.get_iter(path)
560
579
      pkg = self.store.get_value(iter, LIST_PKG)
561
580
      origin = self.store.get_value(iter, LIST_ORIGIN)
 
581
 
562
582
      if pkg is not None:
563
583
          return
564
584
      self.setBusy(True)
565
585
      actiongroup = apt_pkg.GetPkgActionGroup(self.cache._depcache)
566
586
      for pkg in self.list.pkgs[origin]:
567
587
          if pkg.markedInstall or pkg.markedUpgrade:
568
 
              #print "marking keep: ", pkg.name
 
588
              print "marking keep: ", pkg.name
569
589
              pkg.markKeep()
570
590
          elif not (pkg.name in self.list.held_back):
571
 
              #print "marking install: ", pkg.name
 
591
              print "marking install: ", pkg.name
572
592
              pkg.markInstall(autoFix=False,autoInst=False)
573
593
      # check if we left breakage
574
594
      if self.cache._depcache.BrokenCount:
582
602
 
583
603
  def toggled(self, renderer, path):
584
604
    """ a toggle button in the listview was toggled """
 
605
    print "toggled"
585
606
    iter = self.store.get_iter(path)
586
607
    pkg = self.store.get_value(iter, LIST_PKG)
587
608
    # make sure that we don't allow to toggle deactivated updates
596
617
            Fix = apt_pkg.GetPkgProblemResolver(self.cache._depcache)
597
618
            Fix.ResolveByKeep()
598
619
    else:
599
 
        pkg.markInstall()
 
620
        self.cache.markUpgradeInstall(pkg)
600
621
    self.treeview_update.queue_draw()
601
622
    self.refresh_updates_count()
602
623
    self.setBusy(False)
702
723
                   "new_version" : pkg.candidateVersion}
703
724
          else:
704
725
              version = _("Version %s") % pkg.candidateVersion
705
 
          if self.gconfclient.get_bool("/apps/update-manager/show_versions"):
 
726
          if self.show_versions:
706
727
              contents = "%s\n<small>%s %s</small>" % (contents, version, size)
707
728
          else:
708
729
              contents = "%s <small>%s</small>" % (contents, size)
740
761
 
741
762
  def on_button_dist_upgrade_clicked(self, button):
742
763
      #print "on_button_dist_upgrade_clicked"
743
 
      progress = GtkProgress.GtkFetchProgress(self,
744
 
                                              _("Downloading the upgrade "
745
 
                                                "tool"),
746
 
                                              _("The upgrade tool will "
747
 
                                                "guide you through the "
748
 
                                                "upgrade process."))
749
 
      fetcher = DistUpgradeFetcherGtk(new_dist=self.new_dist, parent=self, progress=progress)
 
764
      fetcher = DistUpgradeFetcherGtk(new_dist=self.new_dist, parent=self, progress=self.progress)
750
765
      fetcher.run()
751
766
      
752
767
  def new_dist_available(self, meta_release, upgradable_to):
778
793
        #sys.exit()
779
794
 
780
795
    try:
781
 
        progress = GtkProgress.GtkOpProgress(self.dialog_cacheprogress,
782
 
                                             self.progressbar_cache,
783
 
                                             self.label_cache,
784
 
                                             self.window_main)
785
796
        if hasattr(self, "cache"):
786
 
            self.cache.open(progress)
 
797
            self.cache.open(self.progress)
787
798
            self.cache._initDepCache()
788
799
        else:
789
 
            self.cache = MyCache(progress)
 
800
            self.cache = MyCache(self.progress)
790
801
    except AssertionError:
791
802
        # if the cache could not be opened for some reason,
792
803
        # let the release upgrader handle it, it deals
808
819
        dialog.destroy()
809
820
        sys.exit(1)
810
821
    else:
811
 
        progress.hide()
 
822
        self.progress.hide()
812
823
 
813
824
  def check_auto_update(self):
814
825
      # Check if automatic update is enabled. If not show a dialog to inform