annotate treepkg/info/status.py @ 434:c6d88d70bc43 treepkg-status

fixed another typo
author Bjoern Ricks <bricks@intevation.de>
date Thu, 29 Jul 2010 14:59:10 +0000
parents 9926ced5d477
children 8be095183151
rev   line source
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
1 # Copyright (C) 2010 by Intevation GmbH
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
2 # Authors:
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
3 # Bjoern Ricks <bjoern.ricks@intevation.de>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
4 #
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
5 # This program is free software under the GPL (>=v2)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
6 # Read the file COPYING coming with the software for details.
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
7
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
8 """Build treepkg status information"""
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
9
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
10 import os.path
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
11 import xml.dom.minidom
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
12
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
13 from treepkg.report import get_packager_group
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
14 from treepkg.util import md5sum
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
15 from treepkg.info.package import BinaryPackage
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
16
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
17 TREEPKG_NAMESPACE_URI = "http://wald.intevation.org/projects/treepkg/"
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
18 TREEPKG_NAMESPACE_PREFIX = "tpkg"
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
19
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
20 def createTpkgElement(doc, name):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
21 return doc.createElementNS(TREEPKG_NAMESPACE_URI, name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
22
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
23 def createTpkgRoot(name):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
24 domimpl = xml.dom.minidom.getDOMImplementation()
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
25 doc = domimpl.createDocument(TREEPKG_NAMESPACE_URI, name, None)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
26 root = doc.documentElement
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
27 return (doc, root)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
28
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
29 def getTextFromNode(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
30 if not node:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
31 return None
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
32 textnode = node.firstChild
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
33 if not textnode or textnode.nodeType != node.TEXT_NODE:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
34 return None
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
35 return textnode.data
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
36
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
37 def getChild(node, name, required=False):
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
38 childs = getChilds(node, name, required)
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
39 if not childs or len(childs) == 0:
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
40 return None
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
41 else:
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
42 return childs[0]
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
43
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
44 def getChilds(node, name, required=False):
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
45 if not node:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
46 if required:
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
47 raise TreepkgInfoException("Element %s is required as child. But"
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
48 "parent element is not available.")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
49 return None
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
50 childs = node.getElementsByTagName(name)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
51 if not childs:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
52 if required:
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
53 raise TreepkgInfoException("Element %s is required as child for %s."
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
54 "The XML file must be invalid." % (name, node.nodeName))
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
55 return None
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
56 return childs
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
57
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
58
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
59 class TreepkgInfoException(Exception):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
60 """ Exception class for TreepkgInfo """
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
61
388
1af04bfbb1d0 moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
62 class TreepkgInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
63
413
94a6ae627b31 implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents: 412
diff changeset
64 def __init__(self, config, numnewestrev=-1, success=False):
399
04310ad0063e let the user specify num revisions that should be shown in the info
Bjoern Ricks <bricks@intevation.de>
parents: 398
diff changeset
65 self.numnewestrev = numnewestrev
413
94a6ae627b31 implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents: 412
diff changeset
66 self.success = success
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
67 group = get_packager_group(config)
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
68 treepkgrootinfo = TreepkgRootInfo(group.name, group.treepkg_dir,
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
69 group.tracks_dir)
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
70 version = "1.0"
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
71 self.tpkgroot = TreepkgRoot(version, treepkgrootinfo)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
72 tracks = group.get_package_tracks()
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
73
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
74 for track in tracks:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
75 trackinfo = TreepkgTrackInfo(track.name)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
76 self.tpkgroot.add_track(trackinfo)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
77 self.add_revisions(track, trackinfo)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
78
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
79 def toxml(self):
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
80 return self.tpkgroot.toxml()
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
81
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
82 @staticmethod
409
ecc671a84a73 fixed small bugs
Bjoern Ricks <bricks@intevation.de>
parents: 407
diff changeset
83 def fromxml(xmlstr):
ecc671a84a73 fixed small bugs
Bjoern Ricks <bricks@intevation.de>
parents: 407
diff changeset
84 doc = xml.dom.minidom.parseString(xmlstr)
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
85 root = doc.documentElement
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
86 if not root.tagName == "treepkg":
409
ecc671a84a73 fixed small bugs
Bjoern Ricks <bricks@intevation.de>
parents: 407
diff changeset
87 raise TreepkgInfoException("XML is not valid for treepkginfo")
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
88 return TreepkgRoot.fromxml(root)
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
89
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
90 def add_revisions(self, track, trackinfo):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
91 revisions = track.get_revisions()
400
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
92 revisions = sorted(revisions, key=lambda r: r.status.start,
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
93 reverse=True)
434
c6d88d70bc43 fixed another typo
Bjoern Ricks <bricks@intevation.de>
parents: 433
diff changeset
94 candidates = revisions
432
acf97c1a06e0 fix handling of showing only successfull builds together with num packages
Bjoern Ricks <bricks@intevation.de>
parents: 413
diff changeset
95 if self.success: # skip not successful builds
acf97c1a06e0 fix handling of showing only successfull builds together with num packages
Bjoern Ricks <bricks@intevation.de>
parents: 413
diff changeset
96 candidates = [rev for rev in revisions
434
c6d88d70bc43 fixed another typo
Bjoern Ricks <bricks@intevation.de>
parents: 433
diff changeset
97 if rev.status.status.finished
c6d88d70bc43 fixed another typo
Bjoern Ricks <bricks@intevation.de>
parents: 433
diff changeset
98 and not rev.status.status.error]
432
acf97c1a06e0 fix handling of showing only successfull builds together with num packages
Bjoern Ricks <bricks@intevation.de>
parents: 413
diff changeset
99
400
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
100 if self.numnewestrev > 0:
432
acf97c1a06e0 fix handling of showing only successfull builds together with num packages
Bjoern Ricks <bricks@intevation.de>
parents: 413
diff changeset
101 canditates = candidates[:self.numnewestrev]
399
04310ad0063e let the user specify num revisions that should be shown in the info
Bjoern Ricks <bricks@intevation.de>
parents: 398
diff changeset
102
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
103 arch = None
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
104
432
acf97c1a06e0 fix handling of showing only successfull builds together with num packages
Bjoern Ricks <bricks@intevation.de>
parents: 413
diff changeset
105 for rev in candidates:
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
106 revision = rev.revision
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
107 rules_revision = rev.rules_revision
398
09b7b7bf0b04 fixed status line for revision
Bjoern Ricks <bricks@intevation.de>
parents: 397
diff changeset
108 status = rev.status.status.description # extend status
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
109
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
110 sources = rev.list_source_files()
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
111 binaries = rev.list_binary_files()
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
112
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
113 revinfo = TreepkgTrackRevisionInfo(revision, rules_revision,
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
114 status)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
115 logs = rev.get_log_files()
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
116 for (title, filename) in logs:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
117 loginfo = TreepkgLogInfo(title, filename)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
118 revinfo.add_log(loginfo)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
119 for source in sources:
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
120 self.add_package(revinfo, source, "source")
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
121 for binary in binaries:
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
122 binpackage = BinaryPackage(binary)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
123 arch = binpackage.get_architecture()
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
124 self.add_package(revinfo, binary, "binary", arch)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
125
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
126 trackinfo.add_revision(revinfo)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
127
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
128 def add_package(self, revision, file, type, arch=None):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
129 name = os.path.basename(file)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
130 checksum = md5sum(file)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
131 checksuminfo = TreepkgChecksumInfo(checksum, "md5")
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
132 pkginfo = TreepkgPackageInfo(name, file, type, arch)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
133 pkginfo.add_checksum(checksuminfo)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
134 revision.add_package(pkginfo)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
135
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
136 class TreepkgRoot:
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
137
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
138 def __init__(self, version, info):
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
139 self.version = version
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
140 self.info = info
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
141 self.tracks = []
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
142
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
143 def add_track(self, track):
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
144 self.tracks.append(track)
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
145
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
146 def toxml(self):
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
147 (doc, root) = createTpkgRoot("treepkg")
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
148 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "version", self.version)
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
149 if len(self.tracks) > 0:
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
150 tracksele = createTpkgElement(doc, "tracks")
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
151 for track in self.tracks:
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
152 tracksele.appendChild(track.toxml())
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
153 root.appendChild(tracksele)
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
154 root.appendChild(self.info.toxml())
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
155 return root
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
156
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
157 @staticmethod
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
158 def fromxml(node):
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
159 version = node.getAttribute("version")
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
160 tracksele = getChild(node, "tracks")
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
161 trackeles = getChilds(tracksele, "track")
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
162 infoele = getChild(node, "info")
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
163 treepkgrootinfo = TreepkgRootInfo.fromxml(infoele)
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
164 treepkgroot = TreepkgRoot(version, treepkgrootinfo)
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
165 tracks = []
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
166 for trackele in trackeles:
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
167 tracks.append(TreepkgTrackInfo.fromxml(trackele))
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
168 treepkgroot.tracks = tracks
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
169 return treepkgroot
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
170
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
171 class TreepkgRootInfo:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
172
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
173 def __init__(self, name, treepkgpath=None, trackspath=None, version=None):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
174 self.name = name
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
175 self.treepkgpath = treepkgpath
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
176 self.trackspath = trackspath
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
177 self.version = version
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
178
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
179 def toxml(self):
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
180 (doc, root) = createTpkgRoot("info")
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
181 # add <name>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
182 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
183 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
184 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
185 root.appendChild(nameele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
186 # add <treepkgpath>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
187 if self.treepkgpath:
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
188 treepkgpathele = createTpkgElement(doc, "treepkgpath")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
189 text = doc.createTextNode(self.treepkgpath)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
190 treepkgpathele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
191 root.appendChild(treepkgpathele)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
192 # add <trackspath>
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
193 if self.trackspath:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
194 trackspathele = createTpkgElement(doc, "trackspath")
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
195 text = doc.createTextNode(self.trackspath)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
196 trackspathele.appendChild(text)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
197 root.appendChild(trackspathele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
198 # add <version>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
199 if self.version:
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
200 versionele = createTpkgElement(doc, "version")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
201 text = doc.createTextNode(self.version)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
202 versionele.appendChild(text)
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
203 root.appendChild(versionele)
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
204 return root
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
205
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
206 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
207 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
208 version = node.getAttribute("version")
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
209 nameele = getChild(node, "name", True)
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
210 name = getTextFromNode(nameele)
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
211 treepkgpathele = getChild(node, "treepkgpath")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
212 treepkgpath = getTextFromNode(treepkgpathele)
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
213 trackspathele = getChild(node, "trackspath")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
214 trackspath = getTextFromNode(trackspathele)
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
215 return TreepkgRootInfo(name, treepkgpath, trackspath, version)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
216
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
217 class TreepkgTrackInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
218
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
219 def __init__(self, name, os=None):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
220 self.name = name
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
221 self.os = os
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
222 self.revisions = []
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
223
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
224 def add_revision(self, revision):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
225 self.revisions.append(revision)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
226
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
227 def toxml(self):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
228 (doc, root) = createTpkgRoot("track")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
229 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
230 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
231 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
232 root.appendChild(nameele)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
233 for rev in self.revisions:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
234 root.appendChild(rev.toxml())
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
235 if not self.os is None:
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
236 osele = createTpkgElement(doc, "os")
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
237 text = doc.createTextNode(self.os)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
238 osele.appendChild(text)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
239 root.appendChild(osele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
240 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
241
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
242 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
243 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
244 nameele = getChild(node, "name", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
245 name = getTextFromNode(nameele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
246 osele = getChild(node, "os")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
247 os = getTextFromNode(osele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
248 treepkgtrackinfo = TreepkgTrackInfo(name, os)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
249 treepkgtrackinfo.revisions = []
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
250 revisioneles = node.getElementsByTagName("revision")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
251 for revele in revisioneles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
252 treepkgrevision = TreepkgTrackRevisionInfo.fromxml(revele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
253 treepkgtrackinfo.revisions.append(treepkgrevision)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
254 return treepkgtrackinfo
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
255
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
256
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
257 class TreepkgTrackRevisionInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
258
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
259 def __init__(self, number, rules, status):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
260 self.number = number
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
261 self.rules = rules
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
262 self.status = status
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
263 self.packages = []
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
264 self.logs = []
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
265
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
266 def add_package(self, package):
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
267 self.packages.append(package)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
268
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
269 def add_log(self, log):
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
270 self.logs.append(log)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
271
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
272 def toxml(self):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
273 (doc, root) = createTpkgRoot("revision")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
274 # add <number>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
275 numberele = createTpkgElement(doc, "number")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
276 text = doc.createTextNode(self.number)
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
277 numberele.appendChild(text)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
278 root.appendChild(numberele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
279 # add <rules>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
280 rulesele = createTpkgElement(doc, "rules")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
281 text = doc.createTextNode(self.rules)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
282 rulesele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
283 root.appendChild(rulesele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
284 # add <status><message></message></status>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
285 statusele = createTpkgElement(doc, "status")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
286 messageele = createTpkgElement(doc, "message")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
287 text = doc.createTextNode(self.status)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
288 messageele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
289 statusele.appendChild(messageele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
290 root.appendChild(statusele)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
291 # add <packages>
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
292 packagesele = createTpkgElement(doc, "packages")
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
293 for package in self.packages:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
294 packagesele.appendChild(package.toxml())
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
295 root.appendChild(packagesele)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
296 # add <logs>
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
297 logsele = createTpkgElement(doc, "logs")
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
298 for log in self.logs:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
299 logsele.appendChild(log.toxml())
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
300 root.appendChild(logsele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
301 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
302
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
303 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
304 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
305 numberele = getChild(node, "number", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
306 number = getTextFromNode(numberele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
307 rulesele = getChild(node, "rules", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
308 rules = getTextFromNode(rulesele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
309 statusele = getChild(node, "status", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
310 messageele = getChild(statusele, "message")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
311 message = getTextFromNode(messageele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
312 treepkgrevisioninfo = TreepkgTrackRevisionInfo(number, rules, message)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
313 treepkgrevisioninfo.packages = []
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
314 treepkgrevisioninfo.logs = []
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
315 packagesele = getChild(node, "packages")
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
316 packageeles = getChilds(packagesele, "package")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
317 for packageele in packageeles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
318 treepkgrevisioninfo.packages.append(
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
319 TreepkgPackageInfo.fromxml(packageele))
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
320 logsele = getChild(node, "logs")
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
321 logeles = getChilds(logsele, "log")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
322 for logele in logeles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
323 treepkgrevisioninfo.logs.append(
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
324 TreepkgLogInfo.fromxml(logele))
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
325 return treepkgrevisioninfo
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
326
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
327 class TreepkgLogInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
328
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
329 def __init__(self, name, path):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
330 self.name = name
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
331 self.path = path
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
332
388
1af04bfbb1d0 moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
333 def toxml(self):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
334 (doc, root) = createTpkgRoot("log")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
335 # add <name>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
336 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
337 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
338 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
339 root.appendChild(nameele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
340 # add path
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
341 pathele = createTpkgElement(doc, "path")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
342 text = doc.createTextNode(self.path)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
343 pathele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
344 root.appendChild(pathele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
345 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
346
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
347 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
348 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
349 nameele = getChild(node, "name", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
350 name = getTextFromNode(nameele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
351 pathele = getChild(node, "path", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
352 path = getTextFromNode(pathele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
353 return TreepkgLogInfo(name, path)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
354
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
355 class TreepkgPackageInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
356
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
357 def __init__(self, name, path, type, arch):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
358 self.name = name
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
359 self.path = path
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
360 self.type = type
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
361 self.arch = arch
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
362 self.checksums = []
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
363
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
364 def toxml(self):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
365 (doc, root) = createTpkgRoot("package")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
366 # add <name>
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
367 nameele = createTpkgElement(doc, "name")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
368 text = doc.createTextNode(self.name)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
369 nameele.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
370 root.appendChild(nameele)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
371 # add <path>
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
372 pathele = createTpkgElement(doc, "path")
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
373 text = doc.createTextNode(self.path)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
374 pathele.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
375 root.appendChild(pathele)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
376 # add <checksum>
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
377 for checksum in self.checksums:
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
378 root.appendChild(checksum.toxml())
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
379 # add <type>
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
380 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "type", self.type)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
381 if not self.arch is None:
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
382 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "arch", self.arch)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
383 return root
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
384
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
385 def add_checksum(self, checksum):
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
386 self.checksums.append(checksum)
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
387
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
388 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
389 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
390 nameele = getChild(node, "name", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
391 name = getTextFromNode(nameele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
392 pathele = getChild(node, "path", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
393 path = getTextFromNode(pathele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
394 ptype = node.getAttribute("type")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
395 arch = node.getAttribute("arch")
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
396 if len(arch) == 0:
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
397 arch = None
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
398 packageinfo = TreepkgPackageInfo(name, path, ptype, arch)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
399 checksumeles = node.getElementsByTagName("checksum")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
400 for checksumele in checksumeles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
401 packageinfo.checksums.append(TreepkgChecksumInfo.fromxml(checksumele))
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
402 return packageinfo
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
403
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
404 class TreepkgChecksumInfo:
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
405
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
406 def __init__(self, checksum, type="md5"):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
407 self.checksum = checksum
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
408 self.type = type
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
409
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
410 def toxml(self):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
411 (doc, root) = createTpkgRoot("checksum")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
412 text = doc.createTextNode(self.checksum)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
413 root.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
414 # add attribute type
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
415 if type:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
416 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "type", self.type)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
417 return root
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
418
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
419 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
420 def fromxml(node):
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
421 checksum = getTextFromNode(node)
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
422 ctype = node.getAttribute("type")
412
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
423 if len(ctype) == 0:
58ecf7c0ecba improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents: 411
diff changeset
424 return TreepkgChecksumInfo(checksum)
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
425 return TreepkgChecksumInfo(checksum, ctype)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)