diff options
| -rw-r--r-- | DistUpgrade/DistUpgrade.cfg | 11 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeControler.py | 37 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeViewGtk.py | 4 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeViewNonInteractive.py | 33 | ||||
| -rwxr-xr-x | DistUpgrade/dist-upgrade.py | 13 | ||||
| -rw-r--r-- | SoftwareProperties/__init__.py | 1 | ||||
| -rw-r--r-- | UpdateManager/UpdateManager.py | 2 | ||||
| -rw-r--r-- | gnome-software-properties | 2 |
8 files changed, 65 insertions, 38 deletions
diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index cf97d16f..e081313a 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -1,5 +1,6 @@ -[General] -Frontend=GtkDistUpgradeView +[View] +View=DistUpgradeViewGtk +#View=DistUpgradeViewNonInteractive # Distro contains global information about the upgrade [Distro] @@ -15,6 +16,7 @@ ForcedObsoletes=xscreensaver [kubuntu-desktop] KeyDependencies=kdm, kicker, kubuntu-artwork-usplash +ForcedObsoletes=ivman [edubuntu-desktop] KeyDependencies=edubuntu-artwork, tuxpaint @@ -30,4 +32,7 @@ BackupExt=distUpgrade From=breezy To=dapper ValidOrigin=Ubuntu -ValidMirrors = http://archive.ubuntu.com/ubuntu, http://security.ubuntu.com/ubuntu, http://archive.distrosprint/ubuntu/
\ No newline at end of file +ValidMirrors = http://archive.ubuntu.com/ubuntu, http://security.ubuntu.com/ubuntu, http://archive.distrosprint/ubuntu/ + +[Network] +MaxRetries=3
\ No newline at end of file diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 3a43d517..71127092 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -158,17 +158,25 @@ class DistUpgradeControler(object): progress = self._view.getFetchProgress() # FIXME: retry here too? just like the DoDistUpgrade? # also remove all files from the lists partial dir! - try: - res = self.cache.update(progress) - except IOError, e: - self._view.error(_("Error during update"), - _("A problem occured during the update. " - "This is usually some sort of network " - "problem, please check your network " - "connection and retry."), - "%s" % e) - return False - return True + currentRetry = 0 + maxRetries = self.config.get("Network","MaxRetries") + while currentRetry < maxRetries: + try: + res = self.cache.update(progress) + except IOError, e: + logging.error("IOError in cache.update(): '%s'. Retrying (currentRetry: %s)" % (e,currentRetry)) + currentRetry += 1 + continue + # no exception, so all was fine, we are done + return True + + self._view.error(_("Error during update"), + _("A problem occured during the update. " + "This is usually some sort of network " + "problem, please check your network " + "connection and retry."), "%s" % e) + return False + def askDistUpgrade(self): if not self.cache.distUpgrade(self._view): @@ -191,12 +199,13 @@ class DistUpgradeControler(object): self.cache.requiredDownload) return res - def doDistUpgrade(self, currentTry=0): + def doDistUpgrade(self): currentRetry = 0 fprogress = self._view.getFetchProgress() iprogress = self._view.getInstallProgress() # retry the fetching in case of errors - while currentRetry < 3: + maxRetries = self.config.get("Network","MaxRetries") + while currentRetry < maxRetries: try: res = self.cache.commit(fprogress,iprogress) except SystemError, e: @@ -210,7 +219,7 @@ class DistUpgradeControler(object): return False except IOError, e: # fetch failed, will be retried - logging.error("IOError in cache.commit(): '%s'. Retrying (currentTry: %s)" % (e,currentTry)) + logging.error("IOError in cache.commit(): '%s'. Retrying (currentTry: %s)" % (e,currentRetry)) currentRetry += 1 continue # no exception, so all was fine, we are done diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index f32533db..b4ad4a0a 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -29,6 +29,7 @@ import gobject import pango import sys import logging +import time import apt import apt_pkg @@ -169,9 +170,10 @@ class GtkInstallProgressAdapter(InstallProgress): self.label_status.set_text(self.status) while gtk.events_pending(): gtk.main_iteration() + time.sleep(0.01) -class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp): +class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): " gtk frontend of the distUpgrade tool " diff --git a/DistUpgrade/DistUpgradeViewNonInteractive.py b/DistUpgrade/DistUpgradeViewNonInteractive.py index e8236565..7a8fa7eb 100644 --- a/DistUpgrade/DistUpgradeViewNonInteractive.py +++ b/DistUpgrade/DistUpgradeViewNonInteractive.py @@ -21,8 +21,19 @@ import apt import logging +import time +from DistUpgradeView import DistUpgradeView -class NonInteractiveDistUpgradeView(object): +class NonInteractiveInstallProgress(apt.progress.InstallProgress): + def error(self, pkg, errormsg): + logging.error("got a error from dpkg for pkg: '%s': '%s'" % (pkg, errormsg)) + def conffile(self, current, new): + logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current) + def updateInterface(self): + apt.progress.InstallProgress.updateInterface(self) + time.sleep(0.001) + +class DistUpgradeViewNonInteractive(DistUpgradeView): " non-interactive version of the upgrade view " def __init__(self): pass @@ -34,7 +45,7 @@ class NonInteractiveDistUpgradeView(object): return apt.progress.FetchProgress() def getInstallProgress(self): " return a install progress object " - return apt.progress.InstallProgress() + return NonInteractiveInstallProgress() def updateStatus(self, msg): """ update the current status of the distUpgrade based on the current view @@ -50,18 +61,10 @@ class NonInteractiveDistUpgradeView(object): """ pass def confirmChanges(self, summary, changes, downloadSize): - """ display the list of changed packages (apt.Package) and - return if the user confirms them - """ - self.toInstall = [] - self.toUpgrade = [] - self.toRemove = [] - for pkg in changes: - if pkg.markedInstall: self.toInstall.append(pkg.name) - elif pkg.markedUpgrade: self.toUpgrade.append(pkg.name) - elif pkg.markedDelete: self.toRemove.append(pkg.name) - # no downgrades, re-installs - assert(len(self.toInstall)+len(self.toUpgrade)+len(self.toRemove) == len(changes)) + DistUpgradeView.confirmChanges(self, summary, changes, downloadSize) + logging.debug("toinstall: '%s'" % self.toInstall) + logging.debug("toupgrade: '%s'" % self.toUpgrade) + logging.debug("toremove: '%s'" % self.toRemove) return True def askYesNoQuestion(self, summary, msg): " ask a Yes/No question and return True on 'Yes' " @@ -71,5 +74,5 @@ class NonInteractiveDistUpgradeView(object): return False def error(self, summary, msg, extended_msg=None): " display a error " - logging.error("%s %s (%s)" % (summary, msg, extended_msg) + logging.error("%s %s (%s)" % (summary, msg, extended_msg)) diff --git a/DistUpgrade/dist-upgrade.py b/DistUpgrade/dist-upgrade.py index 14f9f4a1..437be42d 100755 --- a/DistUpgrade/dist-upgrade.py +++ b/DistUpgrade/dist-upgrade.py @@ -1,10 +1,10 @@ #!/usr/bin/python2.4 -from DistUpgradeViewGtk import GtkDistUpgradeView from DistUpgradeControler import DistUpgradeControler from DistUpgradeConfigParser import DistUpgradeConfig import logging import os +import sys if __name__ == "__main__": @@ -13,7 +13,16 @@ if __name__ == "__main__": format='%(asctime)s %(levelname)s %(message)s', filemode='w') - view = GtkDistUpgradeView() + config = DistUpgradeConfig() + requested_view= config.get("View","View") + try: + view_modul = __import__(requested_view) + view_class = getattr(view_modul, requested_view) + view = view_class() + except (ImportError, AttributeError): + logging.error("can't import view '%s'" % requested_view) + print "can't find %s" % requested_view + sys.exit(1) app = DistUpgradeControler(view) app.run() diff --git a/SoftwareProperties/__init__.py b/SoftwareProperties/__init__.py index 1e6834bd..e69de29b 100644 --- a/SoftwareProperties/__init__.py +++ b/SoftwareProperties/__init__.py @@ -1 +0,0 @@ -from SoftwareProperties import SoftwareProperties diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index de77f041..3724de94 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -637,7 +637,7 @@ class UpdateManager(SimpleGladeApp): # self.window_main.set_sensitive(True) self.window_main.set_sensitive(False) from SoftwareProperties import SoftwareProperties - prop = SoftwareProperties(self.datadir, None) + prop = SoftwareProperties.SoftwareProperties(self.datadir, None) prop.window_main.set_transient_for(self.window_main) prop.run() prop.window_main.hide() diff --git a/gnome-software-properties b/gnome-software-properties index d5cbd0ce..a8074f7e 100644 --- a/gnome-software-properties +++ b/gnome-software-properties @@ -37,7 +37,7 @@ from optparse import OptionParser #sys.path.append("@prefix@/share/update-manager/python") -import SoftwareProperties +from SoftwareProperties import SoftwareProperties if __name__ == "__main__": _ = gettext.gettext |
