summaryrefslogtreecommitdiff
path: root/python/progress.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2005-10-21 21:07:38 +0000
committerMichael Vogt <mvo@debian.org>2005-10-21 21:07:38 +0000
commitf701fc174a88d8f2b418a032571ff40ed6fd56e6 (patch)
treed2a0ebed225e24207c952430390a51d3628a03fb /python/progress.cc
parent76bf6920764c1a9a67586d23743f31311b66b811 (diff)
parentbd6df1d8419eb3403e64191681b32fbd1f3accac (diff)
downloadpython-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/progress.cc')
-rw-r--r--python/progress.cc26
1 files changed, 21 insertions, 5 deletions
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();