/[qa]/trunk/pts/www/bin/other_to_xml.py
ViewVC logotype

Contents of /trunk/pts/www/bin/other_to_xml.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 479 - (hide annotations) (download) (as text)
Sat Jan 11 22:56:05 2003 UTC (10 years, 5 months ago) by hertzog
File MIME type: text/x-python
File size: 5110 byte(s)
- Add a link to debconf templates's translations of the DDTP for
  packages which do have debconf templates.
1 hertzog 344 #!/usr/bin/python2.2
2    
3     # Make sure tabs expand to 8 spaces in vim
4     # vim: expandtab
5    
6 hertzog 351 # Copyright 2002 Raphaƫl Hertzog
7     # This file is distributed under the terms of the General Public License
8     # version 2 or (at your option) any later version.
9    
10 hertzog 357 import os.path, rfc822, sys, string, re, email, common, cPickle
11 hertzog 344 from xml.dom import implementation, ext
12    
13     from config import dir, odir, root
14    
15     # Create the source -> binaries correspondance
16     sources = {}
17     f = open(dir + "/sources", "r")
18     while 1:
19     line = f.readline();
20     if not line: break #eof
21     line = line.strip()
22     (binary, source) = line.split(None, 1)
23     if not sources.has_key(source):
24     sources[source] = []
25     sources[source].append(binary)
26     f.close()
27    
28     # Read all the bugs stats
29     bugs = {}
30     f = open(dir + "/bugs.txt")
31     while 1:
32     line = f.readline()
33     if not line: break #eof
34     line = line.strip()
35     (binary, stats) = line.split(None, 1)
36     bugs[binary] = stats.split()
37     f.close()
38    
39     # Read all the PTS stats
40     pts = {}
41     f = open(dir + "/count.txt")
42     while 1:
43     line = f.readline()
44     if not line: break #eof
45     line = line.strip()
46     (binary, stats) = line.split(None, 1)
47     pts[binary] = stats
48     f.close()
49    
50 hertzog 372 # Read the lisf of packages with debcheck problems
51     debcheck = {}
52     for dist in ("stable", "testing", "unstable"):
53     debcheck[dist] = {}
54     f = open(dir + "/debcheck-" + dist)
55     while 1:
56     line = f.readline()
57     if not line: break #eof
58     debcheck[dist][line.strip()] = 1
59     f.close()
60    
61 hertzog 479 # Read the list of source packages with debconf templates
62     debconf = {}
63     f = open(dir + "/debconf-list")
64     while 1:
65     line = f.readline()
66     if not line: break #eof
67     line = line.strip()
68     debconf[line] = 1;
69     f.close()
70    
71 hertzog 357 # Read the current signature of other.xml files
72     sigs = {}
73     if os.path.exists(odir + "/other.sigs"):
74     f = open(odir + "/other.sigs", "r")
75     sigs = cPickle.load(f)
76     f.close()
77    
78 hertzog 344 # Create the XML documents
79     while 1:
80     line = sys.stdin.readline()
81     if not line: break #eof
82     pkg = line.strip()
83    
84     doc = implementation.createDocument(None, "other", None)
85     root_elt = doc.documentElement
86    
87     hash = pkg[0]
88     if pkg[0:3] == "lib":
89     hash = pkg[0:4]
90    
91 hertzog 372 # Add debcheck availability info
92     dc_sig = ""
93     elt = doc.createElement("debcheck")
94     for dist in ("stable", "testing", "unstable"):
95     if debcheck[dist].has_key(pkg):
96     elt.setAttribute(dist, "yes")
97     dc_sig += "y"
98     else:
99     elt.setAttribute(dist, "no")
100     dc_sig += "n"
101     root_elt.appendChild(elt)
102    
103 hertzog 479 # Add debconf templates availibilty info
104     if debconf.has_key(pkg):
105     root_elt.setAttribute("debconf", "yes")
106     dc_sig += "y"
107     else:
108     root_elt.setAttribute("debconf", "no")
109     dc_sig += "n"
110    
111 hertzog 344 # Get PTS stats
112     elt = doc.createElement("pts")
113     elt.setAttribute("count", pts.get(pkg, "0"))
114     root_elt.appendChild(elt)
115    
116     # Get BTS stats
117     elt = doc.createElement("bugs")
118     (s_rc, s_normal, s_wishlist, s_fixed) = (0,0,0,0)
119 hertzog 357 binlist = sources.get(pkg, [])
120     binlist.sort()
121     subsig = ""
122     for binary in binlist:
123 hertzog 344 sub_elt = doc.createElement("item")
124     sub_elt.setAttribute("name", binary)
125     (rc, normal, wishlist, fixed) = bugs.get(binary, ["0","0","0","0"])
126     sub_elt.setAttribute("rc", rc)
127     sub_elt.setAttribute("normal", normal)
128     sub_elt.setAttribute("wishlist", wishlist)
129     sub_elt.setAttribute("fixed", fixed)
130     rc = string.atoi(rc)
131     normal = string.atoi(normal)
132     wishlist = string.atoi(wishlist)
133     fixed = string.atoi(fixed)
134     all = rc + normal + wishlist + fixed
135     sub_elt.setAttribute("all", "%d" % all)
136     elt.appendChild(sub_elt)
137 hertzog 357 if len(subsig):
138     subsig = "%s|%d" % (subsig, all)
139     else:
140     subsig = "%d" % all
141 hertzog 344 s_rc += rc
142     s_normal += normal
143     s_wishlist += wishlist
144     s_fixed += fixed
145 hertzog 413 if (pkg not in binlist): # Source package needs to be counted too
146     (rc, normal, wishlist, fixed) = bugs.get(pkg, ["0","0","0","0"])
147     s_rc += string.atoi(rc)
148     s_normal += string.atoi(normal)
149     s_wishlist += string.atoi(wishlist)
150     s_fixed += string.atoi(fixed)
151    
152 hertzog 344 elt.setAttribute("rc", "%d" % s_rc)
153     elt.setAttribute("normal", "%d" % s_normal)
154     elt.setAttribute("wishlist", "%d" % s_wishlist)
155     elt.setAttribute("fixed", "%d" % s_fixed)
156     elt.setAttribute("all", "%d" % (s_fixed + s_wishlist + s_normal + s_rc))
157     root_elt.appendChild(elt)
158    
159 hertzog 357 # TODO: try to do that signature checking before the creation of XML DOM
160     # Build the sig and check if anything changed
161 hertzog 372 sig = "%s %s %d/%d/%d/%d %s" % (pts.get(pkg, "0"), dc_sig, s_rc, s_normal, s_wishlist, s_fixed, subsig)
162 hertzog 357 if sigs.has_key(pkg) and sig == sigs[pkg]:
163     continue
164     sigs[pkg] = sig
165    
166 hertzog 344 # Output the data to the XML file
167     f = open("%s/%s/%s/other.xml" % (odir, hash, pkg), "w")
168     ext.PrettyPrint(doc, f, "iso-8859-1")
169     f.close()
170    
171 hertzog 357 # Store the signatures
172     f = open(odir + "/other.sigs", "w")
173     cPickle.dump(sigs, f, 0)
174     f.close()
175    

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5