--- /dev/null
+#!/usr/bin/python
+
+import logging
+
+import packages
+
+from constants import *
+from i18n import _
+
+class Action(object):
+ def __init__(self, pakfire, pkg):
+ self.pakfire = pakfire
+ self.pkg = pkg
+
+ # Try to get the binary version of the package from the cache if
+ # any.
+ binary_package = self.pkg.get_from_cache()
+ if binary_package:
+ self.pkg = binary_package
+
+ def __cmp__(self, other):
+ # XXX ugly
+ return cmp(self.__repr__(), other.__repr__())
+
+ def __repr__(self):
+ return "<%s %s>" % (self.__class__.__name__, self.pkg.friendly_name)
+
+ @property
+ def needs_download(self):
+ return self.type in ("install", "reinstall", "upgrade", "downgrade",) \
+ and not isinstance(self.pkg, packages.BinaryPackage)
+
+ def download(self, text):
+ if not self.needs_download:
+ return
+
+ self.pkg = self.pkg.download(text)
+
+ def run(self):
+ raise NotImplementedError
+
+ @property
+ def local(self):
+ """
+ Reference to local repository.
+ """
+ return self.pakfire.repos.local
+
+ def _extract(self, message, prefix=None):
+ # Add package to the database.
+ self.local.add_package(self.pkg)
+
+ if prefix is None:
+ prefix = self.pakfire.path
+
+ self.pkg.extract(message, prefix=prefix)
+
+
+class ActionCleanup(Action):
+ type = "ignore"
+
+ def run(self):
+ print "XXX Cleanup: %s" % self.pkg
+
+
+class ActionScript(Action):
+ def run(self):
+ pass
+
+
+class ActionScriptPreIn(ActionScript):
+ pass
+
+
+class ActionScriptPostIn(ActionScript):
+ pass
+
+
+class ActionScriptPreUn(ActionScript):
+ pass
+
+
+class ActionScriptPostUn(ActionScript):
+ pass
+
+
+class ActionInstall(Action):
+ type = "install"
+
+ def run(self):
+ self._extract(_("Installing"))
+
+
+class ActionUpdate(Action):
+ type = "upgrade"
+
+ def run(self):
+ self._extract(_("Updating"))
+
+
+class ActionRemove(ActionCleanup):
+ type = "erase"
+
+ def run(self):
+ files = self.pkg.filelist
+
+ if not files:
+ return
+
+ self.remove_files(_("Removing: %s") % self.pkg.name, files)
+
+
+class ActionReinstall(Action):
+ type = "reinstall"
+
+ def run(self):
+ self._extract(_("Installing"))
+
+
+class ActionDowngrade(Action):
+ type = "downgrade"
+
+ def run(self):
+ self._extract(_("Downgrading"))
+
+
+class ActionChange(Action):
+ type = "change"
+
+ def run(self):
+ print "XXX Change: %s" % self.pkg
class Error(Exception):
pass
+
+class ActionError(Error):
+ pass
class BuildAbortedException(Error):
pass
# Load progressbar.
pb = None
if message:
- pb = util.make_progress("%-40s" % message, len(members))
+ message = "%-10s : %s" % (message, self.friendly_name)
+ pb = util.make_progress(message, len(members), eta=False)
i = 0
for member in members:
import satsolver
import util
+from constants import *
from i18n import _
PKG_DUMP_FORMAT = " %-21s %-8s %-21s %-19s %5s "
-class ActionError(Exception):
- pass
-
-
-class Action(object):
- def __init__(self, pakfire, pkg):
- self.pakfire = pakfire
- self.pkg = pkg
-
- # Try to get the binary version of the package from the cache if
- # any.
- binary_package = self.pkg.get_from_cache()
- if binary_package:
- self.pkg = binary_package
-
- def __cmp__(self, other):
- # XXX ugly
- return cmp(self.__repr__(), other.__repr__())
-
- def __repr__(self):
- return "<%s %s>" % (self.__class__.__name__, self.pkg.friendly_name)
-
- @property
- def needs_download(self):
- return self.type in ("install", "reinstall", "upgrade", "downgrade",) \
- and not isinstance(self.pkg, packages.BinaryPackage)
-
- def download(self, text):
- if not self.needs_download:
- return
-
- self.pkg = self.pkg.download(text)
-
- def run(self):
- raise NotImplementedError
-
- @property
- def local(self):
- """
- Reference to local repository (database).
- """
- return self.pakfire.repos.local
-
-
-class ActionCleanup(Action):
- type = "ignore"
-
- def run(self):
- print "XXX Cleanup: %s" % self.pkg
-
-
-class ActionScript(Action):
- def run(self):
- pass # XXX TBD
-
-
-class ActionScriptPreIn(ActionScript):
- pass
-
-
-class ActionScriptPostIn(ActionScript):
- pass
-
-
-class ActionScriptPreUn(ActionScript):
- pass
-
-
-class ActionScriptPostUn(ActionScript):
- pass
-
-
-class ActionInstall(Action):
- type = "install"
-
- def extract(self, message, prefix=None):
- logging.debug("Extracting package %s" % self.pkg.friendly_name)
-
- # Create package in the database
- self.local.add_package(self.pkg)
-
- if prefix is None:
- prefix = self.pakfire.path
-
- self.pkg.extract(message, prefix=prefix)
-
- def run(self):
- msg = _("Extracting: %s")
-
- if self.type == "install":
- msg = _("Installing: %s")
- elif self.type == "reinstall":
- msg = _("Reinstalling: %s")
- elif self.type == "upgrade":
- msg = _("Updating: %s")
- elif self.type == "downgrade":
- msg = _("Downgrading: %s")
-
- self.extract(msg % self.pkg.name)
-
-
-class ActionUpdate(ActionInstall):
- type = "upgrade"
-
-class ActionRemove(ActionCleanup):
- type = "erase"
-
- def run(self):
- files = self.pkg.filelist
-
- if not files:
- return
-
- self.remove_files(_("Removing: %s") % self.pkg.name, files)
-
-
-class ActionReinstall(ActionInstall):
- type = "reinstall"
-
-
-class ActionDowngrade(ActionInstall):
- type = "downgrade"
-
-
-class ActionChange(Action):
- type = "change"
-
- def run(self):
- print "XXX Change: %s" % self.pkg
-
+# Import all actions directly.
+from actions import *
class Transaction(object):
action_classes = [
return s
-def make_progress(message, maxval):
+
+class Bar(progressbar.Bar):
+ def update(self, pbar, width):
+ percent = pbar.percentage()
+ if pbar.finished:
+ return " " * width
+
+ cwidth = width - len(self.left) - len(self.right)
+ marked_width = int(percent * cwidth / 100)
+ m = self._format_marker(pbar)
+ bar = (self.left + (m*marked_width).ljust(cwidth) + self.right)
+ return bar
+
+def make_progress(message, maxval, eta=True):
# Return nothing if stdout is not a terminal.
if not sys.stdout.isatty():
return
" ",
"%-40s" % message,
" ",
- progressbar.Bar(left="[", right="]"),
- " ",
- progressbar.ETA(),
+ Bar(left="[", right="]"),
" ",
]
+ if eta:
+ widgets += [progressbar.ETA(), " ",]
+
if not maxval:
maxval = 1
+pakfire/actions.py
pakfire/api.py
pakfire/base.py
pakfire/builder.py
pakfire/packages/source.py
pakfire/packages/util.py
pakfire/packages/virtual.py
-pakfire/repository/actions.py
pakfire/repository/base.py
pakfire/repository/cache.py
pakfire/repository/database.py
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-21 15:40+0200\n"
+"POT-Creation-Date: 2011-07-21 16: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"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
+#: ../pakfire/actions.py:91 ../pakfire/actions.py:117
+msgid "Installing"
+msgstr ""
+
+#: ../pakfire/actions.py:98
+msgid "Updating"
+msgstr ""
+
+#: ../pakfire/actions.py:110
+#, python-format
+msgid "Removing: %s"
+msgstr ""
+
+#: ../pakfire/actions.py:124
+msgid "Downgrading"
+msgstr ""
+
#: ../pakfire/builder.py:246
#, python-format
msgid "Extracting: %s (source)"
msgid "Cleanup all temporary files."
msgstr ""
-#: ../pakfire/cli.py:234 ../pakfire/transaction.py:281
+#: ../pakfire/cli.py:234 ../pakfire/transaction.py:155
msgid "Repository"
msgstr ""
msgid "Name"
msgstr ""
-#: ../pakfire/packages/base.py:70 ../pakfire/transaction.py:280
+#: ../pakfire/packages/base.py:70 ../pakfire/transaction.py:154
msgid "Arch"
msgstr ""
-#: ../pakfire/packages/base.py:71 ../pakfire/transaction.py:280
+#: ../pakfire/packages/base.py:71 ../pakfire/transaction.py:154
msgid "Version"
msgstr ""
msgid "Release"
msgstr ""
-#: ../pakfire/packages/base.py:73 ../pakfire/transaction.py:281
+#: ../pakfire/packages/base.py:73 ../pakfire/transaction.py:155
msgid "Size"
msgstr ""
msgid "Loading installed packages"
msgstr ""
-#: ../pakfire/transaction.py:104
-#, python-format
-msgid "Extracting: %s"
-msgstr ""
-
-#: ../pakfire/transaction.py:107
-#, python-format
-msgid "Installing: %s"
-msgstr ""
-
-#: ../pakfire/transaction.py:109
-#, python-format
-msgid "Reinstalling: %s"
-msgstr ""
-
-#: ../pakfire/transaction.py:111
-#, python-format
-msgid "Updating: %s"
-msgstr ""
-
-#: ../pakfire/transaction.py:113
-#, python-format
-msgid "Downgrading: %s"
-msgstr ""
-
-#: ../pakfire/transaction.py:130
-#, python-format
-msgid "Removing: %s"
-msgstr ""
-
-#: ../pakfire/transaction.py:216
+#: ../pakfire/transaction.py:89
msgid "Downloading packages:"
msgstr ""
-#: ../pakfire/transaction.py:243
+#: ../pakfire/transaction.py:116
#, python-format
msgid "%s | %-5sB %s "
msgstr ""
-#: ../pakfire/transaction.py:280
+#: ../pakfire/transaction.py:154
msgid "Package"
msgstr ""
-#: ../pakfire/transaction.py:285
+#: ../pakfire/transaction.py:159
msgid "Installing:"
msgstr ""
-#: ../pakfire/transaction.py:286
+#: ../pakfire/transaction.py:160
msgid "Reinstalling:"
msgstr ""
-#: ../pakfire/transaction.py:287
+#: ../pakfire/transaction.py:161
msgid "Updating:"
msgstr ""
-#: ../pakfire/transaction.py:288
+#: ../pakfire/transaction.py:162
msgid "Downgrading:"
msgstr ""
-#: ../pakfire/transaction.py:289
+#: ../pakfire/transaction.py:163
msgid "Removing:"
msgstr ""
-#: ../pakfire/transaction.py:295
+#: ../pakfire/transaction.py:169
msgid "Transaction Summary"
msgstr ""
-#: ../pakfire/transaction.py:302
+#: ../pakfire/transaction.py:176
msgid "package"
msgstr ""
-#: ../pakfire/transaction.py:308
+#: ../pakfire/transaction.py:182
#, python-format
msgid "Total download size: %s"
msgstr ""
-#: ../pakfire/transaction.py:317
+#: ../pakfire/transaction.py:191
msgid "Is this okay?"
msgstr ""