From c187e828e1661d09a8437214b2f90dcc25c05c99 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 18 Nov 2005 01:01:37 +0000 Subject: * basic pkgAcquire + pkgPackageManager support added --- python/apt_pkgmodule.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'python/apt_pkgmodule.cc') diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index ce337f0f..5731cae4 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -396,6 +396,12 @@ static PyMethodDef methods[] = // Cdrom {"GetCdrom",GetCdrom,METH_VARARGS,"GetCdrom() -> Cdrom"}, + // Acquire + {"GetAcquire",GetAcquire,METH_VARARGS,"GetAcquire() -> Acquire"}, + + // PkgManager + {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager() -> PackageManager"}, + {} }; -- cgit v1.2.3 From a31cea47fc17cb55016fd52a6ab6bafe5a0857a8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Dec 2005 13:36:35 +0000 Subject: * pkgAcqFile wrapper added --- debian/changelog | 7 ++++++ doc/examples/acquire.py | 7 ++++++ python/acquire.cc | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ python/apt_pkgmodule.cc | 1 + python/apt_pkgmodule.h | 1 + 5 files changed, 83 insertions(+) (limited to 'python/apt_pkgmodule.cc') diff --git a/debian/changelog b/debian/changelog index efd6cdca..402ff2dc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.16) unstable; urgency=low + + * added GetPkgAcqFile to queue individual file downloads with the + system + + -- Michael Vogt Thu, 1 Dec 2005 14:01:39 +0100 + python-apt (0.6.15) unstable; urgency=low * rewrote cache.Commit() and make it raise proper Exception if stuff diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index 72d0c74e..2736ad9c 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -34,6 +34,13 @@ pm = apt_pkg.GetPackageManager(depcache) print pm print fetcher +af = apt_pkg.GetPkgAcqFile(fetcher, + uri="ftp://ftp.debian.org/debian/dists/README", + descr="sample descr", + destFile="/tmp/lala2") +fetcher.Run() +sys.exit(1) + pm.GetArchives(fetcher,list,recs) for item in fetcher.Items: diff --git a/python/acquire.cc b/python/acquire.cc index 2bcd94c1..03606ef2 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -208,4 +208,71 @@ PyObject *GetAcquire(PyObject *Self,PyObject *Args) + +// pkgAcquireFile + +static PyObject *AcquireFileAttr(PyObject *Self,char *Name) +{ + pkgAcqFile *acqFile = GetCpp(Self); + + PyErr_SetString(PyExc_AttributeError,Name); + return 0; +} + + + + +PyTypeObject PkgAcquireFileType = +{ + PyObject_HEAD_INIT(&PyType_Type) + 0, // ob_size + "pkgAcquireFile", // tp_name + sizeof(CppPyObject),// tp_basicsize + 0, // tp_itemsize + // Methods + CppDealloc, // tp_dealloc + 0, // tp_print + AcquireFileAttr, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash +}; + +PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) +{ + PyObject *pyfetcher; + char *uri, *md5, *descr, *shortDescr, *destDir, *destFile; + int size; + uri = md5 = descr = shortDescr = destDir = destFile = ""; + + char * kwlist[] = {"owner","uri", "md5", "size", "descr", "shortDescr", + "destDir", "destFile", NULL}; + + if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist, + &PkgAcquireType, &pyfetcher, &uri, &md5, + &size, &descr, &shortDescr, &destDir, + &destFile) == 0) + return 0; + + pkgAcquire *fetcher = GetCpp(pyfetcher); + pkgAcqFile *af = new pkgAcqFile(fetcher, // owner + uri, // uri + md5, // md5 + size, // size + descr, // descr + shortDescr, // shortdescr + destDir, // destdir + destFile // destfile + ); + CppPyObject *AcqFileObj = CppPyObject_NEW(&PkgAcquireFileType); + AcqFileObj->Object = af; + + return AcqFileObj; +} + + /*}}}*/ diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 5731cae4..e73628c3 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -398,6 +398,7 @@ static PyMethodDef methods[] = // Acquire {"GetAcquire",GetAcquire,METH_VARARGS,"GetAcquire() -> Acquire"}, + {"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS,"GetPkgAcquireFile() -> pkgAcquireFile"}, // PkgManager {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager() -> PackageManager"}, diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 93112f89..84b0069f 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -75,6 +75,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args); // acquire extern PyTypeObject PkgAcquireType; PyObject *GetAcquire(PyObject *Self,PyObject *Args); +PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject *kwds); // packagemanager extern PyTypeObject PkgManagerType; -- cgit v1.2.3