From 2fa652df49918cbfd8def4868b327bab3b30feb9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 18 Nov 2005 12:01:37 +0000 Subject: * added stat constants to the acquire-item interface --- doc/examples/acquire.py | 6 +++++- python/acquire.cc | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index f920e5e9..0031fa18 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -16,7 +16,7 @@ try: os.mkdir("/tmp/pyapt-test/partial") except OSError: pass -apt_pkg.Config.Set("Dir::Cache::archives","/tmp/pyapt-test") +#apt_pkg.Config.Set("Dir::Cache::archives","/tmp/pyapt-test") pkg = cache["3ddesktop"] depcache.MarkInstall(pkg) @@ -37,6 +37,10 @@ for item in fetcher.Items: item.Status, item.Complete, item.IsTrusted) + if item.Status == item.StatError: + print "Some error ocured: '%s'" % item.ErrorText + if item.Complete == False: + print "No error, still nothing downloaded" print diff --git a/python/acquire.cc b/python/acquire.cc index a65b9592..91d75a6b 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -36,6 +36,18 @@ static PyObject *AcquireItemAttr(PyObject *Self,char *Name) return Safe_FromString((*I)->DestFile.c_str()); else if (strcmp("DescURI",Name) == 0) return Safe_FromString((*I)->DescURI().c_str()); + // constants + else if (strcmp("StatIdle",Name) == 0) + return Py_BuildValue("i", pkgAcquire::Item::StatIdle); + else if (strcmp("StatFetching",Name) == 0) + return Py_BuildValue("i", pkgAcquire::Item::StatFetching); + else if (strcmp("StatDone",Name) == 0) + return Py_BuildValue("i", pkgAcquire::Item::StatDone); + else if (strcmp("StatError",Name) == 0) + return Py_BuildValue("i", pkgAcquire::Item::StatError); + else if (strcmp("StatAuthError",Name) == 0) + return Py_BuildValue("i", pkgAcquire::Item::StatAuthError); + PyErr_SetString(PyExc_AttributeError,Name); return 0; -- cgit v1.2.3