diff options
| author | Michael Vogt <mvo@debian.org> | 2005-10-21 21:07:38 +0000 |
|---|---|---|
| committer | Michael Vogt <mvo@debian.org> | 2005-10-21 21:07:38 +0000 |
| commit | f701fc174a88d8f2b418a032571ff40ed6fd56e6 (patch) | |
| tree | d2a0ebed225e24207c952430390a51d3628a03fb /python | |
| parent | 76bf6920764c1a9a67586d23743f31311b66b811 (diff) | |
| parent | bd6df1d8419eb3403e64191681b32fbd1f3accac (diff) | |
| download | python-apt-f701fc174a88d8f2b418a032571ff40ed6fd56e6.tar.gz | |
* merged with apt--mvo
Patches applied:
* michael.vogt@ubuntu.com--2005/python-apt--mvo--0--patch-77
* merged with the progress reporting code
* michael.vogt@ubuntu.com--2005/python-apt--mvo--0--patch-78
* progress interface fully working now, commit interface too
* michael.vogt@ubuntu.com--2005/python-apt--mvo--0--patch-79
* fix a crasher in the install interface
* michael.vogt@ubuntu.com--2005/python-apt--progress-reporting--0--base-0
tag of michael.vogt@ubuntu.com--2005/python-apt--mvo--0--patch-43
* michael.vogt@ubuntu.com--2005/python-apt--progress-reporting--0--patch-1
* support the apt--progress-reporting--0 branch (using "InstallProgress.statusfd)
* michael.vogt@ubuntu.com--2005/python-apt--progress-reporting--0--patch-2
* support for update reporting via vte/progress bars added, including a evil "pass-me-my-file-descriptor" hack
* michael.vogt@ubuntu.com--2005/python-apt--progress-reporting--0--patch-3
* merged with python-apt--mvo
* michael.vogt@ubuntu.com--2005/python-apt--progress-reporting--0--patch-4
* merged from python-apt--mvo
* michael.vogt@ubuntu.com--2005/python-apt--progress-reporting--0--patch-5
* better support new python-apt, added example for gui-inst with support for VTE_PTY_KEEP_FD
* michael.vogt@ubuntu.com--2005/python-apt--progress-reporting--0--patch-6
* removed the fdsend stuff again, libvte will be patched instead
Diffstat (limited to 'python')
| -rw-r--r-- | python/apt_pkgmodule.cc | 3 | ||||
| -rw-r--r-- | python/depcache.cc | 41 | ||||
| -rw-r--r-- | python/makefile | 1 | ||||
| -rw-r--r-- | python/progress.cc | 26 | ||||
| -rw-r--r-- | python/progress.h | 6 |
5 files changed, 39 insertions, 38 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 9a3aac37..ce337f0f 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -449,14 +449,13 @@ extern "C" void initapt_pkg() AddInt(Dict,"DepConflicts",pkgCache::Dep::Conflicts); AddInt(Dict,"DepReplaces",pkgCache::Dep::Replaces); AddInt(Dict,"DepObsoletes",pkgCache::Dep::Obsoletes); - + AddInt(Dict,"PriImportant",pkgCache::State::Important); AddInt(Dict,"PriRequired",pkgCache::State::Required); AddInt(Dict,"PriStandard",pkgCache::State::Standard); AddInt(Dict,"PriOptional",pkgCache::State::Optional); AddInt(Dict,"PriExtra",pkgCache::State::Extra); - } /*}}}*/ diff --git a/python/depcache.cc b/python/depcache.cc index 418ddd14..c78d0077 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -27,6 +27,9 @@ #include <iostream> #include "progress.h" +#ifndef _ +#define _(x) (x) +#endif @@ -96,7 +99,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) return HandleErrors(); } - std::cout << "PM created" << std::endl; + //std::cout << "PM created" << std::endl; PyInstallProgress iprogress; iprogress.setCallbackInst(pyInstallProgressInst); @@ -124,15 +127,16 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) continue; } - //FIXME: report this error somehow -// fprintf(stderr,_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), -// (*I)->ErrorText.c_str()); + _error->Warning(_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), + (*I)->ErrorText.c_str()); Failed = true; } -#if 0 // check that stuff if (Transient == true && Failed == true) - return Py_None; /*_error->Error(_("--fix-missing and media swapping is not currently supported"));*/ + { + _error->Error(_("--fix-missing and media swapping is not currently supported")); + return HandleErrors(Py_None); + } // Try to deal with missing package files if (Failed == true && PM->FixMissing() == false) @@ -141,7 +145,6 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) _error->Error("Aborting install."); return HandleErrors(Py_None); } -#endif _system->UnLock(); @@ -164,29 +167,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) } _system->Lock(); } - - - -#if 0 - if (Fetcher.Run() == pkgAcquire::Failed) - return HandleErrors(Py_None); - - std::cout << "Fetcher was run" << std::endl; - - // FIXME: incomplete, see apt-get.cc - _system->UnLock(); - - pkgPackageManager::OrderResult Res = PM->DoInstall(); - if (Res == pkgPackageManager::Failed || _error->PendingError() == true) - return Py_None/*false;*/; - if (Res == pkgPackageManager::Completed) - return Py_None /*true;*/; - - _system->Lock(); -#endif - - // FIXME: open the cache here again - + return HandleErrors(Py_None); } diff --git a/python/makefile b/python/makefile index 273096a7..16bfcd88 100644 --- a/python/makefile +++ b/python/makefile @@ -22,3 +22,4 @@ LIB_MAKES = apt-inst/makefile APT_INST_SRC = apt_instmodule.cc tar.cc generic.cc SOURCE := $(APT_INST_SRC) include $(PYTHON_H) + diff --git a/python/progress.cc b/python/progress.cc index f79090f7..12f9c7a8 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -9,8 +9,10 @@ #include <iostream> #include <sys/types.h> #include <sys/wait.h> +#include <apt-pkg/acquire-item.h> #include "progress.h" + // generic bool PyCallbackObj::RunSimpleCallback(const char* method_name, PyObject *arglist, @@ -74,9 +76,6 @@ void PyOpProgress::Done() // fetcher interface -enum { - DLDone, DLQueued, DLFailed, DLHit -}; // apt interface @@ -121,6 +120,15 @@ void PyFetchProgress::Done(pkgAcquire::ItemDesc &Itm) void PyFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) { + // Ignore certain kinds of transient failures (bad code) + if (Itm.Owner->Status == pkgAcquire::Item::StatIdle) + return; + + if (Itm.Owner->Status == pkgAcquire::Item::StatDone) + { + UpdateStatus(Itm, DLIgnored); + } + UpdateStatus(Itm, DLFailed); } @@ -220,7 +228,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) return pkgPackageManager::Failed; } if(!PyArg_Parse(result, "i", &child_id) ) - std::cerr << "result could not be parsed?"<< std::endl; + std::cerr << "custom fork() result could not be parsed?"<< std::endl; //std::cerr << "got: " << child_id << std::endl; } else { //std::cerr << "using build-in fork()" << std::endl; @@ -235,10 +243,18 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) } #endif if (child_id == 0) { - res = pm->DoInstall(); + PyObject *v = PyObject_GetAttrString(callbackInst, "writefd"); + if(v) { + int fd = PyObject_AsFileDescriptor(v); + cout << "got fd: " << fd << endl; + res = pm->DoInstall(fd); + } else { + res = pm->DoInstall(); + } _exit(res); } + StartUpdate(); while (waitpid(child_id, &ret, WNOHANG) == 0) UpdateInterface(); diff --git a/python/progress.h b/python/progress.h index f116c811..f04bd683 100644 --- a/python/progress.h +++ b/python/progress.h @@ -15,6 +15,7 @@ #include <apt-pkg/cdrom.h> #include <Python.h> + class PyCallbackObj { protected: PyObject *callbackInst; @@ -44,6 +45,10 @@ struct PyOpProgress : public OpProgress, public PyCallbackObj struct PyFetchProgress : public pkgAcquireStatus, public PyCallbackObj { + enum { + DLDone, DLQueued, DLFailed, DLHit, DLIgnored + }; + void UpdateStatus(pkgAcquire::ItemDesc & Itm, int status); virtual bool MediaChange(string Media, string Drive); @@ -58,7 +63,6 @@ struct PyFetchProgress : public pkgAcquireStatus, public PyCallbackObj bool Pulse(pkgAcquire * Owner); PyFetchProgress() : PyCallbackObj() {}; - }; struct PyInstallProgress : public PyCallbackObj |
