10
from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp
11
from UpdateManager.GtkProgress import GtkOpProgress
12
from SoftwareProperties.aptsources import SourcesList, SourceEntry
13
from gettext import gettext as _
15
class DistUpgradeProgress(object):
19
class DistUpgradeView(object):
20
" abstraction for the upgrade view "
23
def getOpCacheProgress(self):
24
" return a OpProgress() subclass for the given graphic"
25
return apt.progress.OpProgress()
26
def updateStatus(self, msg):
27
""" update the current status of the distUpgrade based
31
def askYesNoQuestion(self,msg):
34
class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp):
35
" gtk frontend of the distUpgrade tool "
37
# FIXME: i18n must be somewhere relative do this dir
38
SimpleGladeApp.__init__(self, "DistUpgrade.glade",
39
None, domain="update-manager")
40
self._opCacheProgress = GtkOpProgress(self.progressbar_cache)
41
def getOpCacheProgress(self):
42
return self._opCacheProgress
43
def updateStatus(self, msg):
44
self.label_status = "<b>%s</b>" % msg
46
class DistUpgradeControler(object):
47
def __init__(self, distUpgradeView):
48
self._view = distUpgradeView
50
def sanityCheck(self):
53
def updateSourcesList(self, fromDist, to):
54
sources = SourcesList()
57
# check if it's a mirror (or offical site)
58
if sources.is_mirror(entry.uri, "archive.ubuntu.com"):
59
if entry.dist == fromDist:
62
# disable all entries that are official but don't
63
# point to the "from" dist
66
# disable non-official entries that point to dist
67
if entry.dist == fromDist:
71
def breezyUpgrade(self):
72
# sanity check (check for ubuntu-desktop, brokenCache etc)
73
self._view.updateStatus(_("Checking the system"))
77
self._view.updateStatus(_("Updating repository information"))
78
self.updateSourcesList(fromDist="hoary",to="breezy")
80
# then update the package index files
84
self._view.updateStatus(_("Reading cache"))
85
self._cache = apt.Cache(self._view.getOpCacheProgress())
87
# do pre-upgrade stuff
89
# calc the dist-upgrade and see if the removals are ok/expected
93
# do post-upgrade stuff
95
# done, ask for reboot
101
if __name__ == "__main__":
102
view = GtkDistUpgradeView()
103
app = DistUpgradeControler(view)