diff options
| author | Emanuele Rocca <ema@debian.org> | 2008-10-04 21:59:16 +0200 |
|---|---|---|
| committer | Emanuele Rocca <ema@debian.org> | 2008-10-04 21:59:16 +0200 |
| commit | 825ead499fa2f385c2cb0876316424b0595c0d3c (patch) | |
| tree | b2527f103906b9e9ce63998d1db65d1c7b84fd2f /python | |
| parent | 13caebe03934e6e66e9096044181d3aa683b5705 (diff) | |
| parent | 3bc4cc400ef9a6994e3ed51526811bfa2acd9927 (diff) | |
| download | python-apt-825ead499fa2f385c2cb0876316424b0595c0d3c.tar.gz | |
Merged Michael's changes
Diffstat (limited to 'python')
| -rw-r--r-- | python/apt_instmodule.cc | 13 | ||||
| -rw-r--r-- | python/apt_pkgmodule.cc | 6 | ||||
| -rw-r--r-- | python/cache.cc | 2 | ||||
| -rw-r--r-- | python/depcache.cc | 6 | ||||
| -rw-r--r-- | python/progress.cc | 6 |
5 files changed, 25 insertions, 8 deletions
diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 43d5e7f7..ea703b21 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -74,6 +74,7 @@ static char *doc_debExtractArchive = static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { char *Rootdir = NULL; + char cwd[512]; PyObject *File; if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0) return 0; @@ -83,21 +84,27 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { if(Rootdir != NULL) { + getcwd(cwd, sizeof(cwd)); chdir(Rootdir); } // Open the file and associate the .deb FileFd Fd(fileno(PyFile_AsFile(File)),false); debDebFile Deb(Fd); - if (_error->PendingError() == true) - return HandleErrors(); + if (_error->PendingError() == true) { + if (Rootdir != NULL) + chdir (cwd); + return HandleErrors(Py_BuildValue("b",false)); + } // extracts relative to the current dir pkgDirStream Extract; res = Deb.ExtractArchive(Extract); + if (Rootdir != NULL) + chdir (cwd); if (res == false) - return HandleErrors(); + return HandleErrors(Py_BuildValue("b",res)); } return HandleErrors(Py_BuildValue("b",res)); } diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index fd7a83cd..fae85f00 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -517,6 +517,12 @@ extern "C" void initapt_pkg() AddInt(Dict,"CurStateConfigFiles",pkgCache::State::ConfigFiles); AddInt(Dict,"CurStateInstalled",pkgCache::State::Installed); + AddInt(Dict,"SelStateUnknown",pkgCache::State::Unknown); + AddInt(Dict,"SelStateInstall",pkgCache::State::Install); + AddInt(Dict,"SelStateHold",pkgCache::State::Hold); + AddInt(Dict,"SelStateDeInstall",pkgCache::State::DeInstall); + AddInt(Dict,"SelStatePurge",pkgCache::State::Purge); + AddInt(Dict,"InstStateOk",pkgCache::State::Ok); AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); diff --git a/python/cache.cc b/python/cache.cc index 66a2c5d9..bd280dec 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -599,7 +599,7 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) else if (strcmp("Priority",Name) == 0) return Py_BuildValue("i",Ver->Priority); else if (strcmp("PriorityStr",Name) == 0) - return PyString_FromString(Ver.PriorityType()); + return Safe_FromString(Ver.PriorityType()); else if (strcmp("Downloadable", Name) == 0) return Py_BuildValue("b", Ver.Downloadable()); else if (strcmp("TranslatedDescription", Name) == 0) { diff --git a/python/depcache.cc b/python/depcache.cc index 5664a6d8..2446dc71 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -197,7 +197,7 @@ static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); - pkgCache::VerIterator I = GetCpp<pkgCache::VerIterator>(VersionObj); + pkgCache::VerIterator &I = GetCpp<pkgCache::VerIterator>(VersionObj); if(I.end()) { return HandleErrors(Py_BuildValue("b",false)); } @@ -215,7 +215,9 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); - pkgCache::VerIterator I = depcache->GetCandidateVer(Pkg); + pkgDepCache::StateCache & State = (*depcache)[Pkg]; + pkgCache::VerIterator I = State.CandidateVerIter(*depcache); + if(I.end()) { Py_INCREF(Py_None); return Py_None; diff --git a/python/progress.cc b/python/progress.cc index 793265db..99ad0a25 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -185,8 +185,10 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) bool res = true; if(!PyArg_Parse(result, "b", &res)) { - // mvo: this is harmless, we shouldn't print anything here - //std::cerr << "result could not be parsed" << std::endl; + // most of the time the user who subclasses the pulse() + // method forgot to add a return {True,False} so we just + // assume he wants a True + return true; } // fetching can be canceld by returning false |
