Mercurial > treepkg
changeset 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 (2010-07-08) |
parents | ffa86312ee81 |
children | 1af04bfbb1d0 |
files | test/test_readconfig.py treepkg/info/__init__.py treepkg/info/status.py treepkg/info/status.xsd treepkg/packager.py treepkg/readconfig.py treepkg/status/__init__.py treepkg/status/status.py treepkg/status/status.xsd |
diffstat | 9 files changed, 315 insertions(+), 306 deletions(-) [+] |
line wrap: on
line diff
--- a/test/test_readconfig.py Wed Jul 07 15:40:48 2010 +0000 +++ b/test/test_readconfig.py Thu Jul 08 10:07:39 2010 +0000 @@ -34,6 +34,7 @@ [treepkg] instructions_file: %(treepkg_dir)s/instructions check_interval: 3600 +name: testtreepkg [pkg_simple] pkg_basename: simple1 @@ -82,7 +83,7 @@ treepkg_opts, packager_opts = read_config(config_file) self.assertEquals(treepkg_opts, dict(instructions_file="/home/builder/mill/instructions", - check_interval=3600)) + check_interval=3600, name="testtreepkg")) self.assertEquals(sorted(packager_opts, key=operator.itemgetter("name")), [ @@ -134,3 +135,9 @@ git_url="", git_branch="", builder_cls="PBuilder")]) + +def main(): + unittest.main() + +if __name__ == "__main__": + main()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/treepkg/info/__init__.py Thu Jul 08 10:07:39 2010 +0000 @@ -0,0 +1,6 @@ +# Copyright (C) 2007 by Intevation GmbH +# Authors: +# Bernhard Herzog <bh@intevation.de> +# +# This program is free software under the GPL (>=v2) +# Read the file COPYING coming with the software for details.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/treepkg/info/status.py Thu Jul 08 10:07:39 2010 +0000 @@ -0,0 +1,198 @@ +# 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) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/treepkg/info/status.xsd Thu Jul 08 10:07:39 2010 +0000 @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tpkg="http://wald.intevation.org/projects/treepkg/" + targetNamespace="http://wald.intevation.org/projects/treepkg/"> + + <xsd:element name="treepkg"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="tracks" type="tpkg:tracks"/> + <xsd:element name="info" type="tpkg:info" minOccurs="1"/> + </xsd:sequence> + <!-- xml schema version --> + <xsd:attribute name="version" type="xsd:string"/> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="info"> + <xsd:sequence> + <xsd:element name="name" type="xsd:string" minOccurs="1"/> + <xsd:element name="treepkgpath" type="xsd:string"/> + <xsd:element name="millpath" type="xsd:string"/> + <!-- treepkg version e.g. svn revision --> + <xsd:element name="version" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="tracks"> + <xsd:sequence> + <xsd:element name="track" type="tpkg:track" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="track"> + <xsd:sequence> + <xsd:element name="name" type="xsd:string" minOccurs="1"/> + <xsd:element name="revision" type="tpkg:revision" + maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="revision"> + <xsd:sequence> + <xsd:element name="number" type="xsd:string" minOccurs="1"/> + <xsd:element name="rules" type="xsd:string" minOccurs="1"/> + <xsd:element name="status" type="tpkg:revisionstatus" minOccurs="1"/> + <xsd:element name="platform" type="tpkg:platform" minOccurs="1"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="revisionstatus"> + <xsd:sequence> + <xsd:element name="message" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="platform"> + <xsd:sequence> + <xsd:element name="os" type="xsd:string"/> + <xsd:element name="arch" type="xsd:string"/> + <xsd:element name="packages" type="tpkg:packages"/> + <xsd:element name="logs" type="tpkg:logs"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="logs"> + <xsd:sequence> + <xsd:element name="log" type="tpkg:log"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType nam="log"> + <xsd:sequence> + <xsd:element name="name" type="xsd:string"/> + <xsd:element name="path" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + + <xsd:complexType name="packages"> + <xsd:sequence> + <xsd:element name="package" type="tpkg:package"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="package"> + <xsd:sequence> + <xsd:element name="name" type="xsd:string" minOccurs="1"/> + <xsd:element name="path" type="xsd:string" minOccurs="1"> + <xsd:element name="checksum" type="xsd:string"/> + <xsd:element name="type" type="tpkg:pkgtype" minOccurs="1"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:simpleType name="pkgtype"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="binary"/> + <xsd:enumeration value="source"/> + </xsd:restriction> + </xsd:simpleType> +</xsd:schema>
--- a/treepkg/packager.py Wed Jul 07 15:40:48 2010 +0000 +++ b/treepkg/packager.py Thu Jul 08 10:07:39 2010 +0000 @@ -641,7 +641,7 @@ def __init__(self, package_tracks, check_interval, revision=None, instructions_file=None, do_svn_update=True, - stop_on_error=False): + stop_on_error=False, name=""): self.package_tracks = package_tracks self.check_interval = check_interval self.revision = revision @@ -649,6 +649,7 @@ self.stop_on_error = stop_on_error self.instructions_file = instructions_file self.instructions_file_removed = False + self.name = name self.sort_tracks() def sort_tracks(self):
--- a/treepkg/readconfig.py Wed Jul 07 15:40:48 2010 +0000 +++ b/treepkg/readconfig.py Thu Jul 08 10:07:39 2010 +0000 @@ -84,6 +84,7 @@ treepkg_desc = [ ("check_interval", int), "instructions_file", + ("name", str, "") ]
--- a/treepkg/status/__init__.py Wed Jul 07 15:40:48 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -# Copyright (C) 2007 by Intevation GmbH -# Authors: -# Bernhard Herzog <bh@intevation.de> -# -# This program is free software under the GPL (>=v2) -# Read the file COPYING coming with the software for details.
--- a/treepkg/status/status.py Wed Jul 07 15:40:48 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ -# 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) -
--- a/treepkg/status/status.xsd Wed Jul 07 15:40:48 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:tpkg="http://wald.intevation.org/projects/treepkg/" - targetNamespace="http://wald.intevation.org/projects/treepkg/"> - - <xsd:element name="treepkg"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="tracks" type="tpkg:tracks"/> - <xsd:element name="info" type="tpkg:info" minOccurs="1"/> - </xsd:sequence> - <!-- xml schema version --> - <xsd:attribute name="version" type="xsd:string"/> - </xsd:complexType> - </xsd:element> - - <xsd:complexType name="info"> - <xsd:sequence> - <xsd:element name="name" type="xsd:string" minOccurs="1"/> - <xsd:element name="treepkgpath" type="xsd:string"/> - <xsd:element name="millpath" type="xsd:string"/> - <!-- treepkg version e.g. svn revision --> - <xsd:element name="version" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="tracks"> - <xsd:sequence> - <xsd:element name="track" type="tpkg:track" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="track"> - <xsd:sequence> - <xsd:element name="name" type="xsd:string" minOccurs="1"/> - <xsd:element name="revision" type="tpkg:revision" - maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="revision"> - <xsd:sequence> - <xsd:element name="number" type="xsd:string" minOccurs="1"/> - <xsd:element name="rules" type="xsd:string" minOccurs="1"/> - <xsd:element name="status" type="tpkg:revisionstatus" minOccurs="1"/> - <xsd:element name="platform" type="tpkg:platform" minOccurs="1"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="revisionstatus"> - <xsd:sequence> - <xsd:element name="message" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="platform"> - <xsd:sequence> - <xsd:element name="os" type="xsd:string"/> - <xsd:element name="arch" type="xsd:string"/> - <xsd:element name="packages" type="tpkg:packages"/> - <xsd:element name="logs" type="tpkg:logs"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="logs"> - <xsd:sequence> - <xsd:element name="log" type="tpkg:log"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType nam="log"> - <xsd:sequence> - <xsd:element name="name" type="xsd:string"/> - <xsd:element name="path" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - - - <xsd:complexType name="packages"> - <xsd:sequence> - <xsd:element name="package" type="tpkg:package"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="package"> - <xsd:sequence> - <xsd:element name="name" type="xsd:string" minOccurs="1"/> - <xsd:element name="path" type="xsd:string" minOccurs="1"> - <xsd:element name="checksum" type="xsd:string"/> - <xsd:element name="type" type="tpkg:pkgtype" minOccurs="1"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:simpleType name="pkgtype"> - <xsd:restriction base="xsd:string"> - <xsd:enumeration value="binary"/> - <xsd:enumeration value="source"/> - </xsd:restriction> - </xsd:simpleType> -</xsd:schema>