Mercurial > treepkg > treepkg
view treepkg/info/status.py @ 387:c1f3be727f9d treepkg-status
renamed new status dir to info because of a naming conflict with status.py
let the user specify a treepkg name in the config
the name is propagated to PackagerGroup
[treepkg]
name: <treepkgname>
becomes:
pg = PackagerGroup(...)
pg.name
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Thu, 08 Jul 2010 10:07:39 +0000 |
parents | treepkg/status/status.py@ffa86312ee81 |
children | 1af04bfbb1d0 |
line wrap: on
line source
# Copyright (C) 2010 by Intevation GmbH # Authors: # Bjoern Ricks <bjoern.ricks@intevation.de> # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with the software for details. """Build treepkg status information""" import xml.dom.minidom TREEPKG_NAMESPACE_URI = "http://wald.intevation.org/projects/treepkg/" TREEPKG_NAMESPACE_PREFIX = "tpkg" def createTpkgElement(doc, name): return doc.createElementNS(TREEPKG_NAMESPACE_URI, name) def createTpkgRoot(name): domimpl = xml.dom.minidom.getDOMImplementation() doc = domimpl.createDocument(TREEPKG_NAMESPACE_URI, name, None) root = doc.documentElement return (doc, root) class TreepkgStatus: def __init__(self, name, treepkgpath=None, millpath=None, version=None): self.name = name self.treepkgpath = treepkgpath self.millpath = millpath self.version = version def toxml(self): (doc, root) = createTpkgRoot("status") # add <name> nameele = createTpkgElement(doc, "name") text = doc.createTextNode(self.name) nameele.appendChild(text) root.appendChild(nameele) # add <treepkgpath> if self.treepkgpath: treepkgpathele = createTpkgElement(doc, "treepkgpath") text = doc.createTextNode(self.treepkgpath) treepkgpathele.appendChild(text) root.appendChild(treepkgpathele) # add <millpath> if self.millpath: millpathele = createTpkgElement(doc, "millpath") text = doc.createTextNode(self.millpath) millpathele.appendChild(text) root.appendChild(millpathele) # add <version> if self.version: versionele = createTpkgElement(doc, "version") text = doc.createTextNode(self.version) versionele.appendChild(text) root.appendChild(version) return root class TreepkgTrack: def __init__(self, name): self.name = name self.revisions = [] def add_revision(self, revision): self.revisions.append(revision) def toxml(self): (doc, root) = createTpkgRoot("track") nameele = createTpkgElement(doc, "name") text = doc.createTextNode(self.name) nameele.appendChild(text) root.appendChild(nameele) for rev in self.revision: root.appendChild(rev.toxml()) return root class TreepkgTrackRevision: def __init__(self, number, rules, status, platform): self.number = number self.rules = rules self.status = status self.platform = platform def toxml(self): (doc, root) = createTpkgRoot("revision") # add <number> numberele = createTpkgElement(doc, "number") text = doc.createTextNode(self.number) numbverele.appendChild(text) root.appendChild(numberele) # add <rules> rulesele = createTpkgElement(doc, "rules") text = doc.createTextNode(self.rules) rulesele.appendChild(text) root.appendChild(rulesele) # add <status><message></message></status> statusele = createTpkgElement(doc, "status") messageele = createTpkgElement(doc, "message") text = doc.createTextNode(self.status) messageele.appendChild(text) statusele.appendChild(messageele) root.appendChild(statusele) # add <platform> root.appendChild(platform.toxml()) return root class TreepkgPlatform: def __init__(self, os, arch): self.os = os self.arch = arch self.packages = [] self.logs = [] def add_package(self, package): self.packages.append(package) def add_log(self, log): self.logs.append(log) def toxml(self): (doc, root) = createTpkgRoot("platform") # add <os> osele = createTpkgElement(doc, "os") text = doc.createTextNode(self.os) osele.appendChild(text) root.appendChild(osele) # add <arch> archele = createTpkgElement(doc, "arch") text = doc.createTextNode(sef.arch) archele.appendChild(text) root.appendChild(archele) # add <packages> packagesele = createTpkgElement(doc, "packages") for package in self.packages: packagesele.appendChild(package.toxml()) root.appendChild(packagesele) # add <logs> logsele = createTpkgElement(doc, "logs") for log in self.logs: losele.appendChild(log) root.appendChild(logsele) return root class TreepkgLog: def __init__(self, name, path): self.name = name self.path = path def toxml(self) (doc, root) = createTpkgRoot("log") # add <name> nameele = createTpkgElement(doc, "name") text = doc.createTextNode(self.name) nameele.appendChild(text) root.appendChild(nameele) # add path pathele = createTpkgElement(doc, "path") text = doc.createTextNode(self.path) pathele.appendChild(text) root.appendChild(pathele) return root class TreepkgPackage: def __init__(self, name, path, type, checksum = None): self.name = name self.path = path self.type = type self.checksum = checksum def toxml(self): (doc, root) = createTpkgRoot("package") # add <name> nameele = createTpkgElement(doc, "name") text = doc.createTextNode(self.name) nameele.appendChild(text) root.appendChild(nameele) # add <path> pathele = createTpkgElement("path") text = doc.createTextNode(self.path) pathele.appendChild(text) root.appendChild(pathele) # add <checksum> if self.checksum: checksumele = createTpkgElement(doc, "checksum") text = doc.createTextNode(self.checksum) checksumele.appendChild(text) root.appendChild(checksumele) # add <type> typeele = createTpkgElement(doc, "type") text = doc.createTextNode(self.type) typeele.appendChild(text) root.appendChild(typeele)