Code review comment for ubuntu-release-upgrader:server-mode-check

Revision history for this message
Nick Rosbrook (enr0n) wrote :

Is there a more general reason why it makes sense to not allow switching from desktop to server mode? Or is this just to avoid the AttributeError?

When I first looked at this issue, the question I had about the code was: why do we assign a `self.tasks` attribute at all, instead of accessing `self.cache.installedTasks` when needed? I.e.,

diff --git a/DistUpgrade/DistUpgradeController.py b/DistUpgrade/DistUpgradeController.py
index 29002e61..71a5e4f4 100644
--- a/DistUpgrade/DistUpgradeController.py
+++ b/DistUpgrade/DistUpgradeController.py
@@ -945,8 +945,6 @@ class DistUpgradeController(object):
             self.config.set("Options","foreignPkgs", "True")
         else:
             self.config.set("Options","foreignPkgs", "False")
- if self.serverMode:
- self.tasks = self.cache.installedTasks
         logging.debug("Foreign: %s" % " ".join(sorted(self.foreign_pkgs)))
         logging.debug("Obsolete: %s" % " ".join(sorted(self.obsolete_pkgs)))
         return True
@@ -1098,7 +1096,7 @@ class DistUpgradeController(object):
             return False

         if self.serverMode:
- if not self.cache.installTasks(self.tasks):
+ if not self.cache.installTasks(self.cache.installedTasks):
                 return False

         # show changes and confirm

« Back to merge proposal