From f2cd844828de310dc510505612395ef60ded8731 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 17 Nov 2011 16:46:53 +0100 Subject: * apt/package.py: - add new "suggests" property, thanks to Christop Groth --- apt/package.py | 5 +++++ debian/changelog | 2 ++ 2 files changed, 7 insertions(+) diff --git a/apt/package.py b/apt/package.py index cb373c2e..e09acca4 100644 --- a/apt/package.py +++ b/apt/package.py @@ -454,6 +454,11 @@ class Version(object): """Return the recommends of the package version.""" return self.get_dependencies("Recommends") + @property + def suggests(self): + """Return the suggests of the package version.""" + return self.get_dependencies("Suggests") + @property def origins(self): """Return a list of origins for the package version.""" diff --git a/debian/changelog b/debian/changelog index 14ee705e..afffdf12 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ python-apt (0.8.2) UNRELEASED; urgency=low * apt/cache.py: - set Dir::bin::dpkg if a alternate rootdir is given (LP: #885895) + * apt/package.py: + - add new "suggests" property, thanks to Christop Groth [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) -- cgit v1.2.3 From add08632b8a66c7ba5de7ab44d8a10ec9462692e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 17 Nov 2011 17:57:34 +0100 Subject: allow Dependency object to be iteratable, this allows to write code like: for or_dep_group in pkg.candidate.dependencies: for dep in or_dep_group: do_something() --- apt/package.py | 3 +++ debian/changelog | 4 ++++ tests/test_apt_cache.py | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apt/package.py b/apt/package.py index e09acca4..ab692788 100644 --- a/apt/package.py +++ b/apt/package.py @@ -107,6 +107,9 @@ class Dependency(object): def __repr__(self): return repr(self.or_dependencies) + def __iter__(self): + return self.or_dependencies.__iter__() + class DeprecatedProperty(property): """A property which gives DeprecationWarning on access. diff --git a/debian/changelog b/debian/changelog index afffdf12..7d939702 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,10 @@ python-apt (0.8.2) UNRELEASED; urgency=low (LP: #885895) * apt/package.py: - add new "suggests" property, thanks to Christop Groth + - allow Dependency object to be iteratable, this allows to write + code like: + for or_dep_group in pkg.candidate.dependencies: + for dep in or_dep_group: do_something() [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 0d80f617..7784a25f 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -55,8 +55,8 @@ class TestAptCache(unittest.TestCase): # that is possible and does not crash for pkg in cache: if pkg.candidate: - for or_dep in pkg.candidate.dependencies: - for dep in or_dep.or_dependencies: + for or_deps in pkg.candidate.dependencies: + for dep in or_deps: self.assertTrue(dep.name) self.assertTrue(isinstance(dep.relation, str)) self.assertTrue(dep.pre_depend in (True, False)) -- cgit v1.2.3 From a01e314df3ceaf0cc99102beb511a2ecbd973057 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 17 Nov 2011 20:28:10 +0100 Subject: make Dependency a list (it should probably also renamed to DependencyOrGroup or something), thanks to Christop Groth --- apt/package.py | 14 ++++++-------- debian/changelog | 4 +++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apt/package.py b/apt/package.py index ab692788..8b79c420 100644 --- a/apt/package.py +++ b/apt/package.py @@ -94,7 +94,7 @@ class BaseDependency(object): preDepend = AttributeDeprecatedBy('pre_depend') -class Dependency(object): +class Dependency(list): """Represent an Or-group of dependencies. Attributes defined here: @@ -102,14 +102,12 @@ class Dependency(object): """ def __init__(self, alternatives): - self.or_dependencies = alternatives - - def __repr__(self): - return repr(self.or_dependencies) - - def __iter__(self): - return self.or_dependencies.__iter__() + super(Dependency, self).__init__() + self.extend(alternatives) + @property + def or_dependencies(self): + return self class DeprecatedProperty(property): """A property which gives DeprecationWarning on access. diff --git a/debian/changelog b/debian/changelog index 7d939702..6e750980 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,7 +27,9 @@ python-apt (0.8.2) UNRELEASED; urgency=low - allow Dependency object to be iteratable, this allows to write code like: for or_dep_group in pkg.candidate.dependencies: - for dep in or_dep_group: do_something() + for dep in or_dep_group: + do_something() + (thanks to Christop Groth) [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) -- cgit v1.2.3 From 4600b96f047154b4adadfc8f862c0f6201d21bdc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 24 Nov 2011 16:36:48 +0100 Subject: fixed a typo, changed "Open Source software" to "free and open-source software" (LP: #500940) --- data/templates/Ubuntu.info.in | 52 +++++++++++++++++++++---------------------- debian/changelog | 4 ++++ 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index 9e62c0fa..3a9562f4 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -13,10 +13,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 12.04 'Precise Pangolin' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -131,10 +131,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 11.10 'Oneiric Ocelot' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -250,10 +250,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 11.04 'Natty Narwhal' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -368,10 +368,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 10.10 'Maverick Meerkat' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -451,10 +451,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 10.04 'Lucid Lynx' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -514,10 +514,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.10 'Karmic Koala' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -577,10 +577,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.04 'Jaunty Jackalope' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -639,10 +639,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.10 'Intrepid Ibex' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -703,10 +703,10 @@ MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.04 'Hardy Heron' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -768,10 +768,10 @@ MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 7.10 'Gutsy Gibbon' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -832,10 +832,10 @@ MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 7.04 'Feisty Fawn' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -893,10 +893,10 @@ MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 6.10 'Edgy Eft' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices @@ -954,10 +954,10 @@ MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 6.06 LTS 'Dapper Drake' Component: main _CompDescription: Officially supported -_CompDescriptionLong: Canonical-supported Open Source software +_CompDescriptionLong: Canonical-supported free and open-source software Component: universe _CompDescription: Community-maintained (universe) -_CompDescriptionLong: Community-maintained Open Source software +_CompDescriptionLong: Community-maintained free and open-source software Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices diff --git a/debian/changelog b/debian/changelog index 6e750980..7150adf7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,10 @@ python-apt (0.8.2) UNRELEASED; urgency=low to get output from require_changes and missing_deps (closes: #624379) + [ Nikola Pavlović ] + * fixed a typo, changed "Open Source software" to + "free and open-source software" (LP: #500940) + -- Michael Vogt Wed, 19 Oct 2011 18:03:42 +0200 python-apt (0.8.1) unstable; urgency=low -- cgit v1.2.3 From c4c1197922edb4f82390f7e0f125be34863d24d3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Dec 2011 12:03:16 +0100 Subject: * apt/progress/base.py: - write exception text to stderr to avoid hidding exceptions like "pre-configure failed" from libapt (thanks to Jean-Baptiste Lallement) --- apt/progress/base.py | 4 +++- debian/changelog | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apt/progress/base.py b/apt/progress/base.py index 97375431..4943978c 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -27,6 +27,7 @@ import fcntl import os import re import select +import sys import apt_pkg @@ -196,7 +197,8 @@ class InstallProgress(object): os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", str(self.write_stream.fileno()), "-i", obj)) - except Exception: + except Exception as e: + sys.stderr.write("%s\n" % e) os._exit(apt_pkg.PackageManager.RESULT_FAILED) self.child_pid = pid diff --git a/debian/changelog b/debian/changelog index 7150adf7..569c335d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,10 @@ python-apt (0.8.2) UNRELEASED; urgency=low for dep in or_dep_group: do_something() (thanks to Christop Groth) + * apt/progress/base.py: + - write exception text to stderr to avoid hidding exceptions + like "pre-configure failed" from libapt (thanks to Jean-Baptiste + Lallement) [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) -- cgit v1.2.3 From c8bfdda85fbd2df250fbc6d3faeb2bd5875a77d6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Dec 2011 13:32:42 +0100 Subject: py3 fixes/clean --- apt/progress/base.py | 2 ++ tests/test_debfile.py | 4 ++-- tests/test_utils.py | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apt/progress/base.py b/apt/progress/base.py index 4943978c..c2a9a9c8 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -192,12 +192,14 @@ class InstallProgress(object): # and the execution continues in the # parent code leading to very confusing bugs try: + raise Exception("foo") os._exit(obj.do_install(self.write_stream.fileno())) except AttributeError: os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", str(self.write_stream.fileno()), "-i", obj)) except Exception as e: + os.write(self.writefd, "pmerror:::%s" % e) sys.stderr.write("%s\n" % e) os._exit(apt_pkg.PackageManager.RESULT_FAILED) diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 501b8f61..56410153 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -131,12 +131,12 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading 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() + res = deb.check() + # FIXME: do something sensible with the multiarch test diff --git a/tests/test_utils.py b/tests/test_utils.py index 23511f32..26ee0bff 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,7 +7,6 @@ # notice and this notice are preserved. import sys -sys.path.insert(0, "..") import apt_pkg import apt.utils import datetime -- cgit v1.2.3 From fb595849bc7149619b3e47b65f145a1f66fc7dbe Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Dec 2011 13:45:58 +0100 Subject: fix debfile binary test for py3 --- apt/debfile.py | 11 +++++++++-- tests/test_debfile.py | 5 ----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apt/debfile.py b/apt/debfile.py index 104b0814..4a82842a 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -525,12 +525,19 @@ class DebPackage(object): @staticmethod def to_strish(in_data): + # helper for py3 compat, in_data is str in py2 and bytes in py3 + def my_ord(c): + if type(c) == int: + return c + else: + return ord(c) + # convert s = "" for c in in_data: - if ord(c) < 10 or ord(c) > 127: + if my_ord(c) < 10 or my_ord(c) > 127: s += " " else: - s += c + s += chr(c) return s def _get_content(self, part, name, auto_decompress=True, auto_hex=True): diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 56410153..70979689 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -88,11 +88,6 @@ class TestDebfilee(unittest.TestCase): "Samuel Lidén Borell ") def test_content(self): - # no python-debian for python3 yet, so fail gracefully - try: - import debian - except ImportError: - return # normal deb = apt.debfile.DebPackage(cache=self.cache) deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) -- cgit v1.2.3 From 1c6b01aa63e440444f00ec9e3f527e1c65a63787 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Dec 2011 13:55:04 +0100 Subject: apt/progress/base.py: fix silly leftover from last commit --- apt/progress/base.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/apt/progress/base.py b/apt/progress/base.py index c2a9a9c8..4943978c 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -192,14 +192,12 @@ class InstallProgress(object): # and the execution continues in the # parent code leading to very confusing bugs try: - raise Exception("foo") os._exit(obj.do_install(self.write_stream.fileno())) except AttributeError: os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", str(self.write_stream.fileno()), "-i", obj)) except Exception as e: - os.write(self.writefd, "pmerror:::%s" % e) sys.stderr.write("%s\n" % e) os._exit(apt_pkg.PackageManager.RESULT_FAILED) -- cgit v1.2.3 From d236f527f85b185144875e0e7ad9102c4c2dabd0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Dec 2011 13:55:28 +0100 Subject: apt/debfile.py: add py3 compat for to_strish() --- apt/debfile.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/apt/debfile.py b/apt/debfile.py index 4a82842a..a7202eba 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -525,19 +525,21 @@ class DebPackage(object): @staticmethod def to_strish(in_data): - # helper for py3 compat, in_data is str in py2 and bytes in py3 - def my_ord(c): - if type(c) == int: - return c - else: - return ord(c) - # convert s = "" - for c in in_data: - if my_ord(c) < 10 or my_ord(c) > 127: - s += " " - else: - s += chr(c) + # py2 compat, in_data is type string + if type(in_data) == str: + for c in in_data: + if ord(c) < 10 or ord(c) > 127: + s += " " + else: + s += c + # py3 compat, in_data is type bytes + else: + for b in in_data: + if b < 10 or b > 127: + s += " " + else: + s += chr(b) return s def _get_content(self, part, name, auto_decompress=True, auto_hex=True): -- cgit v1.2.3