# HG changeset patch # User Bjoern Ricks # Date 1278681315 0 # Node ID 0ba451c4a8563777a330de429717512c928728c4 # Parent bfd1c6a155fac8d5e00fc01577e3b223309e6321 implemented nearly all info only arch and os info are missing diff -r bfd1c6a155fa -r 0ba451c4a856 treepkg/info/status.py --- a/treepkg/info/status.py Fri Jul 09 12:42:42 2010 +0000 +++ b/treepkg/info/status.py Fri Jul 09 13:15:15 2010 +0000 @@ -7,6 +7,7 @@ """Build treepkg status information""" +import os.path import xml.dom.minidom from treepkg.report import get_packager_group @@ -35,10 +36,47 @@ for track in tracks: trackinfo = TreepkgTrackInfo(track.name) self.tpkgroot.add_track(trackinfo) + self.add_revisions(track, trackinfo) def toxml(self): return self.tpkgroot.toxml() + def add_revisions(self, track, trackinfo): + revisions = track.get_revisions() + for rev in revisions: + revision = rev.revision + rules_revision = rev.rules_revision + status = rev.status.status # extend status + platforminfo = self.get_platform(rev) + revinfo = TreepkgTrackRevisionInfo(revision, rules_revision, + status, platforminfo) + trackinfo.add_revision(revinfo) + + def get_platform(self, revision): + # FIXME + os = "abc os" + arch = "def arch" + platforminfo = TreepkgPlatformInfo(os, arch) + logs = revision.get_log_files() + for (title, file) in logs: + loginfo = TreepkgLogInfo(title, file) + platforminfo.add_log(loginfo) + sources = revision.list_source_files() + for source in sources: + self.add_package(source, "source", platforminfo) + binaries = revision.list_binary_files() + for binary in binaries: + self.add_package(binary, "binary", platforminfo) + return platforminfo + + def add_package(self, file, type, platform): + name = os.path.basename(file) + path = source + checksum = md5sum(file) + checksuminfo = TreepkgChecksumInfo(checksum, "md5") + pkginfo = TreepkgPackageInfo(name, path, type) + pkginfo.add_checksum(checksuminfo) + platform.add_package(pkginfo) class TreepkgRootInfo: @@ -194,33 +232,44 @@ class TreepkgPackageInfo: - def __init__(self, name, path, type, checksum = None): - self.name = name - self.path = path - self.type = type - self.checksum = checksum + def __init__(self, name, path, type): + self.name = name + self.path = path + self.type = type + self.checksums = [] - def toxml(self): - (doc, root) = createTpkgRoot("package") - # add - nameele = createTpkgElement(doc, "name") - text = doc.createTextNode(self.name) - nameele.appendChild(text) - root.appendChild(nameele) - # add - pathele = createTpkgElement("path") - text = doc.createTextNode(self.path) - pathele.appendChild(text) - root.appendChild(pathele) - # add - if self.checksum: - checksumele = createTpkgElement(doc, "checksum") - text = doc.createTextNode(self.checksum) - checksumele.appendChild(text) - root.appendChild(checksumele) - # add - typeele = createTpkgElement(doc, "type") - text = doc.createTextNode(self.type) - typeele.appendChild(text) - root.appendChild(typeele) + def toxml(self): + (doc, root) = createTpkgRoot("package") + # add + nameele = createTpkgElement(doc, "name") + text = doc.createTextNode(self.name) + nameele.appendChild(text) + root.appendChild(nameele) + # add + pathele = createTpkgElement("path") + text = doc.createTextNode(self.path) + pathele.appendChild(text) + root.appendChild(pathele) + # add + for checksum in self.checksums: + root.appendChild(checksum.toxml()) + # add + typeele = createTpkgElement(doc, "type") + text = doc.createTextNode(self.type) + typeele.appendChild(text) + root.appendChild(typeele) + return root +class TreepkgChecksumInfo: + + def __inif__(self, checksum, type="md5"): + self.checksum = checksum + self.type = type + + def toxml(self): + (doc, root) = createTpkgRoot("checksum") + text = doc.createTextNode(self.checksum) + root.appendChild(text) + # add attribute type + root.setAttributeNS(TREEPKG_NAMESPACE_URI, "type", self.type) + return root diff -r bfd1c6a155fa -r 0ba451c4a856 treepkg/info/status.xsd --- a/treepkg/info/status.xsd Fri Jul 09 12:42:42 2010 +0000 +++ b/treepkg/info/status.xsd Fri Jul 09 13:15:15 2010 +0000 @@ -86,11 +86,19 @@ - + + + + + + + +