summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/progress/__init__.py25
-rw-r--r--debian/changelog14
-rw-r--r--doc/examples/progress.py20
-rw-r--r--po/python-apt.pot2
-rw-r--r--python/progress.cc18
5 files changed, 69 insertions, 10 deletions
diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py
index 68441cfa..3be197f7 100644
--- a/apt/progress/__init__.py
+++ b/apt/progress/__init__.py
@@ -107,14 +107,20 @@ class FetchProgress(object):
def stop(self):
"""Called when all files have been fetched."""
- def updateStatus(self, uri, descr, shortDescr, status, fileSize,
- partialSize):
+ def updateStatus(self, uri, descr, shortDescr, status):
"""Called when the status of an item changes.
This happens eg. when the downloads fails or is completed.
"""
+ def update_status_full(self, uri, descr, short_descr, status, file_size,
+ partial_size):
+ """Called when the status of an item changes.
+
+ This happens eg. when the downloads fails or is completed. This
+ version include information on current filesize and partial size
+ """
- def pulse(self, items):
+ def pulse(self):
"""Called periodically to update the user interface.
Return True to continue or False to cancel.
@@ -126,6 +132,19 @@ class FetchProgress(object):
float(self.currentCPS))
return True
+ def pulse_items(self, items):
+ """Called periodically to update the user interface.
+ This function includes details about the items being fetched
+ Return True to continue or False to cancel.
+
+ """
+ self.percent = (((self.currentBytes + self.currentItems) * 100.0) /
+ float(self.totalBytes + self.totalItems))
+ if self.currentCPS > 0:
+ self.eta = ((self.totalBytes - self.currentBytes) /
+ float(self.currentCPS))
+ return True
+
def mediaChange(self, medium, drive):
"""react to media change events."""
diff --git a/debian/changelog b/debian/changelog
index 83b00150..a3faab79 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
+python-apt (0.7.10.4) UNRELEASED; urgency=low
+
+ [ Stephan Peijnik ]
+ * apt/progress/__init__.py:
+ - add update_status_full() that takes file_size/partial_size as
+ additional callback arguments
+ - add pulse_items() that takes a addtional "items" tuple that
+ gives the user full access to the individual items that are
+ fetched
+ * python/progress.cc:
+ - low level code for update_status_full and pulse_items()
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 05 May 2009 11:57:57 +0200
+
python-apt (0.7.10.3) unstable; urgency=low
* apt/package.py: Handle cases where no candidate is available, by returning
diff --git a/doc/examples/progress.py b/doc/examples/progress.py
index f7650f69..c007681f 100644
--- a/doc/examples/progress.py
+++ b/doc/examples/progress.py
@@ -34,12 +34,22 @@ class TextFetchProgress(apt.FetchProgress):
def stop(self):
pass
- def updateStatus(self, uri, descr, shortDescr, status, fileSize,
- partialSize):
- print "UpdateStatus: '%s' '%s' '%s' '%i' '%d/%d'" % (
+ def updateStatus(self, uri, descr, shortDescr, status):
+ print "UpdateStatus: '%s' '%s' '%s' '%i' " % (
+ uri, descr, shortDescr, status)
+
+ def update_status_full(self, uri, descr, shortDescr, status, fileSize,
+ partialSize):
+ print "update_status_full: '%s' '%s' '%s' '%i' '%d/%d'" % (
uri, descr, shortDescr, status, partialSize, fileSize)
- def pulse(self, items):
+ def pulse(self):
+ print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (
+ apt.SizeToStr(self.currentCPS), apt.SizeToStr(self.currentBytes),
+ apt.SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
+ return True
+
+ def pulse_items(self, items):
print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (
apt.SizeToStr(self.currentCPS), apt.SizeToStr(self.currentBytes),
apt.SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
@@ -47,7 +57,7 @@ class TextFetchProgress(apt.FetchProgress):
for itm in items:
uri, descr, shortDescr, fileSize, partialSize = itm
print " - '%s' '%s' '%s' '%d/%d'" % (
- uri, descr, shortDescr, partialSize, fileSize
+ uri, descr, shortDescr, partialSize, fileSize)
return True
def mediaChange(self, medium, drive):
diff --git a/po/python-apt.pot b/po/python-apt.pot
index 27f7e1af..2a004600 100644
--- a/po/python-apt.pot
+++ b/po/python-apt.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-04-30 12:52+0200\n"
+"POT-Creation-Date: 2009-05-05 11:44+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"
diff --git a/python/progress.cc b/python/progress.cc
index a30ea2e7..14948d3c 100644
--- a/python/progress.cc
+++ b/python/progress.cc
@@ -120,7 +120,15 @@ void PyFetchProgress::UpdateStatus(pkgAcquire::ItemDesc &Itm, int status)
Itm.Owner->FileSize,
Itm.Owner->PartialSize);
+ RunSimpleCallback("update_status_full", arglist);
+
+ // legacy version of the interface
+ arglist = Py_BuildValue("(sssi)", Itm.URI.c_str(),
+ Itm.Description.c_str(),
+ Itm.ShortDesc.c_str(),
+ status);
RunSimpleCallback("updateStatus", arglist);
+
}
void PyFetchProgress::IMSHit(pkgAcquire::ItemDesc &Itm)
@@ -274,11 +282,19 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner)
}
PyObject *result;
+ bool res = true;
+
+ RunSimpleCallback("pulse_items", arglist, &result);
+ if (result != NULL && PyArg_Parse(result, "b", &res) && res == false) {
+ // the user returned a explicit false here, stop
+ return false;
+ }
+
+ arglist = Py_BuildValue("()");
if (!RunSimpleCallback("pulse", arglist, &result)) {
return true;
}
- bool res = true;
if((result == NULL) || (!PyArg_Parse(result, "b", &res)))
{
// most of the time the user who subclasses the pulse()