From 248de65b8195f33c096704bab9ee9b9bee807784 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 12 Jun 2012 01:53:24 +0100 Subject: aptsources/*.py, setup.py: Make aptsources modules work directly in either Python 2 or 3, and exclude the "future" 2to3 fixer so that 2to3 doesn't need to modify them. This makes life a little easier for the strange tricks update-manager plays with its dist-upgrader tarball. --- aptsources/distro.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'aptsources/distro.py') diff --git a/aptsources/distro.py b/aptsources/distro.py index 27d7f859..ca87a919 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -327,12 +327,14 @@ class Distribution(object): if s.type == self.binary_type: if s.dist not in comps_per_dist: comps_per_dist[s.dist] = set() - map(comps_per_dist[s.dist].add, s.comps) + for c in s.comps: + comps_per_dist[s.dist].add(c) for s in self.source_code_sources: if s.type == self.source_type: if s.dist not in comps_per_sdist: comps_per_sdist[s.dist] = set() - map(comps_per_sdist[s.dist].add, s.comps) + for c in s.comps: + comps_per_sdist[s.dist].add(c) # check if there is a main source at all if len(self.main_sources) < 1: -- cgit v1.2.3 From a0ecfe1c745e07c41c85b80d747b19179341531d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 19 Nov 2012 13:22:42 +0000 Subject: * aptsources/distinfo.py, aptsources/distro.py, aptsources/sourceslist.py, tests/test_apt_cache.py, tests/test_debfile_multiarch.py: - Use logging.warning rather than the deprecated logging.warn. --- aptsources/distinfo.py | 3 ++- aptsources/distro.py | 2 +- aptsources/sourceslist.py | 2 +- debian/changelog | 3 +++ tests/test_apt_cache.py | 8 ++++---- tests/test_debfile_multiarch.py | 4 ++-- 6 files changed, 13 insertions(+), 9 deletions(-) (limited to 'aptsources/distro.py') diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index e0ee915d..d80721e5 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -172,7 +172,8 @@ class DistInfo(object): stdout=PIPE).communicate()[0].strip() except OSError as exc: if exc.errno != errno.ENOENT: - logging.warn('lsb_release failed, using defaults:' % exc) + logging.warning( + 'lsb_release failed, using defaults:' % exc) dist = "Debian" self.dist = dist diff --git a/aptsources/distro.py b/aptsources/distro.py index ca87a919..82fd67ba 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -465,7 +465,7 @@ def _lsb_release(): result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) except OSError as exc: if exc.errno != errno.ENOENT: - logging.warn('lsb_release failed, using defaults:' % exc) + logging.warning('lsb_release failed, using defaults:' % exc) return result diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 40902d84..f5a86ecb 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -375,7 +375,7 @@ class SourcesList(object): source = SourceEntry(line, file) self.list.append(source) except: - logging.warn("could not open file '%s'\n" % file) + logging.warning("could not open file '%s'\n" % file) def save(self): """ save the current sources """ diff --git a/debian/changelog b/debian/changelog index 39685bef..d9083659 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,9 @@ python-apt (0.8.8ubuntu4) UNRELEASED; urgency=low * tests/test_auth.py: - Discard stderr from gpg. - Try successive keyserver ports if 19191 is already in use. + * aptsources/distinfo.py, aptsources/distro.py, aptsources/sourceslist.py, + tests/test_apt_cache.py, tests/test_debfile_multiarch.py: + - Use logging.warning rather than the deprecated logging.warn. -- Colin Watson Mon, 19 Nov 2012 11:57:28 +0000 diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 3cf89c07..fe90eb8a 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -34,7 +34,7 @@ def if_sources_list_is_readable(f): if os.access("/etc/apt/sources.list", os.R_OK): f(*args, **kwargs) else: - logging.warn("skipping '%s' because sources.list is not readable" % f) + logging.warning("skipping '%s' because sources.list is not readable" % f) return wrapper @@ -42,7 +42,7 @@ def get_open_file_descriptors(): try: fds = os.listdir("/proc/self/fd") except OSError: - logging.warn("failed to list /proc/self/fd") + logging.warning("failed to list /proc/self/fd") return set([]) return set(map(int, fds)) @@ -122,7 +122,7 @@ class TestAptCache(TestCase): cache = apt.Cache(rootdir="./data/test-provides/") cache.open() if len(cache) == 0: - logging.warn("skipping test_get_provided_packages, cache empty?!?") + logging.warning("skipping test_get_provided_packages, cache empty?!?") return # a true virtual pkg l = cache.get_providing_packages("mail-transport-agent") @@ -135,7 +135,7 @@ class TestAptCache(TestCase): # create highlevel cache and get the lowlevel one from it highlevel_cache = apt.Cache(rootdir="./data/test-provides") if len(highlevel_cache) == 0: - logging.warn("skipping test_log_level_pkg_provides, cache empty?!?") + logging.warning("skipping test_log_level_pkg_provides, cache empty?!?") return # low level cache provides list of the pkg cache = highlevel_cache._cache diff --git a/tests/test_debfile_multiarch.py b/tests/test_debfile_multiarch.py index 7c02a32a..8da070aa 100644 --- a/tests/test_debfile_multiarch.py +++ b/tests/test_debfile_multiarch.py @@ -23,7 +23,7 @@ class TestDebfileMultiarch(unittest.TestCase): def test_multiarch_deb_check(self): if apt_pkg.get_architectures() != ["amd64", "i386"]: - logging.warn("skipping test because running on a non-multiarch system") + logging.warning("skipping test because running on a non-multiarch system") return deb = apt.debfile.DebPackage( "./data/test_debs/multiarch-test1_i386.deb") @@ -37,7 +37,7 @@ class TestDebfileMultiarch(unittest.TestCase): # use "lib3ds-1-3" as a test to see if non-multiach lib conflicts work canary = "lib3ds-1-3" if not canary in cache: - logging.warn("skipping test because %s is missing" % canary) + logging.warning("skipping test because %s is missing" % canary) return cache[canary].mark_install() deb = apt.debfile.DebPackage( -- cgit v1.2.3 From 7898eab688249a2200156c5be039d91ba58a8b39 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 20 Nov 2012 10:52:06 +0100 Subject: aptsources/distro.py: Replace the deprecated getiterator() ElementTree method with iter(), to avoid raising a PendingDeprecationWarning. --- aptsources/distro.py | 2 +- debian/changelog | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'aptsources/distro.py') diff --git a/aptsources/distro.py b/aptsources/distro.py index 82fd67ba..1c9daa27 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -163,7 +163,7 @@ class Distribution(object): fname = "/usr/share/xml/iso-codes/iso_3166.xml" if os.path.exists(fname): et = ElementTree(file=fname) - it = et.getiterator('iso_3166_entry') + it = et.iter('iso_3166_entry') for elm in it: try: descr = elm.attrib["common_name"] diff --git a/debian/changelog b/debian/changelog index cce0d623..cad5c31c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ python-apt (0.8.8ubuntu5) UNRELEASED; urgency=low * tests/test_auth.py: In test_add_key_from_server_mitm(), show the exception if it does not match the expectation, so that this becomes possible to debug. + * aptsources/distro.py: Replace the deprecated getiterator() ElementTree + method with iter(), to avoid raising a PendingDeprecationWarning. -- Martin Pitt Tue, 20 Nov 2012 09:43:36 +0100 -- cgit v1.2.3 From 6c4a6388831e4c9a158f626b94634bddad819592 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Mar 2013 18:36:17 +0100 Subject: python2.6 compat fixes --- aptsources/distro.py | 4 ++++ tests/test_all.py | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'aptsources/distro.py') diff --git a/aptsources/distro.py b/aptsources/distro.py index 1c9daa27..108a3012 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -163,6 +163,10 @@ class Distribution(object): fname = "/usr/share/xml/iso-codes/iso_3166.xml" if os.path.exists(fname): et = ElementTree(file=fname) + # python2.6 compat, the next two lines can get removed + # once we do not use py2.6 anymore + if getattr(et, "iter", None) is None: + et.iter = et.getiterator it = et.iter('iso_3166_entry') for elm in it: try: diff --git a/tests/test_all.py b/tests/test_all.py index 0eccfa91..25774617 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -6,9 +6,16 @@ # notice and this notice are preserved. """Run all available unit tests.""" import os -import unittest import sys +try: + import unittest.runner + import unittest +except ImportError: + # py2.6 compat + import unittest2 as unittest + + # workaround for py3.2 that apparently does not have this anymore # it has "abiflags" if not hasattr(sys, "pydebug"): -- cgit v1.2.3