summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-10-20 14:16:10 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-10-20 14:16:10 +0000
commitdbab2dd1c1360837ebd524bcc1bb378534210426 (patch)
tree3da5c5c476e0ced5e2ee1a14cd53c4734c65262d /python
parente608d6106a75a678fe121afd8020073b9ba80836 (diff)
downloadpython-apt-dbab2dd1c1360837ebd524bcc1bb378534210426.tar.gz
* progress interface fully working now, commit interface too
Diffstat (limited to 'python')
-rw-r--r--python/apt_pkgmodule.cc3
-rw-r--r--python/depcache.cc39
-rw-r--r--python/progress.cc13
-rw-r--r--python/progress.h6
4 files changed, 26 insertions, 35 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..fb506c96 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -27,6 +27,9 @@
#include <iostream>
#include "progress.h"
+#ifndef _
+#define _(x) (x)
+#endif
@@ -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/progress.cc b/python/progress.cc
index fb56ea87..5267134f 100644
--- a/python/progress.cc
+++ b/python/progress.cc
@@ -9,6 +9,7 @@
#include <iostream>
#include <sys/types.h>
#include <sys/wait.h>
+#include <apt-pkg/acquire-item.h>
#include "progress.h"
@@ -75,9 +76,6 @@ void PyOpProgress::Done()
// fetcher interface
-enum {
- DLDone, DLQueued, DLFailed, DLHit
-};
// apt interface
@@ -122,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);
}
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