changeset 392:e2afbd3c2bf1 treepkg-status

write first info about tracks
author Bjoern Ricks <bricks@intevation.de>
date Thu, 08 Jul 2010 16:11:13 +0000
parents 89ecca5d262e
children 5fe26e7f6e2d
files bin/treepkginfo.py test/test_info.py treepkg/info/status.py
diffstat 3 files changed, 82 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/treepkginfo.py	Thu Jul 08 16:11:13 2010 +0000
@@ -0,0 +1,27 @@
+#! /usr/bin/python
+# 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.
+
+"""Receive the status of a treepkg"""
+
+import treepkgcmd
+
+from treepkg.info import status
+
+from treepkg.options import create_parser
+
+def parse_commandline():
+    parser = create_parser()
+ 
+    return parser.parse_args()
+
+def main():
+    options, args = parse_commandline()
+
+    tpkginfo = status.TreepkgInfo(options.config_file)
+
+main()
--- a/test/test_info.py	Thu Jul 08 16:08:39 2010 +0000
+++ b/test/test_info.py	Thu Jul 08 16:11:13 2010 +0000
@@ -14,17 +14,18 @@
 test_dir = os.path.dirname(__file__)
 sys.path.append(os.path.join(test_dir, os.pardir))
 
-from treepkg.info.status import TreepkgInfo
+from treepkg.info.status import *
 from treepkg.report import get_packager_group
 from filesupport import FileTestMixin
 
-class TreepkgInfoExampleTest(unittest.TestCase, FileTestMixin):
+class TreepkgInfoTest(unittest.TestCase, FileTestMixin):
     config_contents = """\
 [DEFAULT]
-treepkg_dir: /home/builder/mill
-tracks_dir: %(treepkg_dir)s/tracks
+#treepkg_dir: /home/builder/mill
+#tracks_dir: %(treepkg_dir)s/tracks
+tracks_dir: /home/builder/mill/tracks
 root_cmd: sudo
-pbuilder_dir: %(treepkg_dir)s/pbuilder
+pbuilder_dir: %(tracks_dir)s/pbuilder
 builderconfig: %(pbuilder_dir)s/pbuilderrc
 deb_email: treepkg@example.com
 deb_fullname: TreePKG
@@ -32,7 +33,7 @@
 handle_dependencies: False
 
 [treepkg]
-instructions_file: %(treepkg_dir)s/instructions
+instructions_file: %(tracks_dir)s/instructions
 check_interval: 3600
 name: testtreepkginfo
 
@@ -67,16 +68,16 @@
 
     def test_createinfo(self):
         config_file = os.path.join(self.directory, "treepkg.cfg")
-        group = get_packager_group(config_file)
-        tpginfo = TreepkgInfo(group.name)
-        print tpginfo.toxml().toxml()
-        self.assertEquals("testtreepkginfo", tpginfo.name)
+        tpkginfo = TreepkgInfo(config_file)
+        print tpkginfo.toxml().toxml()
+        tpkgroot = tpkginfo.tpkgroot
+        self.assertEquals("testtreepkginfo", tpkgroot.name)
  
 
-class TreepkgInfoTest(unittest.TestCase):
+class TreepkgRootInfoTest(unittest.TestCase):
 
     def test_toxml(self):
-        status = TreepkgInfo("testtreepkg")
+        status = TreepkgRootInfo("testtreepkg")
         dom = status.toxml()
         xml = dom.toxml()
         self.assertEquals("<status><name>testtreepkg</name></status>", xml)
--- a/treepkg/info/status.py	Thu Jul 08 16:08:39 2010 +0000
+++ b/treepkg/info/status.py	Thu Jul 08 16:11:13 2010 +0000
@@ -9,6 +9,9 @@
 
 import xml.dom.minidom
 
+from treepkg.report import get_packager_group
+
+
 TREEPKG_NAMESPACE_URI = "http://wald.intevation.org/projects/treepkg/"
 TREEPKG_NAMESPACE_PREFIX = "tpkg"
 
@@ -23,11 +26,31 @@
 
 class TreepkgInfo:
 
-    def __init__(self, name, treepkgpath=None, millpath=None, version=None):
+    def __init__(self, config):
+        group = get_packager_group(config)
+        self.tpkgroot = TreepkgRootInfo(group.name, group.treepkg_dir, 
+                                        group.tracks_dir)
+        tracks = group.get_package_tracks()
+
+        for track in tracks:
+            trackinfo = TreepkgTrackInfo(track.name)
+            self.tpkgroot.add_track(trackinfo)
+
+    def toxml(self):
+        return self.tpkgroot.toxml()
+
+
+class TreepkgRootInfo:
+
+    def __init__(self, name, treepkgpath=None, trackspath=None, version=None):
         self.name = name
         self.treepkgpath = treepkgpath
-        self.millpath = millpath
+        self.trackspath = trackspath
         self.version = version
+        self.tracks = []
+
+    def add_track(self, track):
+        self.tracks.append(track)
 
     def toxml(self):
         (doc, root) = createTpkgRoot("status")
@@ -42,21 +65,26 @@
             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 <trackspath>
+        if self.trackspath:
+            trackspathele = createTpkgElement(doc, "trackspath")
+            text = doc.createTextNode(self.trackspath)
+            trackspathele.appendChild(text)
+            root.appendChild(trackspathele)
         # add <version>
         if self.version:
             versionele = createTpkgElement(doc, "version")
             text = doc.createTextNode(self.version)
             versionele.appendChild(text)
             root.appendChild(version)
+        if len(self.tracks) > 0:
+            tracksele = createTpkgElement(doc, "tracks")
+            for track in self.tracks:
+                tracksele.appendChild(track.toxml())
+            root.appendChild(tracksele)
         return root
 
-class TreepkgTrack:
+class TreepkgTrackInfo:
     
     def __init__(self, name):
         self.name = name
@@ -71,11 +99,11 @@
         text = doc.createTextNode(self.name)
         nameele.appendChild(text)
         root.appendChild(nameele)
-        for rev in self.revision:
+        for rev in self.revisions:
             root.appendChild(rev.toxml())
         return root
 
-class TreepkgTrackRevision:
+class TreepkgTrackRevisionInfo:
 
     def __init__(self, number, rules, status, platform):
         self.number = number
@@ -106,7 +134,7 @@
         root.appendChild(platform.toxml())
         return root
 
-class TreepkgPlatform:
+class TreepkgPlatformInfo:
 
     def __init__(self, os, arch):
         self.os = os
@@ -144,7 +172,7 @@
         root.appendChild(logsele)
         return root
 
-class TreepkgLog:
+class TreepkgLogInfo:
 
     def __init__(self, name, path):
         self.name = name
@@ -164,7 +192,7 @@
         root.appendChild(pathele)
         return root
 
-class TreepkgPackage:
+class TreepkgPackageInfo:
         
         def __init__(self, name, path, type, checksum = None):
             self.name = name
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)