[Treepkg-commits] r352 - in branches/treepkg-status: bin test treepkg/info

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jul 8 18:11:13 CEST 2010


Author: bricks
Date: 2010-07-08 18:11:13 +0200 (Thu, 08 Jul 2010)
New Revision: 352

Added:
   branches/treepkg-status/bin/treepkginfo.py
Modified:
   branches/treepkg-status/test/test_info.py
   branches/treepkg-status/treepkg/info/status.py
Log:
write first info about tracks


Added: branches/treepkg-status/bin/treepkginfo.py
===================================================================
--- branches/treepkg-status/bin/treepkginfo.py	2010-07-08 16:08:39 UTC (rev 351)
+++ branches/treepkg-status/bin/treepkginfo.py	2010-07-08 16:11:13 UTC (rev 352)
@@ -0,0 +1,27 @@
+#! /usr/bin/python
+# Copyright (C) 2010 by Intevation GmbH
+# Authors:
+# Bjoern Ricks <bjoern.ricks at 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()


Property changes on: branches/treepkg-status/bin/treepkginfo.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: branches/treepkg-status/test/test_info.py
===================================================================
--- branches/treepkg-status/test/test_info.py	2010-07-08 16:08:39 UTC (rev 351)
+++ branches/treepkg-status/test/test_info.py	2010-07-08 16:11:13 UTC (rev 352)
@@ -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 at 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)

Modified: branches/treepkg-status/treepkg/info/status.py
===================================================================
--- branches/treepkg-status/treepkg/info/status.py	2010-07-08 16:08:39 UTC (rev 351)
+++ branches/treepkg-status/treepkg/info/status.py	2010-07-08 16:11:13 UTC (rev 352)
@@ -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,12 +26,32 @@
 
 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")
         # add <name>
@@ -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



More information about the Treepkg-commits mailing list