summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-11-18 11:23:10 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-11-18 11:23:10 +0000
commita56d4330c45ea9dbb9dd8babb7e8f17ae79a6fdd (patch)
tree1fabe39aa01711733a75403a9257e7bd14dc53b3
parentc187e828e1661d09a8437214b2f90dcc25c05c99 (diff)
downloadpython-apt-a56d4330c45ea9dbb9dd8babb7e8f17ae79a6fdd.tar.gz
* acquire interface works with progress reporting now
-rw-r--r--doc/examples/acquire.py10
-rw-r--r--python/acquire.cc16
2 files changed, 24 insertions, 2 deletions
diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py
index 12727232..98b70ab0 100644
--- a/doc/examples/acquire.py
+++ b/doc/examples/acquire.py
@@ -1,4 +1,6 @@
+import apt
import apt_pkg
+import os
apt_pkg.init()
@@ -9,10 +11,16 @@ recs = apt_pkg.GetPkgRecords(cache)
list = apt_pkg.GetPkgSourceList()
list.ReadMainList()
+os.mkdir("/tmp/pyapt-test")
+os.mkdir("/tmp/pyapt-test/partial")
+apt_pkg.Config.Set("Dir::Cache::archives","/tmp/pyapt-test")
+
pkg = cache["3ddesktop"]
depcache.MarkInstall(pkg)
-fetcher = apt_pkg.GetAcquire()
+progress = apt.progress.TextFetchProgress()
+fetcher = apt_pkg.GetAcquire(progress)
+#fetcher = apt_pkg.GetAcquire()
pm = apt_pkg.GetPackageManager(depcache)
print pm
diff --git a/python/acquire.cc b/python/acquire.cc
index 550deb0e..ff01b659 100644
--- a/python/acquire.cc
+++ b/python/acquire.cc
@@ -9,6 +9,7 @@
#include "generic.h"
#include "apt_pkgmodule.h"
#include "acquire.h"
+#include "progress.h"
#include <apt-pkg/acquire-item.h>
@@ -92,7 +93,20 @@ PyTypeObject PkgAcquireType =
PyObject *GetAcquire(PyObject *Self,PyObject *Args)
{
- pkgAcquire *fetcher = new pkgAcquire();
+ pkgAcquire *fetcher;
+
+ PyObject *pyFetchProgressInst = NULL;
+ if (PyArg_ParseTuple(Args,"|O",&pyFetchProgressInst) == 0)
+ return 0;
+
+ if (pyFetchProgressInst != NULL) {
+ // FIXME: memleak?
+ PyFetchProgress *progress = new PyFetchProgress();
+ progress->setCallbackInst(pyFetchProgressInst);
+ fetcher = new pkgAcquire(progress);
+ } else {
+ fetcher = new pkgAcquire();
+ }
CppOwnedPyObject<pkgAcquire> *FetcherObj =
CppOwnedPyObject_NEW<pkgAcquire>(0,&PkgAcquireType, *fetcher);