annotate treepkg/info/status.py @ 405:eaf04fc0f615 treepkg-status

moved arch info to each package info
author Bjoern Ricks <bricks@intevation.de>
date Tue, 13 Jul 2010 14:26:11 +0000
parents 01c059298906
children 52e3c3976e53
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
388
1af04bfbb1d0 moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
29 class TreepkgInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
30
399
04310ad0063e let the user specify num revisions that should be shown in the info
Bjoern Ricks <bricks@intevation.de>
parents: 398
diff changeset
31 def __init__(self, config, numnewestrev=-1):
04310ad0063e let the user specify num revisions that should be shown in the info
Bjoern Ricks <bricks@intevation.de>
parents: 398
diff changeset
32 self.numnewestrev = numnewestrev
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
33 group = get_packager_group(config)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
34 self.tpkgroot = TreepkgRootInfo(group.name, group.treepkg_dir,
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
35 group.tracks_dir)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
36 tracks = group.get_package_tracks()
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
37
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
38 for track in tracks:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
39 trackinfo = TreepkgTrackInfo(track.name)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
40 self.tpkgroot.add_track(trackinfo)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
41 self.add_revisions(track, trackinfo)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
42
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
43 def toxml(self):
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
44 return self.tpkgroot.toxml()
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
45
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
46 @staticmethod
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
47 def fromxml(xml):
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
48 pass
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
49
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
50 def add_revisions(self, track, trackinfo):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
51 revisions = track.get_revisions()
400
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
52 revisions = sorted(revisions, key=lambda r: r.status.start,
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
53 reverse=True)
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
54 if self.numnewestrev > 0:
48aaffdc1a4f missed in last commit
Bjoern Ricks <bricks@intevation.de>
parents: 399
diff changeset
55 revisions = revisions[: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
56
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
57 arch = None
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
58
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
59 for rev in revisions:
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
60 revision = rev.revision
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
61 rules_revision = rev.rules_revision
398
09b7b7bf0b04 fixed status line for revision
Bjoern Ricks <bricks@intevation.de>
parents: 397
diff changeset
62 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
63
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
64 sources = rev.list_source_files()
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
65 binaries = rev.list_binary_files()
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
66
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
67 revinfo = TreepkgTrackRevisionInfo(revision, rules_revision,
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
68 status)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
69 logs = rev.get_log_files()
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
70 for (title, filename) in logs:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
71 loginfo = TreepkgLogInfo(title, filename)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
72 revinfo.add_log(loginfo)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
73 for source in sources:
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
74 self.add_package(revinfo, source, "source")
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
75 for binary in binaries:
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
76 binpackage = BinaryPackage(binary)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
77 arch = binpackage.get_architecture()
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
78 self.add_package(revinfo, binary, "binary", arch)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
79
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
80 trackinfo.add_revision(revinfo)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
81
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
82 def add_package(self, revision, file, type, arch=None):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
83 name = os.path.basename(file)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
84 checksum = md5sum(file)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
85 checksuminfo = TreepkgChecksumInfo(checksum, "md5")
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
86 pkginfo = TreepkgPackageInfo(name, file, type, arch)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
87 pkginfo.add_checksum(checksuminfo)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
88 revision.add_package(pkginfo)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
89
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
90 class TreepkgRootInfo:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
91
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
92 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
93 self.name = name
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
94 self.treepkgpath = treepkgpath
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
95 self.trackspath = trackspath
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
96 self.version = version
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
97 self.tracks = []
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
98
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
99 def add_track(self, track):
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
100 self.tracks.append(track)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
101
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
102 def toxml(self):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
103 (doc, root) = createTpkgRoot("status")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
104 # add <name>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
105 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
106 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
107 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
108 root.appendChild(nameele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
109 # add <treepkgpath>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
110 if self.treepkgpath:
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
111 treepkgpathele = createTpkgElement(doc, "treepkgpath")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
112 text = doc.createTextNode(self.treepkgpath)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
113 treepkgpathele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
114 root.appendChild(treepkgpathele)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
115 # add <trackspath>
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
116 if self.trackspath:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
117 trackspathele = createTpkgElement(doc, "trackspath")
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
118 text = doc.createTextNode(self.trackspath)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
119 trackspathele.appendChild(text)
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
120 root.appendChild(trackspathele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
121 # add <version>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
122 if self.version:
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
123 versionele = createTpkgElement(doc, "version")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
124 text = doc.createTextNode(self.version)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
125 versionele.appendChild(text)
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
126 root.appendChild(versionele)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
127 if len(self.tracks) > 0:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
128 tracksele = createTpkgElement(doc, "tracks")
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
129 for track in self.tracks:
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
130 tracksele.appendChild(track.toxml())
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
131 root.appendChild(tracksele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
132 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
133
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
134 class TreepkgTrackInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
135
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
136 def __init__(self, name, os=None):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
137 self.name = name
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
138 self.os = os
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
139 self.revisions = []
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
140
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
141 def add_revision(self, revision):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
142 self.revisions.append(revision)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
143
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
144 def toxml(self):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
145 (doc, root) = createTpkgRoot("track")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
146 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
147 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
148 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
149 root.appendChild(nameele)
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
150 for rev in self.revisions:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
151 root.appendChild(rev.toxml())
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
152 if not self.os is None:
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
153 osele = createTpkgElement(doc, "os")
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
154 text = doc.createTextNode(self.os)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
155 osele.appendChild(text)
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
156 root.appendChild(osele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
157 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
158
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
159 class TreepkgTrackRevisionInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
160
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
161 def __init__(self, number, rules, status):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
162 self.number = number
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
163 self.rules = rules
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
164 self.status = status
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
165 self.packages = []
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
166 self.logs = []
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
167
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
168 def add_package(self, package):
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
169 self.packages.append(package)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
170
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
171 def add_log(self, log):
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
172 self.logs.append(log)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
173
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
174 def toxml(self):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
175 (doc, root) = createTpkgRoot("revision")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
176 # add <number>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
177 numberele = createTpkgElement(doc, "number")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
178 text = doc.createTextNode(self.number)
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
179 numberele.appendChild(text)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
180 root.appendChild(numberele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
181 # add <rules>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
182 rulesele = createTpkgElement(doc, "rules")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
183 text = doc.createTextNode(self.rules)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
184 rulesele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
185 root.appendChild(rulesele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
186 # add <status><message></message></status>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
187 statusele = createTpkgElement(doc, "status")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
188 messageele = createTpkgElement(doc, "message")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
189 text = doc.createTextNode(self.status)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
190 messageele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
191 statusele.appendChild(messageele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
192 root.appendChild(statusele)
402
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
193 # add <packages>
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
194 packagesele = createTpkgElement(doc, "packages")
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
195 for package in self.packages:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
196 packagesele.appendChild(package.toxml())
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
197 root.appendChild(packagesele)
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
198 # add <logs>
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
199 logsele = createTpkgElement(doc, "logs")
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
200 for log in self.logs:
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
201 logsele.appendChild(log.toxml())
01c059298906 moved packages and logs to revision tag
Bjoern Ricks <bricks@intevation.de>
parents: 400
diff changeset
202 root.appendChild(logsele)
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
203 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
204
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
205 class TreepkgLogInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
206
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
207 def __init__(self, name, path):
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
208 self.name = name
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
209 self.path = path
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
210
388
1af04bfbb1d0 moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
211 def toxml(self):
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
212 (doc, root) = createTpkgRoot("log")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
213 # add <name>
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
214 nameele = createTpkgElement(doc, "name")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
215 text = doc.createTextNode(self.name)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
216 nameele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
217 root.appendChild(nameele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
218 # add path
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
219 pathele = createTpkgElement(doc, "path")
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
220 text = doc.createTextNode(self.path)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
221 pathele.appendChild(text)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
222 root.appendChild(pathele)
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
223 return root
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
224
392
e2afbd3c2bf1 write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents: 388
diff changeset
225 class TreepkgPackageInfo:
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
226
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
227 def __init__(self, name, path, type, arch):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
228 self.name = name
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
229 self.path = path
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
230 self.type = type
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
231 self.arch = arch
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
232 self.checksums = []
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
233
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
234 def toxml(self):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
235 (doc, root) = createTpkgRoot("package")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
236 # add <name>
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
237 nameele = createTpkgElement(doc, "name")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
238 text = doc.createTextNode(self.name)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
239 nameele.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
240 root.appendChild(nameele)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
241 # add <path>
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
242 pathele = createTpkgElement(doc, "path")
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
243 text = doc.createTextNode(self.path)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
244 pathele.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
245 root.appendChild(pathele)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
246 # add <checksum>
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
247 for checksum in self.checksums:
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
248 root.appendChild(checksum.toxml())
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
249 # add <type>
405
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
250 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
251 if not self.arch is None:
eaf04fc0f615 moved arch info to each package info
Bjoern Ricks <bricks@intevation.de>
parents: 402
diff changeset
252 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "arch", self.arch)
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
253 return root
386
ffa86312ee81 added classed for treepkg status xml generation
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
254
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
255 def add_checksum(self, checksum):
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
256 self.checksums.append(checksum)
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
257
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
258 class TreepkgChecksumInfo:
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
259
397
a7bf4464bd60 fixed some typos
Bjoern Ricks <bricks@intevation.de>
parents: 396
diff changeset
260 def __init__(self, checksum, type="md5"):
395
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
261 self.checksum = checksum
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
262 self.type = type
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
263
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
264 def toxml(self):
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
265 (doc, root) = createTpkgRoot("checksum")
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
266 text = doc.createTextNode(self.checksum)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
267 root.appendChild(text)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
268 # add attribute type
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
269 root.setAttributeNS(TREEPKG_NAMESPACE_URI, "type", self.type)
0ba451c4a856 implemented nearly all info
Bjoern Ricks <bricks@intevation.de>
parents: 392
diff changeset
270 return root
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)