annotate treepkg/info/status.py @ 435:8be095183151 treepkg-status

fixed another typo treepkg is really slow with many revisions
author Bjoern Ricks <bricks@intevation.de>
date Thu, 29 Jul 2010 16:05:54 +0000
parents c6d88d70bc43
children 3a3cad8f6f60
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
435
8be095183151 fixed another typo
Bjoern Ricks <bricks@intevation.de>
parents: 434
diff changeset
95
432
acf97c1a06e0 fix handling of showing only successfull builds together with num packages
Bjoern Ricks <bricks@intevation.de>
parents: 413
diff changeset
96 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
97 candidates = [rev for rev in revisions
434
c6d88d70bc43 fixed another typo
Bjoern Ricks <bricks@intevation.de>
parents: 433
diff changeset
98 if rev.status.status.finished
c6d88d70bc43 fixed another typo
Bjoern Ricks <bricks@intevation.de>
parents: 433
diff changeset
99 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
100
400
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
101 if self.numnewestrev > 0:
435
8be095183151 fixed another typo
Bjoern Ricks <bricks@intevation.de>
parents: 434
diff changeset
102 candidates = 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
103
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
104 arch = None
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
105
432
acf97c1a06e0 fix handling of showing only successfull builds together with num packages
Bjoern Ricks <bricks@intevation.de>
parents: 413
diff changeset
106 for rev in candidates:
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
107 revision = rev.revision
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
108 rules_revision = rev.rules_revision
398
09b7b7bf0b04 fixed status line for revision
Bjoern Ricks <bricks@intevation.de>
parents: 397
diff changeset
109 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
110
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
111 sources = rev.list_source_files()
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
112 binaries = rev.list_binary_files()
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
113
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
114 revinfo = TreepkgTrackRevisionInfo(revision, rules_revision,
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
115 status)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
116 logs = rev.get_log_files()
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
117 for (title, filename) in logs:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
118 loginfo = TreepkgLogInfo(title, filename)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
119 revinfo.add_log(loginfo)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
120 for source in sources:
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
121 self.add_package(revinfo, source, "source")
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
122 for binary in binaries:
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
123 binpackage = BinaryPackage(binary)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
124 arch = binpackage.get_architecture()
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
125 self.add_package(revinfo, binary, "binary", arch)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
126
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
127 trackinfo.add_revision(revinfo)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
128
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
129 def add_package(self, revision, file, type, arch=None):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
130 name = os.path.basename(file)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
131 checksum = md5sum(file)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
132 checksuminfo = TreepkgChecksumInfo(checksum, "md5")
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
133 pkginfo = TreepkgPackageInfo(name, file, type, arch)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
134 pkginfo.add_checksum(checksuminfo)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
135 revision.add_package(pkginfo)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
136
410
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
137 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
138
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
139 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
140 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
141 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
142 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
143
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
144 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
145 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
146
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
147 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
148 (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
149 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
150 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
151 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
152 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
153 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
154 root.appendChild(tracksele)
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
155 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
156 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
157
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
158 @staticmethod
5e8546444a8e added a new root element which is called TreepkgRoot for Treepkg Info classes
Bjoern Ricks <bricks@intevation.de>
parents: 409
diff changeset
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
172 class TreepkgRootInfo:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
173
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
174 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
175 self.name = name
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
176 self.treepkgpath = treepkgpath
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
177 self.trackspath = trackspath
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
178 self.version = version
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
179
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
180 def toxml(self):
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
181 (doc, root) = createTpkgRoot("info")
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
182 # add <name>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
183 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
184 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
185 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
186 root.appendChild(nameele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
187 # add <treepkgpath>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
188 if self.treepkgpath:
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
189 treepkgpathele = createTpkgElement(doc, "treepkgpath")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
190 text = doc.createTextNode(self.treepkgpath)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
191 treepkgpathele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
192 root.appendChild(treepkgpathele)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
193 # add <trackspath>
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
194 if self.trackspath:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
195 trackspathele = createTpkgElement(doc, "trackspath")
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
196 text = doc.createTextNode(self.trackspath)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
197 trackspathele.appendChild(text)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
198 root.appendChild(trackspathele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
199 # add <version>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
200 if self.version:
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
201 versionele = createTpkgElement(doc, "version")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
202 text = doc.createTextNode(self.version)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
203 versionele.appendChild(text)
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
204 root.appendChild(versionele)
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
205 return root
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
206
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
207 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
208 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
209 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
210 nameele = getChild(node, "name", True)
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
211 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
212 treepkgpathele = getChild(node, "treepkgpath")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
213 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
214 trackspathele = getChild(node, "trackspath")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
215 trackspath = getTextFromNode(trackspathele)
411
8dd64f8bf572 fixed some small issues
Bjoern Ricks <bricks@intevation.de>
parents: 410
diff changeset
216 return TreepkgRootInfo(name, treepkgpath, trackspath, version)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
217
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
218 class TreepkgTrackInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
219
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
220 def __init__(self, name, os=None):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
221 self.name = name
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
222 self.os = os
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
223 self.revisions = []
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
224
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
225 def add_revision(self, revision):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
226 self.revisions.append(revision)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
227
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
228 def toxml(self):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
229 (doc, root) = createTpkgRoot("track")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
230 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
231 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
232 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
233 root.appendChild(nameele)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
234 for rev in self.revisions:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
235 root.appendChild(rev.toxml())
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
236 if not self.os is None:
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
237 osele = createTpkgElement(doc, "os")
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
238 text = doc.createTextNode(self.os)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
239 osele.appendChild(text)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
240 root.appendChild(osele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
241 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
242
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
243 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
244 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
245 nameele = getChild(node, "name", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
246 name = getTextFromNode(nameele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
247 osele = getChild(node, "os")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
248 os = getTextFromNode(osele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
249 treepkgtrackinfo = TreepkgTrackInfo(name, os)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
250 treepkgtrackinfo.revisions = []
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
251 revisioneles = node.getElementsByTagName("revision")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
252 for revele in revisioneles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
253 treepkgrevision = TreepkgTrackRevisionInfo.fromxml(revele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
254 treepkgtrackinfo.revisions.append(treepkgrevision)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
255 return treepkgtrackinfo
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
256
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
257
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
258 class TreepkgTrackRevisionInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
259
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
260 def __init__(self, number, rules, status):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
261 self.number = number
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
262 self.rules = rules
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
263 self.status = status
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
264 self.packages = []
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
265 self.logs = []
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
266
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
267 def add_package(self, package):
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
268 self.packages.append(package)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
269
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
270 def add_log(self, log):
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
271 self.logs.append(log)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
272
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
273 def toxml(self):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
274 (doc, root) = createTpkgRoot("revision")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
275 # add <number>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
276 numberele = createTpkgElement(doc, "number")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
277 text = doc.createTextNode(self.number)
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
278 numberele.appendChild(text)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
279 root.appendChild(numberele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
280 # add <rules>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
281 rulesele = createTpkgElement(doc, "rules")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
282 text = doc.createTextNode(self.rules)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
283 rulesele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
284 root.appendChild(rulesele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
285 # add <status><message></message></status>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
286 statusele = createTpkgElement(doc, "status")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
287 messageele = createTpkgElement(doc, "message")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
288 text = doc.createTextNode(self.status)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
289 messageele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
290 statusele.appendChild(messageele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
291 root.appendChild(statusele)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
292 # add <packages>
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
293 packagesele = createTpkgElement(doc, "packages")
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
294 for package in self.packages:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
295 packagesele.appendChild(package.toxml())
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
296 root.appendChild(packagesele)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
297 # add <logs>
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
298 logsele = createTpkgElement(doc, "logs")
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
299 for log in self.logs:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
300 logsele.appendChild(log.toxml())
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
301 root.appendChild(logsele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
302 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
303
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
304 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
305 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
306 numberele = getChild(node, "number", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
307 number = getTextFromNode(numberele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
308 rulesele = getChild(node, "rules", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
309 rules = getTextFromNode(rulesele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
310 statusele = getChild(node, "status", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
311 messageele = getChild(statusele, "message")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
312 message = getTextFromNode(messageele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
313 treepkgrevisioninfo = TreepkgTrackRevisionInfo(number, rules, message)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
314 treepkgrevisioninfo.packages = []
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
315 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
316 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
317 packageeles = getChilds(packagesele, "package")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
318 for packageele in packageeles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
319 treepkgrevisioninfo.packages.append(
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
320 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
321 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
322 logeles = getChilds(logsele, "log")
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
323 for logele in logeles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
324 treepkgrevisioninfo.logs.append(
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
325 TreepkgLogInfo.fromxml(logele))
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
326 return treepkgrevisioninfo
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
327
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
328 class TreepkgLogInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
329
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
330 def __init__(self, name, path):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
331 self.name = name
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
332 self.path = path
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
333
388
1af04bfbb1d0 moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
334 def toxml(self):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
335 (doc, root) = createTpkgRoot("log")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
336 # add <name>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
337 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
338 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
339 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
340 root.appendChild(nameele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
341 # add path
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
342 pathele = createTpkgElement(doc, "path")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
343 text = doc.createTextNode(self.path)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
344 pathele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
345 root.appendChild(pathele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
346 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
347
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
348 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
349 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
350 nameele = getChild(node, "name", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
351 name = getTextFromNode(nameele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
352 pathele = getChild(node, "path", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
353 path = getTextFromNode(pathele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
354 return TreepkgLogInfo(name, path)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
355
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
356 class TreepkgPackageInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
357
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
358 def __init__(self, name, path, type, arch):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
359 self.name = name
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
360 self.path = path
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
361 self.type = type
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
362 self.arch = arch
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
363 self.checksums = []
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
364
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
365 def toxml(self):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
366 (doc, root) = createTpkgRoot("package")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
367 # add <name>
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
368 nameele = createTpkgElement(doc, "name")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
369 text = doc.createTextNode(self.name)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
370 nameele.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
371 root.appendChild(nameele)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
372 # add <path>
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
373 pathele = createTpkgElement(doc, "path")
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
374 text = doc.createTextNode(self.path)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
375 pathele.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
376 root.appendChild(pathele)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
377 # add <checksum>
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
378 for checksum in self.checksums:
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
379 root.appendChild(checksum.toxml())
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
380 # add <type>
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
381 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
382 if not self.arch is None:
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
383 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "arch", self.arch)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
384 return root
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
385
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
386 def add_checksum(self, checksum):
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
387 self.checksums.append(checksum)
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
388
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
389 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
390 def fromxml(node):
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
391 nameele = getChild(node, "name", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
392 name = getTextFromNode(nameele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
393 pathele = getChild(node, "path", True)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
394 path = getTextFromNode(pathele)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
395 ptype = node.getAttribute("type")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
396 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
397 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
398 arch = None
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
399 packageinfo = TreepkgPackageInfo(name, path, ptype, arch)
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
400 checksumeles = node.getElementsByTagName("checksum")
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
401 for checksumele in checksumeles:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
402 packageinfo.checksums.append(TreepkgChecksumInfo.fromxml(checksumele))
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
403 return packageinfo
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
404
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
405 class TreepkgChecksumInfo:
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
406
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
407 def __init__(self, checksum, type="md5"):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
408 self.checksum = checksum
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
409 self.type = type
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
410
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
411 def toxml(self):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
412 (doc, root) = createTpkgRoot("checksum")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
413 text = doc.createTextNode(self.checksum)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
414 root.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
415 # add attribute type
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
416 if type:
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
417 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "type", self.type)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
418 return root
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
419
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
420 @staticmethod
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
421 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
422 checksum = getTextFromNode(node)
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
423 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
424 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
425 return TreepkgChecksumInfo(checksum)
407
fb473f67345b implemented parsing from xml string
Bjoern Ricks <bricks@intevation.de>
parents: 406
diff changeset
426 return TreepkgChecksumInfo(checksum, ctype)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)