diff options
Diffstat (limited to 'aptsources')
| -rw-r--r-- | aptsources/distinfo.py | 29 | ||||
| -rw-r--r-- | aptsources/distro.py | 5 | ||||
| -rw-r--r-- | aptsources/sourceslist.py | 22 |
3 files changed, 29 insertions, 27 deletions
diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index b21e95b3..c8ec5c46 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -22,11 +22,11 @@ # USA import errno +import logging import os import gettext from os import getenv from subprocess import Popen, PIPE -import ConfigParser import re import apt_pkg @@ -173,9 +173,9 @@ class DistInfo(object): try: dist = Popen(["lsb_release", "-i", "-s"], stdout=PIPE).communicate()[0].strip() - except OSError, exc: + except OSError as exc: if exc.errno != errno.ENOENT: - print 'WARNING: lsb_release failed, using defaults:', exc + logging.warn('lsb_release failed, using defaults:' % exc) dist = "Debian" self.dist = dist @@ -184,9 +184,6 @@ class DistInfo(object): dist_fname = "%s/%s.info" % (base_dir, dist) with open(dist_fname) as dist_file: - - - template = None component = None for line in dist_file: @@ -299,17 +296,17 @@ class DistInfo(object): if __name__ == "__main__": d = DistInfo("Ubuntu", "/usr/share/python-apt/templates") - print d.changelogs_uri + logging.info(d.changelogs_uri) for template in d.templates: - print "\nSuite: %s" % template.name - print "Desc: %s" % template.description - print "BaseURI: %s" % template.base_uri - print "MatchURI: %s" % template.match_uri + logging.info("\nSuite: %s" % template.name) + logging.info("Desc: %s" % template.description) + logging.info("BaseURI: %s" % template.base_uri) + logging.info("MatchURI: %s" % template.match_uri) if template.mirror_set != {}: - print "Mirrors: %s" % template.mirror_set.keys() + logging.info("Mirrors: %s" % template.mirror_set.keys()) for comp in template.components: - print " %s -%s -%s" % (comp.name, - comp.description, - comp.description_long) + logging.info(" %s -%s -%s" % (comp.name, + comp.description, + comp.description_long)) for child in template.children: - print " %s" % child.description + logging.info(" %s" % child.description) diff --git a/aptsources/distro.py b/aptsources/distro.py index 28d5b96f..f777a4ea 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -22,6 +22,7 @@ # USA import gettext +import logging import re import os import sys @@ -464,9 +465,9 @@ def _lsb_release(): # Convert to unicode string, needed for Python 3.1 out = out.decode("utf-8") result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) - except OSError, exc: + except OSError as exc: if exc.errno != errno.ENOENT: - print 'WARNING: lsb_release failed, using defaults:', exc + logging.warn('lsb_release failed, using defaults:' % exc) return result diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 353cce2d..40a0379b 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -25,6 +25,7 @@ import gettext import glob +import logging import os.path import re import shutil @@ -32,7 +33,7 @@ import sys import time import apt_pkg -from aptsources.distinfo import DistInfo +from distinfo import DistInfo from apt.deprecation import function_deprecated_by @@ -373,7 +374,7 @@ class SourcesList(object): source = SourceEntry(line, file) self.list.append(source) except: - print "could not open file '%s'" % file + logging.warn("could not open file '%s'\n" % file) def save(self): """ save the current sources """ @@ -449,7 +450,10 @@ class SourceEntryMatcher(object): found = False for template in self.templates: if (re.search(template.match_uri, source.uri) and - re.match(template.match_name, source.dist)): + re.match(template.match_name, source.dist) and + # deb is a valid fallback for deb-src (if that is not + # definied, see #760035 + (source.type == template.type or template.type == "deb")): found = True source.template = template break @@ -467,14 +471,14 @@ if __name__ == "__main__": sources = SourcesList() for entry in sources: - print entry.str() + logging.info("entry %s" % entry.str()) #print entry.uri mirror = is_mirror("http://archive.ubuntu.com/ubuntu/", "http://de.archive.ubuntu.com/ubuntu/") - print "is_mirror(): %s" % mirror + logging.info("is_mirror(): %s" % mirror) - print is_mirror("http://archive.ubuntu.com/ubuntu", - "http://de.archive.ubuntu.com/ubuntu/") - print is_mirror("http://archive.ubuntu.com/ubuntu/", - "http://de.archive.ubuntu.com/ubuntu") + logging.info(is_mirror("http://archive.ubuntu.com/ubuntu", + "http://de.archive.ubuntu.com/ubuntu/")) + logging.info(is_mirror("http://archive.ubuntu.com/ubuntu/", + "http://de.archive.ubuntu.com/ubuntu")) |
