first attempt at yaml logging

master
Ivo De Decker 11 years ago committed by Niels Thykier
parent 4fb5b6d313
commit ab4de3b93c

@ -186,12 +186,14 @@ import string
import time
import optparse
import urllib
import yaml
import apt_pkg
from functools import reduce, partial
from itertools import chain, ifilter, product
from operator import attrgetter
from datetime import datetime
if __name__ == '__main__':
# Check if there is a python-search dir for this version of
@ -1655,6 +1657,18 @@ class Britney(object):
f.write("</ul></body></html>\n")
f.close()
if hasattr(self.options, 'excuses_yaml_output'):
self.__log("> Writing YAML Excuses to %s" % self.options.excuses_yaml_output, type="I")
f = open(self.options.excuses_yaml_output, 'w')
excuselist = []
for e in self.excuses:
excuselist.append(e.excusedata())
excusesdata = {}
excusesdata["sources"] = excuselist
excusesdata["generated"] = datetime.utcnow()
f.write(yaml.dump(excusesdata, default_flow_style=False, allow_unicode=True))
f.close()
self.__log("Update Excuses generation completed", type="I")
# Upgrade run

@ -151,3 +151,57 @@ class Excuse(object):
res += "<li>Valid candidate\n"
res = res + "</ul>\n"
return res
# TODO merge with html()
def text(self):
"""Render the excuse in text"""
res = []
res.append("%s (%s to %s)" % \
(self.name, self.ver[0], self.ver[1]))
if self.maint:
maint = self.maint
# ugly hack to work around strange encoding in pyyaml
# should go away with pyyaml in python 3
try:
maint.decode('ascii')
except UnicodeDecodeError:
maint = unicode(self.maint,'utf-8')
res.append("Maintainer: %s" % maint)
if self.section and string.find(self.section, "/") > -1:
res.append("Section: %s" % (self.section))
if self.daysold != None:
if self.daysold < self.mindays:
res.append(("Too young, only %d of %d days old" %
(self.daysold, self.mindays)))
else:
res.append(("%d days old (needed %d days)" %
(self.daysold, self.mindays)))
for x in self.htmlline:
res.append("" + x + "")
lastdep = ""
for x in sorted(self.deps, lambda x,y: cmp(x.split('/')[0], y.split('/')[0])):
dep = x.split('/')[0]
if dep == lastdep: continue
lastdep = dep
if x in self.invalid_deps:
res.append("Depends: %s %s (not considered)" % (self.name, dep))
else:
res.append("Depends: %s %s" % (self.name, dep))
for (n,a) in self.break_deps:
if n not in self.deps:
res.append("Ignoring %s depends: %s" % (a, n))
if self.is_valid:
res.append("Valid candidate")
return res
def excusedata(self):
"""Render the excuse in as key-value data"""
excusedata = {}
excusedata["excuses"] = self.text()
excusedata["source"] = self.name
excusedata["oldversion"] = self.ver[0]
excusedata["newversion"] = self.ver[1]
excusedata["age"] = self.daysold
excusedata["ageneeded"] = self.mindays
return excusedata

Loading…
Cancel
Save