summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-04-07 09:23:19 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-04-07 09:23:19 +0000
commita567392950a174ccb85c7f6c5c4ad8de7c37773d (patch)
tree238af6fa07544673af8a97bf7e309ff1e914bfe9
parent5ab4ad5865fab22f9b8d90bf4ab1a73e8bba0dce (diff)
downloadpython-apt-a567392950a174ccb85c7f6c5c4ad8de7c37773d.tar.gz
* added Current{CPS,Bytes,Items}, Total{Bytes,Items} to the fetch object
-rw-r--r--debian/changelog2
-rw-r--r--doc/examples/action.py4
-rw-r--r--python/progress.cc21
3 files changed, 20 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog
index a38deb59..f8593cda 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,7 +3,7 @@ python-apt (0.5.36ubuntu3) hoary; urgency=low
* fixed some reference count problems in the depcache code
* DepCache.Init() is never called implicit now
- --
+ -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 7 Apr 2005 10:20:30 +0200
python-apt (0.5.36ubuntu2) hoary; urgency=low
diff --git a/doc/examples/action.py b/doc/examples/action.py
index d3cddbc4..e19025a6 100644
--- a/doc/examples/action.py
+++ b/doc/examples/action.py
@@ -25,8 +25,8 @@ class OpProgress:
class FetchProgress:
def __init__(self):
pass
- def Pulse(self, CurrentCPS, CurrentBytes, CurrentItems):
- print "Pulse: CPS: %s Bytes: %s Item: %s" % (CurrentCPS, CurrentBytes, CurrentItems)
+ def Pulse(self):
+ print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (apt_pkg.SizeToStr(self.CurrentCPS), apt_pkg.SizeToStr(self.CurrentBytes), apt_pkg.SizeToStr(self.TotalBytes), self.CurrentItems, self.TotalItems)
diff --git a/python/progress.cc b/python/progress.cc
index 75c531fe..c6f56ed1 100644
--- a/python/progress.cc
+++ b/python/progress.cc
@@ -112,18 +112,31 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner)
if(callbackInst == 0)
return false;
- // Build up the argument list...
- PyObject *arglist = Py_BuildValue("(ffi)", CurrentCPS, CurrentBytes, CurrentItems);
+ // set stats
+ PyObject *o;
+ o = Py_BuildValue("f", CurrentCPS);
+ PyObject_SetAttrString(callbackInst, "CurrentCPS", o);
+ o = Py_BuildValue("f", CurrentBytes);
+ PyObject_SetAttrString(callbackInst, "CurrentBytes", o);
+ o = Py_BuildValue("i", CurrentItems);
+ PyObject_SetAttrString(callbackInst, "CurrentItems", o);
+ o = Py_BuildValue("i", TotalItems);
+ PyObject_SetAttrString(callbackInst, "TotalItems", o);
+ o = Py_BuildValue("f", TotalBytes);
+ PyObject_SetAttrString(callbackInst, "TotalBytes", o);
- // ...for calling the Python compare function.
+ // Call the pulse method
+ PyObject *arglist = Py_BuildValue("()");
PyObject *method = PyObject_GetAttrString(callbackInst, "Pulse");
if(method == NULL) {
// FIXME: make this silent
+ std::cerr << "Can't find 'Pulse' method" << std::endl;
Py_DECREF(arglist);
return false;
}
PyObject *result = PyEval_CallObject(method,arglist);
-
+ // FIXME: throw some exception here if the method was unsuccessfull
+
Py_XDECREF(result);
Py_XDECREF(method);
Py_DECREF(arglist);