changeset 395:0ba451c4a856 treepkg-status

implemented nearly all info only arch and os info are missing
author Bjoern Ricks <bricks@intevation.de>
date Fri, 09 Jul 2010 13:15:15 +0000
parents bfd1c6a155fa
children 343af65e808b
files treepkg/info/status.py treepkg/info/status.xsd
diffstat 2 files changed, 86 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- 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 <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)
+    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>
+        for checksum in self.checksums:
+            root.appendChild(checksum.toxml())
+        # add <type>
+        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
--- 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 @@
         <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="checksum" type="tpkg:checksum"
+                         maxOccurs="unbounded" default="md5"/>
             <xsd:element name="type" type="tpkg:pkgtype" minOccurs="1"/>
         </xsd:sequence>
     </xsd:complexType>
 
+    <xsd:complexType name="checksum">
+        <xsd:sequence>
+            <xsd:element name="checksum" type="xsd:string"/>
+        </xsd:sequence>
+        <xsd:attribute name="type" type="xsd:string"/>
+    </xsd:complexType>
+
     <xsd:simpleType name="pkgtype">
         <xsd:restriction base="xsd:string">
             <xsd:enumeration value="binary"/>
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)