]> git.ipfire.org Git - pakfire.git/commitdiff
Cleanup of transaction code.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 May 2011 15:34:06 +0000 (17:34 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 May 2011 15:34:06 +0000 (17:34 +0200)
Remove unneeded stuff and fix formatting.

pakfire/repository/transaction.py
po/pakfire.pot

index dfc7f7a0ac1661cbfa624d312c8b44172663b8db..5235d66a5e21dcbc245a5913b3be270c50564511 100644 (file)
@@ -18,10 +18,9 @@ class ActionError(Exception):
 
 
 class Action(object):
-       def __init__(self, pakfire, pkg, deps=None):
+       def __init__(self, pakfire, pkg):
                self.pakfire = pakfire
                self.pkg = pkg
-               self.deps = deps or []
 
        def __cmp__(self, other):
                # XXX ugly
@@ -30,17 +29,9 @@ class Action(object):
        def __repr__(self):
                return "<%s %s>" % (self.__class__.__name__, self.pkg.friendly_name)
 
-       def remove_dep(self, dep):
-               if not self.deps:
-                       return
-
-               while dep in self.deps:
-                       logging.debug("Removing dep %s from %s" % (dep, self))
-                       self.deps.remove(dep)
-
        @property
        def needs_download(self):
-               return self.type in ("install", "reinstall", "update", "downgrade",) \
+               return self.type in ("install", "reinstall", "upgrade", "downgrade",) \
                        and not isinstance(self.pkg, packages.BinaryPackage)
 
        def download(self, text):
@@ -109,7 +100,7 @@ class ActionInstall(Action):
                        msg = _("Installing: %s")
                elif self.type == "reinstall":
                        msg = _("Reinstalling: %s")
-               elif self.type == "update":
+               elif self.type == "upgrade":
                        msg = _("Updating: %s")
                elif self.type == "downgrade":
                        msg = _("Downgrading: %s")
@@ -172,10 +163,6 @@ class Transaction(object):
                        action = step.type_s(satsolver.TRANSACTION_MODE_ACTIVE)
                        pkg = solver1.solv2pkg(step.solvable())
 
-                       if action in ("install", "reinstall", "upgrade") and \
-                                       not isinstance(pkg, packages.BinaryPackage):
-                               transaction.downloads.append(pkg)
-
                        for action_cls in cls.action_classes:
                                if action_cls.type == action:
                                        action = action_cls(pakfire, pkg)
@@ -183,9 +170,8 @@ class Transaction(object):
                        if not isinstance(action, Action):
                                raise Exception, "Unknown action required: %s" % action
 
-                       transaction.add_action(action)
+                       transaction.actions.append(action)
 
-               print transaction.actions
                return transaction
 
        @property
@@ -253,7 +239,8 @@ class Transaction(object):
 
                s = [""]
                s.append(line)
-               s.append(PKG_DUMP_FORMAT % (_("Package"), _("Arch"), _("Version"), _("Repository"), _("Size")))
+               s.append(PKG_DUMP_FORMAT % (_("Package"), _("Arch"), _("Version"),
+                       _("Repository"), _("Size")))
                s.append(line)
 
                actions = (
@@ -270,12 +257,11 @@ class Transaction(object):
                s.append(_("Transaction Summary"))
                s.append(line)
 
-               format = "%-20s %-4d %s"
-
                for caption, pkgs in actions:
                        if not len(pkgs):
                                continue
-                       s.append(format % (caption, len(pkgs), _("package", "packages", len(pkgs))))
+                       s.append("%-20s %-4d %s" % (caption, len(pkgs),
+                               _("package", "packages", len(pkgs))))
 
                # Calculate the size of all files that need to be downloaded this this
                # transaction.
@@ -292,36 +278,13 @@ class Transaction(object):
 
                return util.ask_user(_("Is this okay?"))
 
-       def run_action(self, action):
-               try:
-                       action.run()
-               except ActionError, e:
-                       logging.error("Action finished with an error: %s - %s" % (action, e))
-
-       def add_action(self, action):
-               logging.debug("New action added: %s" % action)
-
-               self.actions.append(action)
-
-       def remove_action(self, action):
-               logging.debug("Removing action: %s" % action)
-
-               self.actions.remove(action)
-               for action in self.actions:
-                       action.remove_dep(action)
-
        def run(self):
                # Download all packages.
                self.download()
 
-               while True:
-                       if not [a for a in self.actions]:
-                               break
-
-                       for action in self.actions:
-                               if action.deps:
-                                       #logging.debug("Skipping %s which cannot be run now." % action)
-                                       continue
-
-                               self.run_action(action)
-                               self.remove_action(action)
+               # Run all actions in order and catch all kinds of ActionError.
+               for action in self.actions:
+                       try:
+                               action.run()
+                       except ActionError, e:
+                               logging.error("Action finished with an error: %s - %s" % (action, e))
index 565fe514eb2456f883e112919e588a8b91bbe48f..8b074300c2491335d74a60e7d7b18f0bbe319036 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-05-21 17:16+0200\n"
+"POT-Creation-Date: 2011-05-21 17:26+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -26,11 +26,11 @@ msgstr ""
 msgid "Name"
 msgstr ""
 
-#: ../pakfire/packages/base.py:69 ../pakfire/repository/transaction.py:256
+#: ../pakfire/packages/base.py:69 ../pakfire/repository/transaction.py:242
 msgid "Arch"
 msgstr ""
 
-#: ../pakfire/packages/base.py:70 ../pakfire/repository/transaction.py:256
+#: ../pakfire/packages/base.py:70 ../pakfire/repository/transaction.py:242
 msgid "Version"
 msgstr ""
 
@@ -38,7 +38,7 @@ msgstr ""
 msgid "Release"
 msgstr ""
 
-#: ../pakfire/packages/base.py:72 ../pakfire/repository/transaction.py:256
+#: ../pakfire/packages/base.py:72 ../pakfire/repository/transaction.py:243
 msgid "Size"
 msgstr ""
 
@@ -108,78 +108,78 @@ msgstr ""
 msgid "You have entered an invalid solution. Try again."
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:106
+#: ../pakfire/repository/transaction.py:97
 #, python-format
 msgid "Extracting: %s"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:109
+#: ../pakfire/repository/transaction.py:100
 #, python-format
 msgid "Installing: %s"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:111
+#: ../pakfire/repository/transaction.py:102
 #, python-format
 msgid "Reinstalling: %s"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:113
+#: ../pakfire/repository/transaction.py:104
 #, python-format
 msgid "Updating: %s"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:115
+#: ../pakfire/repository/transaction.py:106
 #, python-format
 msgid "Downgrading: %s"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:134
+#: ../pakfire/repository/transaction.py:125
 #, python-format
 msgid "Removing: %s"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:256
+#: ../pakfire/repository/transaction.py:242
 msgid "Package"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:256 ../pakfire/cli.py:223
+#: ../pakfire/repository/transaction.py:243 ../pakfire/cli.py:223
 msgid "Repository"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:260
+#: ../pakfire/repository/transaction.py:247
 msgid "Installing:"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:261
+#: ../pakfire/repository/transaction.py:248
 msgid "Reinstalling:"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:262
+#: ../pakfire/repository/transaction.py:249
 msgid "Updating:"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:263
+#: ../pakfire/repository/transaction.py:250
 msgid "Downgrading:"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:264
+#: ../pakfire/repository/transaction.py:251
 msgid "Removing:"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:270
+#: ../pakfire/repository/transaction.py:257
 msgid "Transaction Summary"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:278
+#: ../pakfire/repository/transaction.py:264
 msgid "package"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:284
+#: ../pakfire/repository/transaction.py:270
 #, python-format
 msgid "Total download size: %s"
 msgstr ""
 
-#: ../pakfire/repository/transaction.py:293
+#: ../pakfire/repository/transaction.py:279
 msgid "Is this okay?"
 msgstr ""