From a9f50bc26bb8864886fc7c831324781822194f57 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 22 Oct 2012 13:50:07 +0100 Subject: [PATCH] Use default urgency for all packages if Urgencies is missing. --- britney.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/britney.py b/britney.py index 3af3c8e..7ed4392 100755 --- a/britney.py +++ b/britney.py @@ -766,31 +766,34 @@ class Britney(object): urgencies = {} filename = os.path.join(basedir, "Urgency") self.__log("Loading upload urgencies from %s" % filename) - for line in open(filename): - l = line.split() - if len(l) != 3: continue + try: + for line in open(filename): + l = line.split() + if len(l) != 3: continue - # read the minimum days associated with the urgencies - urgency_old = urgencies.get(l[0], self.options.default_urgency) - mindays_old = self.MINDAYS.get(urgency_old, self.MINDAYS[self.options.default_urgency]) - mindays_new = self.MINDAYS.get(l[2], self.MINDAYS[self.options.default_urgency]) + # read the minimum days associated with the urgencies + urgency_old = urgencies.get(l[0], self.options.default_urgency) + mindays_old = self.MINDAYS.get(urgency_old, self.MINDAYS[self.options.default_urgency]) + mindays_new = self.MINDAYS.get(l[2], self.MINDAYS[self.options.default_urgency]) - # if the new urgency is lower (so the min days are higher), do nothing - if mindays_old <= mindays_new: - continue + # if the new urgency is lower (so the min days are higher), do nothing + if mindays_old <= mindays_new: + continue - # if the package exists in testing and it is more recent, do nothing - tsrcv = self.sources['testing'].get(l[0], None) - if tsrcv and apt_pkg.version_compare(tsrcv[VERSION], l[1]) >= 0: - continue + # if the package exists in testing and it is more recent, do nothing + tsrcv = self.sources['testing'].get(l[0], None) + if tsrcv and apt_pkg.version_compare(tsrcv[VERSION], l[1]) >= 0: + continue - # if the package doesn't exist in unstable or it is older, do nothing - usrcv = self.sources['unstable'].get(l[0], None) - if not usrcv or apt_pkg.version_compare(usrcv[VERSION], l[1]) < 0: - continue + # if the package doesn't exist in unstable or it is older, do nothing + usrcv = self.sources['unstable'].get(l[0], None) + if not usrcv or apt_pkg.version_compare(usrcv[VERSION], l[1]) < 0: + continue - # update the urgency for the package - urgencies[l[0]] = l[2] + # update the urgency for the package + urgencies[l[0]] = l[2] + except IOError: + self.__log("%s missing; using default for all packages" % filename) return urgencies