summaryrefslogtreecommitdiff
path: root/python/progress.cc
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 /python/progress.cc
parent5ab4ad5865fab22f9b8d90bf4ab1a73e8bba0dce (diff)
downloadpython-apt-a567392950a174ccb85c7f6c5c4ad8de7c37773d.tar.gz
* added Current{CPS,Bytes,Items}, Total{Bytes,Items} to the fetch object
Diffstat (limited to 'python/progress.cc')
-rw-r--r--python/progress.cc21
1 files changed, 17 insertions, 4 deletions
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);