From b7ce3c2b47e1234631e00cb0ba8a86fa0aa9c8d8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 10:08:44 +0200 Subject: * python/apt_pkgmodule.cc: - add apt_pkg.get_architectures() call --- python/apt_pkgmodule.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'python/apt_pkgmodule.cc') diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e8490b4e..03c88e9a 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -393,6 +394,29 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) return 0; } /*}}}*/ +// get_architectures - return the list of architectures /*{{{*/ +// --------------------------------------------------------------------- +static const char *doc_GetArchitectures = + "get_architectures() -> list\n\n" + "Return the list of supported architectures on this system. On a \n" + "multiarch system this can be more than one.";; +static PyObject *GetArchitectures(PyObject *Self,PyObject *Args) +{ + PyObject *Obj; + if (PyArg_ParseTuple(Args,"",&Obj) == 0) + return 0; + + PyObject *List = PyList_New(0); + vector arches = APT::Configuration::getArchitectures(); + vector::const_iterator I; + for (I = arches.begin(); I != arches.end(); I++) + { + PyList_Append(List, CppPyString(*I)); + } + + return List; +} + /*}}}*/ // init - 3 init functions /*{{{*/ // --------------------------------------------------------------------- static char *doc_Init = @@ -539,6 +563,9 @@ static PyMethodDef methods[] = {"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum}, {"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum}, + // multiarch + {"get_architectures", GetArchitectures, METH_VARARGS, doc_GetArchitectures}, + // Strings {"check_domain_list",StrCheckDomainList,METH_VARARGS, "check_domain_list(host: str, domains: str) -> bool\n\n" -- cgit v1.2.3 From d7c8f470a236d70fa6ce8eb0e522702fee64ff5e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 10:11:02 +0200 Subject: python/apt_pkgmodule.cc: improve docstring --- po/python-apt.pot | 2 +- python/apt_pkgmodule.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'python/apt_pkgmodule.cc') diff --git a/po/python-apt.pot b/po/python-apt.pot index 48b4fb18..d19871d0 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-21 10:05+0200\n" +"POT-Creation-Date: 2011-10-21 10:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 03c88e9a..8532b1e3 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -399,7 +399,8 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) static const char *doc_GetArchitectures = "get_architectures() -> list\n\n" "Return the list of supported architectures on this system. On a \n" - "multiarch system this can be more than one.";; + "multiarch system this can be more than one. The main architectures\n" + "is the first item in the list.";; static PyObject *GetArchitectures(PyObject *Self,PyObject *Args) { PyObject *Obj; -- cgit v1.2.3 From 628d7caf9ca6ee819398a4b88c23e42094fe2c10 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Nov 2011 17:20:58 +0100 Subject: fix build against apt in experimental --- debian/changelog | 1 + po/python-apt.pot | 2 +- python/apt_pkgmodule.cc | 11 ++++++----- python/apt_pkgmodule.h | 1 + python/arfile.cc | 8 ++++---- python/cdrom.cc | 4 ++-- python/configuration.cc | 2 +- python/depcache.cc | 1 + python/lock.cc | 2 ++ python/metaindex.cc | 4 ++-- python/progress.cc | 14 +++++++------- python/progress.h | 6 +++--- python/tag.cc | 1 + python/tarfile.cc | 2 +- tests/test_debfile.py | 13 ++++++++++++- 15 files changed, 45 insertions(+), 27 deletions(-) (limited to 'python/apt_pkgmodule.cc') diff --git a/debian/changelog b/debian/changelog index f5ae2b79..58326dc2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ python-apt (0.8.2) UNRELEASED; urgency=low * apt/cache.py: - remove "print" when creating dirs in apt.Cache(rootdir=dir), thanks to Martin Pitt + * fix build against apt in experimental [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) diff --git a/po/python-apt.pot b/po/python-apt.pot index d19871d0..046f5779 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-21 10:10+0200\n" +"POT-Creation-Date: 2011-11-10 17:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 8532b1e3..acfdf019 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -185,11 +186,11 @@ static const char *parse_src_depends_doc = "only contains those dependencies for the architecture set in the\n" "configuration variable APT::Architecture"; static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, - bool ParseArchFlags, string name, + bool ParseArchFlags, std::string name, bool debStyle=false) { - string Package; - string Version; + std::string Package; + std::string Version; unsigned int Op; bool StripMultiArch=true; @@ -408,8 +409,8 @@ static PyObject *GetArchitectures(PyObject *Self,PyObject *Args) return 0; PyObject *List = PyList_New(0); - vector arches = APT::Configuration::getArchitectures(); - vector::const_iterator I; + std::vector arches = APT::Configuration::getArchitectures(); + std::vector::const_iterator I; for (I = arches.begin(); I != arches.end(); I++) { PyList_Append(List, CppPyString(*I)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index b3534a30..85c34130 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "generic.h" // Configuration Stuff diff --git a/python/arfile.cc b/python/arfile.cc index c31ea35e..44cd3c82 100644 --- a/python/arfile.cc +++ b/python/arfile.cc @@ -204,7 +204,7 @@ static PyObject *_extract(FileFd &Fd, const ARArchive::Member *member, if (!Fd.Seek(member->Start)) return HandleErrors(); - string outfile_str = flCombine(dir,member->Name); + std::string outfile_str = flCombine(dir,member->Name); char *outfile = (char*)outfile_str.c_str(); // We are not using FileFd here, because we want to raise OSErrror with @@ -539,8 +539,8 @@ static PyObject *debfile_new(PyTypeObject *type, PyObject *args, PyObject *kwds) for (std::vector::const_iterator t = types.begin(); t != types.end(); ++t) { - string member = string("data.tar.").append(*t); - string comp = _config->Find(string("Acquire::CompressionTypes::").append(*t)); + std::string member = std::string("data.tar.").append(*t); + std::string comp = _config->Find(std::string("Acquire::CompressionTypes::").append(*t)); self->data = _gettar(self, self->Object->FindMember(member.c_str()), comp.c_str()); if (self->data) @@ -548,7 +548,7 @@ static PyObject *debfile_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } // no data found, we need to if (!self->data) { - string error; + std::string error; for (std::vector::const_iterator t = types.begin(); t != types.end(); ++t) error.append(*t + ","); diff --git a/python/cdrom.cc b/python/cdrom.cc index 6ac16d59..46bb769c 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -67,7 +67,7 @@ static PyObject *cdrom_ident(PyObject *Self,PyObject *Args) PyCdromProgress progress; progress.setCallbackInst(pyCdromProgressInst); - string ident; + std::string ident; bool res = Cdrom.Ident(ident, &progress); if (res) @@ -94,7 +94,7 @@ static PyObject *cdrom_ident_old(PyObject *Self,PyObject *Args) PyCdromProgress progress; progress.setCallbackInst(pyCdromProgressInst); - string ident; + std::string ident; bool res = Cdrom.Ident(ident, &progress); PyObject *boolres = PyBool_FromLong(res); diff --git a/python/configuration.cc b/python/configuration.cc index 9000f71f..3e634901 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -262,7 +262,7 @@ static PyObject *CnfDump(PyObject *Self,PyObject *Args) if (PyArg_ParseTuple(Args,"") == 0) return 0; - stringstream ss; + std::stringstream ss; GetSelf(Self).Dump(ss); return CppPyString(ss.str()); } diff --git a/python/depcache.cc b/python/depcache.cc index e6113429..73993c82 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/python/lock.cc b/python/lock.cc index 2c957df1..38a2bc74 100644 --- a/python/lock.cc +++ b/python/lock.cc @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "generic.h" static PyObject *systemlock_exit(PyObject *self, PyObject *args) diff --git a/python/metaindex.cc b/python/metaindex.cc index a00cf04e..9e330d3d 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -33,8 +33,8 @@ static PyObject *MetaIndexGetIsTrusted(PyObject *Self,void*) { static PyObject *MetaIndexGetIndexFiles(PyObject *Self,void*) { metaIndex *meta = GetCpp(Self); PyObject *List = PyList_New(0); - vector *indexFiles = meta->GetIndexFiles(); - for (vector::const_iterator I = indexFiles->begin(); + std::vector *indexFiles = meta->GetIndexFiles(); + for (std::vector::const_iterator I = indexFiles->begin(); I != indexFiles->end(); I++) { CppPyObject *Obj; diff --git a/python/progress.cc b/python/progress.cc index bd3c2ad6..a7fd7ae1 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -127,7 +127,7 @@ PyObject *PyFetchProgress::GetDesc(pkgAcquire::ItemDesc *item) { return pyDesc; } -bool PyFetchProgress::MediaChange(string Media, string Drive) +bool PyFetchProgress::MediaChange(std::string Media, std::string Drive) { PyCbObj_END_ALLOW_THREADS //std::cout << "MediaChange" << std::endl; @@ -485,7 +485,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) PyObject *v = PyObject_GetAttrString(callbackInst, "writefd"); if(v) { int fd = PyObject_AsFileDescriptor(v); - cout << "got fd: " << fd << endl; + std::cout << "got fd: " << fd << std::endl; res = pm->DoInstall(fd); } else { res = pm->DoInstall(); @@ -542,7 +542,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) //----------------------------------------------------------------------------- // apt-cdrom interface -void PyCdromProgress::Update(string text, int current) +void PyCdromProgress::Update(std::string text, int current) { PyObject *arglist = Py_BuildValue("(si)", text.c_str(), current); setattr(callbackInst, "total_steps", "i", totalSteps); @@ -569,7 +569,7 @@ bool PyCdromProgress::ChangeCdrom() } -bool PyCdromProgress::AskCdromName(string &Name) +bool PyCdromProgress::AskCdromName(std::string &Name) { PyObject *arglist = Py_BuildValue("()"); const char *new_name; @@ -582,7 +582,7 @@ bool PyCdromProgress::AskCdromName(string &Name) if(!PyArg_Parse(result, "(bs)", &res, &new_name)) std::cerr << "AskCdromName: result could not be parsed" << std::endl; // set the new name - Name = string(new_name); + Name =std:: string(new_name); return res; } // New style: String on success, None on failure. @@ -593,7 +593,7 @@ bool PyCdromProgress::AskCdromName(string &Name) if(!PyArg_Parse(result, "s", &new_name)) std::cerr << "ask_cdrom_name: result could not be parsed" << std::endl; else - Name = string(new_name); - return true; + Name = std::string(new_name); + return true; } } diff --git a/python/progress.h b/python/progress.h index 4e66c771..af8e3acc 100644 --- a/python/progress.h +++ b/python/progress.h @@ -72,7 +72,7 @@ struct PyFetchProgress : public pkgAcquireStatus, public PyCallbackObj void UpdateStatus(pkgAcquire::ItemDesc & Itm, int status); - virtual bool MediaChange(string Media, string Drive); + virtual bool MediaChange(std::string Media, std::string Drive); void setPyAcquire(PyObject *o) { Py_CLEAR(pyAcquire); @@ -107,11 +107,11 @@ struct PyInstallProgress : public PyCallbackObj struct PyCdromProgress : public pkgCdromStatus, public PyCallbackObj { // update steps, will be called regularly as a "pulse" - virtual void Update(string text="", int current=0); + virtual void Update(std::string text="", int current=0); // ask for cdrom insert virtual bool ChangeCdrom(); // ask for cdrom name - virtual bool AskCdromName(string &Name); + virtual bool AskCdromName(std::string &Name); PyCdromProgress() : PyCallbackObj() {}; }; diff --git a/python/tag.cc b/python/tag.cc index 94554400..3996af8e 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -26,6 +26,7 @@ #include "apt_pkgmodule.h" #include +#include #include #include diff --git a/python/tarfile.cc b/python/tarfile.cc index cdfe0a7c..bd903b57 100644 --- a/python/tarfile.cc +++ b/python/tarfile.cc @@ -348,7 +348,7 @@ static const char *tarfile_extractall_doc = "can be used to change the target directory."; static PyObject *tarfile_extractall(PyObject *self, PyObject *args) { - string cwd = SafeGetCWD(); + std::string cwd = SafeGetCWD(); char *rootdir = 0; if (PyArg_ParseTuple(args,"|s:extractall",&rootdir) == 0) return 0; diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 951c2afe..501b8f61 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -87,7 +87,7 @@ class TestDebfilee(unittest.TestCase): self.assertEqual(deb["Maintainer"], "Samuel Lidén Borell ") - def testContent(self): + def test_content(self): # no python-debian for python3 yet, so fail gracefully try: import debian @@ -130,6 +130,17 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading # we need to support python2.6 self.assertTrue(raised) + def test_multiarch_deb(self): + print apt_pkg.get_architectures() + if apt_pkg.get_architectures() != ["amd64", "i386"]: + logging.warn("skipping test because running on a non-multiarch system") + return + deb = apt.debfile.DebPackage("./data/test_debs/multiarch-test1_i386.deb") + print deb.missing_deps() + + + + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) unittest.main() -- cgit v1.2.3 From d37863d6d08a02b484577f7a6a67f163cc2f2902 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 5 Mar 2012 13:05:39 +0100 Subject: python/apt_pkgmodule.cc: Fix apt_pkg.Dependency.TYPE_RECOMMENDS, had Suggests value previously --- debian/changelog | 5 +++++ python/apt_pkgmodule.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'python/apt_pkgmodule.cc') diff --git a/debian/changelog b/debian/changelog index a585bbb4..b193ed71 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ python-apt (0.8.4) UNRELEASED; urgency=low + [ Michael Vogt ] * doc/examples/build-deps.py: - update the build-deps.py example to use the apt API more * add support for apt_pkg.Policy.get_priority(PkgFileIterator) @@ -14,6 +15,10 @@ python-apt (0.8.4) UNRELEASED; urgency=low - add support a filename argument in apt_pkg.TagFile() (in addition to the file object currently supported) + [Julian Andres Klode ] + * python/apt_pkgmodule.cc: + - Fix apt_pkg.Dependency.TYPE_RECOMMENDS, had Suggests value previously + -- Michael Vogt Wed, 04 Jan 2012 12:07:48 +0100 python-apt (0.8.3.1) UNRELEASED; urgency=low diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index acfdf019..7704aa01 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -920,7 +920,7 @@ extern "C" void initapt_pkg() PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_SUGGESTS", MkPyNumber(pkgCache::Dep::Suggests)); PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_RECOMMENDS", - MkPyNumber(pkgCache::Dep::Suggests)); + MkPyNumber(pkgCache::Dep::Recommends)); PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_CONFLICTS", MkPyNumber(pkgCache::Dep::Conflicts)); PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_REPLACES", -- cgit v1.2.3