diff options
| author | Sebastian Heinlein <sebi@server.daheim> | 2006-04-17 15:21:42 +0200 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@server.daheim> | 2006-04-17 15:21:42 +0200 |
| commit | 8670d8c43a9ce7f42b85febe7bd9d35310fcb8ea (patch) | |
| tree | 6d92362d2623d7d293c94591e4d6fff6c80ef2c7 /UpdateManager | |
| parent | dbe01bf94fa020f5fc88cc320cf47a79db146d73 (diff) | |
| parent | a34c35a2528041e658e541692adaa8b542a2e086 (diff) | |
| download | python-apt-8670d8c43a9ce7f42b85febe7bd9d35310fcb8ea.tar.gz | |
huge merge from mvo
Diffstat (limited to 'UpdateManager')
| -rw-r--r-- | UpdateManager/Common/utils.py | 12 | ||||
| -rw-r--r-- | UpdateManager/DistUpgradeFetcher.py | 46 | ||||
| -rw-r--r-- | UpdateManager/MetaRelease.py | 6 | ||||
| -rw-r--r-- | UpdateManager/UpdateManager.py | 23 | ||||
| -rw-r--r-- | UpdateManager/fakegconf.py | 69 |
5 files changed, 137 insertions, 19 deletions
diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py index ffafadfb..17c62212 100644 --- a/UpdateManager/Common/utils.py +++ b/UpdateManager/Common/utils.py @@ -1,3 +1,4 @@ +import gtk def str_to_bool(str): if str == "0" or str.upper() == "FALSE": @@ -7,3 +8,14 @@ def str_to_bool(str): def utf8(str): return unicode(str, 'latin1').encode('utf-8') + +def error(parent, summary, message): + d = gtk.MessageDialog(parent=parent, + flags=gtk.DIALOG_MODAL, + type=gtk.MESSAGE_ERROR, + buttons=gtk.BUTTONS_CLOSE) + d.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, message)) + d.set_title("") + res = d.run() + d.destroy() + return diff --git a/UpdateManager/DistUpgradeFetcher.py b/UpdateManager/DistUpgradeFetcher.py index c6b83994..aa51066a 100644 --- a/UpdateManager/DistUpgradeFetcher.py +++ b/UpdateManager/DistUpgradeFetcher.py @@ -33,7 +33,7 @@ from gettext import gettext as _ import GtkProgress from ReleaseNotesViewer import ReleaseNotesViewer - +from Common.utils import * class DistUpgradeFetcher(object): @@ -90,7 +90,7 @@ class DistUpgradeFetcher(object): # user clicked cancel if res == gtk.RESPONSE_CANCEL: return False - return True + return True def authenticate(self): if self.new_dist.upgradeToolSig: @@ -104,19 +104,30 @@ class DistUpgradeFetcher(object): # mandatory return True - def gpgauthenticate(self, file, signature, keyring='/etc/apt/trusted.gpg'): + def gpgauthenticate(self, file, signature, + keyring='/etc/apt/trusted.gpg', + trustdb='/etc/apt/trustdb.gpg'): """ authenticated a file against a given signature, if no keyring is given use the apt default keyring """ gpg = GnuPGInterface.GnuPG() - gpg.options.extra_args = ['--no-default-keyring', + gpg.options.extra_args = ['--no-options', + '--no-default-keyring', + '--trustdb-name',trustdb, '--keyring', keyring] proc = gpg.run(['--verify', signature, file], create_fhs=['status','logger','stderr']) gpgres = proc.handles['status'].read() - proc.wait() + try: + proc.wait() + except IOError,e: + # gnupg returned a problem (non-zero exit) + print "exception from gpg: %s" % e + return False if "VALIDSIG" in gpgres: return True + print "invalid result from gpg:" + print gpgres return False def extractDistUpgrader(self): @@ -192,22 +203,37 @@ class DistUpgradeFetcher(object): if not self.showReleaseNotes(): return if not self.fetchDistUpgrader(): - print "Fetch failed" + error(self.window_main, + _("Failed to fetch"), + _("Fetching the upgrade failed. There may be a network " + "problem. ")) return if not self.extractDistUpgrader(): - print "extract failed" + error(self.window_main, + _("Failed to extract"), + _("Extracting the upgrade failed. There may be a problem " + "with the network or with the server. ")) + return if not self.verifyDistUprader(): - print "verify failed" + error(self.window_main, + _("Verfication failed"), + _("Verfing the upgrade failed. There may be a problem " + "with the network or with the server. ")) self.cleanup() return if not self.authenticate(): - print "authenticate failed" + error(self.window_main, + _("Authentication failed"), + _("Authenticating the upgrade failed. There may be a problem " + "with the network or with the server. ")) self.cleanup() return self.runDistUpgrader() if __name__ == "__main__": - d = DistUpgradeFetcher(None) + error(None, "summary","message") + d = DistUpgradeFetcher(None,None) print d.authenticate('/tmp/Release','/tmp/Release.gpg') + diff --git a/UpdateManager/MetaRelease.py b/UpdateManager/MetaRelease.py index fde705bb..b655f36a 100644 --- a/UpdateManager/MetaRelease.py +++ b/UpdateManager/MetaRelease.py @@ -44,7 +44,7 @@ class MetaRelease(gobject.GObject): # some constants METARELEASE_URI = "http://changelogs.ubuntu.com/meta-release" - #METARELEASE_URI = "http://people.ubuntu.com/~mvo/dist-upgrader/meta-release-test2" + METARELEASE_URI_UNSTABLE = "http://changelogs.ubuntu.com/meta-release-development" METARELEASE_FILE = "/var/lib/update-manager/meta-release" __gsignals__ = { @@ -57,8 +57,10 @@ class MetaRelease(gobject.GObject): } - def __init__(self): + def __init__(self, useDevelopmentRelase=False): gobject.GObject.__init__(self) + if useDevelopmentRelase: + self.METARELEASE_URI = self.METARELEASE_URI_UNSTABLE self.metarelease_information = None self.downloading = True # we start the download thread here and we have a timeout diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index bdbfc20f..45638838 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -28,7 +28,10 @@ pygtk.require('2.0') import gtk import gtk.gdk import gtk.glade -import gconf +try: + import gconf +except: + import fakegconf as gconf import gobject import apt import apt_pkg @@ -179,7 +182,7 @@ class UpdateList: msg = ("<big><b>%s</b></big>\n\n%s" % \ (_("Cannot install all available updates"), _("Some updates require the removal of further software. " - "Use the function \"Smart Upgrade\" of the package manager " + "Use the function \"Mark All Upgrades\" of the package manager " "\"Synaptic\" or run \"sudo apt-get dist-upgrade\" in a " "terminal to update your system completely."))) dialog = gtk.MessageDialog(self.parent_window, 0, gtk.MESSAGE_INFO, @@ -639,12 +642,12 @@ class UpdateManager(SimpleGladeApp): dialog.destroy() def on_button_dist_upgrade_clicked(self, button): - print "on_button_dist_upgrade_clicked" + #print "on_button_dist_upgrade_clicked" fetcher = DistUpgradeFetcher(self, self.new_dist) fetcher.run() def new_dist_available(self, meta_release, upgradable_to): - print "new_dist_available: %s" % upgradable_to.name + #print "new_dist_available: %s" % upgradable_to.name # check if the user already knowns about this dist #seen = self.gconfclient.get_string("/apps/update-manager/seen_dist") #if name == seen: @@ -735,10 +738,16 @@ class UpdateManager(SimpleGladeApp): self.on_button_reload_clicked(None) - def main(self): - self.meta = MetaRelease() - self.meta.connect("new_dist_available",self.new_dist_available) + def main(self, options): + gconfclient = gconf.client_get_default() + self.meta = MetaRelease(options.devel_release) self.meta.connect("dist_no_longer_supported",self.dist_no_longer_supported) + + # check if we are interessted in dist-upgrade information + # (we are not by default on dapper) + if options.check_dist_upgrades or \ + gconfclient.get_bool("/apps/update-manager/check_dist_upgrades"): + self.meta.connect("new_dist_available",self.new_dist_available) while gtk.events_pending(): gtk.main_iteration() diff --git a/UpdateManager/fakegconf.py b/UpdateManager/fakegconf.py new file mode 100644 index 00000000..7e387b56 --- /dev/null +++ b/UpdateManager/fakegconf.py @@ -0,0 +1,69 @@ +# Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> + +# This is a class which handles settings when the gconf library +# is unavailable such as in a non-Gnome environment +# The configuration is stored in python hash format which is sourced +# at program start and dumped at exit + +import string +import atexit + +CONFIG_FILE="/root/.update-manager-conf" + +class FakeGconf: + + def __init__(self): + self.config = {} + try: + #execute python file which contains the dictionary called config + exec open (CONFIG_FILE) + self.config = config + except: + pass + + #only get the 'basename' from the gconf key + def keyname(self, key): + return string.rsplit(key, '/', 1)[-1] + + def get_bool(self, key): + key = self.keyname(key) + return self.config.setdefault(self.keyname(key), True) + + def set_bool(self, key,value): + key = self.keyname(key) + self.config[key] = value + + # FIXME assume type is int for now + def get_pair(self, key, ta = None, tb = None): + key = self.keyname(key) + return self.config.setdefault(self.keyname(key), [400, 500]) + + # FIXME assume type is int for now + def set_pair(self, key, ta, tb, a, b): + key = self.keyname(key) + self.config[key] = [a, b] + + #Save current dictionary to config file + def save(self): + file = open(CONFIG_FILE, "w") + data = "config = {" + for i in self.config: + data += "'"+i+"'" + ":" + str(self.config[i])+",\n" + data += "}" + file.write(data) + file.close() + + +VALUE_INT = "" + +fakegconf = FakeGconf() + +def client_get_default(): + return fakegconf + +def fakegconf_atexit(): + fakegconf.save() + +atexit.register(fakegconf_atexit) + + |
