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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1800 by zack, Thu Dec 20 10:06:45 2007 UTC revision 2225 by zack, Tue Jul 21 21:14:49 2009 UTC
# Line 1  Line 1 
1  #!/usr/bin/python  #!/usr/bin/python
2  # -*- coding: utf8 -*-  # -*- coding: utf-8 -*-
3    
4  # Make sure tabs expand to 8 spaces in vim  # Make sure tabs expand to 8 spaces in vim
5  # vim: expandtab  # vim: expandtab
6    
7  # Copyright 2002 Raphaël Hertzog  # Copyright: © 2002 Raphaël Hertzog
8  # Copyright 2005 Jeroen van Wolffelaar  # Copyright: © 2005 Jeroen van Wolffelaar
9    # Copyright: © 2007-2009 Stefano Zacchiroli
10  # This file is distributed under the terms of the General Public License  # This file is distributed under the terms of the General Public License
11  # version 2 or (at your option) any later version.  # version 2 or (at your option) any later version.
12    
13  import os.path, rfc822, sys, string, re, email, common, cPickle  import os.path, sys, string, re, email, common, cPickle, yaml
14  from xml.dom import implementation, ext  from xml.dom import implementation, ext
15    from debian_bundle import deb822, debian_support
16    
17  from config import dir, odir, root  from config import dir, odir, root
18    from common import hash_name
19    
20  # Create the source -> binaries correspondance  # sources <-> binaries correspondances, kind of global variables
21  sources = {}  source2binaries = {} # maps a source package to its binaries
22    binary2source = {}   # maps a binary package to its source
23    
24    def read_shortdesc(fname):
25        global binary2source
26        source_descs = {} # source package -> (binary package -> short description)
27        for line in open(fname):
28            pkg, shortdesc = line.strip().split("\t", 1)
29            if not binary2source.has_key(pkg):
30                continue
31            src = binary2source[pkg]
32            if not source_descs.has_key(src):
33                source_descs[src] = {}
34            source_descs[src][pkg] = shortdesc
35        return source_descs
36    
37    def read_bug_summary(fname):
38        global binary2source
39        summary = {} # source package -> bug count
40        for line in open(fname):
41            pkg, count = line.split()
42            if not binary2source.has_key(pkg):
43                continue
44            src = binary2source[pkg]
45            if not summary.has_key(src):
46                summary[src] = 0
47            summary[src] += int(count)
48        return summary
49    
50    def read_low_threshold_nmu(fname):
51        """read low threshold NMU info"""
52        emails = []
53        if os.path.exists(fname):
54            f = open(fname)
55            devel_php_RE = \
56                re.compile(r'http://qa\.debian\.org/developer\.php\?login=([^\s&]+)')
57            word_RE = re.compile(r'^\w+$')
58            for line in f.readlines():
59                match = devel_php_RE.search(line)
60                while match:    # look for several matches on the same line
61                    email = None
62                    login = match.group(1)
63                    if word_RE.match(login):
64                        email = login + '@debian.org'
65                    elif login.find('@') >= 0:
66                        email = login
67                    if email:
68                        emails.append(email)
69                    line = line[match.end():]
70                    match = devel_php_RE.search(line)
71            f.close()
72        return emails
73    
74    def read_transitions(fname):
75        y = yaml.load(file(fname))
76        packages = {} # maps pkg to the _list_ of transitions they are involved in
77        for id, transition in y.iteritems():
78            for pkg in transition['packages']:
79                if not packages.has_key(pkg):
80                    packages[pkg] = []
81                packages[pkg].append(id)
82        return packages
83    
84    def read_piuparts(fname):
85        failures = {}
86        if os.path.exists(fname):
87            f = open(fname)
88            for line in f.readlines():
89                try:
90                    src, outcome = map(lambda s: s.strip(), line.split(':'))
91                    if outcome == "fail":
92                        failures[src] = True
93                except ValueError:
94                    pass
95            f.close()
96        return failures
97    
98    def read_lintian_info(fname):
99        lintian = {} # maps source pkg names to pairs <errors_no, warnings_no>
100        for line in open(fname).readlines():
101            try:
102                (pkg, errors_no, warnings_no) = line.split()
103                lintian[pkg] = (int(errors_no), int(warnings_no))
104            except ValueError:
105                continue
106        return lintian
107    
108    # DEHS textual file are line oriented with lines like "field: value"
109    def read_dehs(fname):
110        f = open(fname)
111        for line in f.readlines():
112            yield map(string.strip, line.split(':'))
113        f.close()
114    
115    # read 822 dump of NEW queue content
116    def read_NEW(fname):
117        new_contents = {}
118        for stanza in deb822.Sources.iter_paragraphs(file(os.path.join(dir, 'new.822'))):
119            if stanza.has_key('source') and stanza.has_key('version') and \
120                    stanza.has_key('queue'):
121                # store only the most recent version in NEW (ignore accepted)
122                if stanza['queue'] == 'new' and \
123                        (not new_contents.has_key(stanza['source']) or \
124                         debian_support.version_compare( \
125                                        new_contents[stanza['source']],
126                                        stanza['version']) < 0):
127                    new_contents[stanza['source']] = stanza['version']
128        return new_contents
129    
130    # Initialization: fill binary <-> source maps
131  f = open(dir + "/sources.map", "r")  f = open(dir + "/sources.map", "r")
132  while 1:  while 1:
133      line = f.readline();      line = f.readline();
134      if not line: break #eof      if not line: break #eof
135      line = line.strip()      line = line.strip()
136      (binary, source) = line.split(None, 1)      (binary, source) = line.split(None, 1)
137      if not sources.has_key(source):      if not source2binaries.has_key(source):
138          sources[source] = []          source2binaries[source] = []
139      sources[source].append(binary)      source2binaries[source].append(binary)
140        binary2source[binary] = source
141  f.close()  f.close()
142    
143  # Read all the bugs stats  # Read all the bugs stats
# Line 35  while 1: Line 148  while 1:
148      if not line: break #eof      if not line: break #eof
149      line = line.strip()      line = line.strip()
150      (binary, stats) = line.split(None, 1)      (binary, stats) = line.split(None, 1)
151      bugs[binary] = stats.split()      bugs[binary] = [ string.atoi(i) for i in stats.split() ]
152  f.close()  f.close()
153    
154    srcbugs = {}
155    f = open(dir + "/bugs-src.txt")
156    while 1:
157        line = f.readline()
158        if not line: break #eof
159        line = line.strip()
160        (pkg, stats) = line.split(":", 1)
161        try:
162            srcbugs[pkg] = [ string.atoi(i) for i in stats.replace("(", " ").replace(")", " ").split() ]
163        except:
164            sys.stderr.write("Failed to parse bugs-src.txt stats for %s: %s" % (pkg, stats))
165    f.close()
166    
167    gift_bugs = read_bug_summary(os.path.join(dir, 'bugs.gift.txt'))
168    help_bugs = read_bug_summary(os.path.join(dir, 'bugs.help.txt'))
169    
170  # Read all the PTS stats  # Read all the PTS stats
171  pts = {}  pts = {}
172  f = open(dir + "/count.txt")  f = open(dir + "/count.txt")
# Line 51  f.close() Line 180  f.close()
180    
181  # Read the lisf of packages with debcheck problems  # Read the lisf of packages with debcheck problems
182  debcheck = {}  debcheck = {}
183  for dist in ("stable", "testing", "unstable"):  for dist in ("oldstable", "stable", "testing", "unstable"):
184      debcheck[dist] = {}      debcheck[dist] = {}
185      f = open(dir + "/debcheck-" + dist)      f = open(dir + "/debcheck-" + dist)
186      while 1:      while 1:
# Line 98  if os.path.exists(dir + "/wnpp_rm"): Line 227  if os.path.exists(dir + "/wnpp_rm"):
227      while 1:      while 1:
228          line = f.readline()          line = f.readline()
229          if not line: break # eof          if not line: break # eof
230          (package, type, number) = line.split("|")[0].split()          line = line.strip()
231            try:
232                (package, type, number) = line.split("|")[0].split()
233            except:
234                #too many badly formatted ITP... disable warning. --RH
235                #sys.stderr.write("Ignoring bad line '%s' in wnpp_rm\n" % line)
236                pass
237          wnpp[package[:-1]] = (type, number)          wnpp[package[:-1]] = (type, number)
238      f.close()      f.close()
239    
 # Read watch information [FG]  
 watch = {}  
 if os.path.exists(odir + "/watch_done"):  
     f = open(odir + "/watch_done")  
     watch = cPickle.load(f)  
     f.close()  
   
240  # Read patches information [FG]  # Read patches information [FG]
241  patches = {}  ubuntu_patches = {}
242  # this can be easily inserted into a new update_patches.py if it becomes too  # this can be easily inserted into a new update_patches.py if it becomes too
243  # heavy to parse the file  # heavy to parse the file
244  if os.path.exists(dir + "/patches.ubuntu"):  if os.path.exists(dir + "/patches.ubuntu"):
# Line 122  if os.path.exists(dir + "/patches.ubuntu Line 250  if os.path.exists(dir + "/patches.ubuntu
250          if not r:          if not r:
251              continue              continue
252          version = r.group(1)          version = r.group(1)
253          patches[package] = {}          ubuntu_patches[package] = (version, "http://patches.ubuntu.com/" + rel_url)
         patches[package]['ubuntu'] = (version, "http://patches.ubuntu.com/" + rel_url)  
254      f.close()      f.close()
255    
256  # read low threshold NMU infos  ubuntu_versions = {}
257  def read_low_threshold_nmu(fname):  if os.path.exists(dir + "/versions.ubuntu"):
258      emails = []      f = open(dir + "/versions.ubuntu")
259      if os.path.exists(fname):      for line in f.readlines():
260          f = open(fname)          (package, version) = line.split(' ', 2)
261          devel_php_RE = \          version = version.strip()
262              re.compile(r'http://qa\.debian\.org/developer\.php\?login=([^\s&]+)')          ubuntu_versions[package] = (version, "https://launchpad.net/ubuntu/+source/" + package)
263          word_RE = re.compile(r'^\w+$')      f.close()
264          for line in f.readlines():  
265              match = devel_php_RE.search(line)  ubuntu_bugs = {}
266              while match:    # look for several matches on the same line  if os.path.exists(dir + "/bugs.ubuntu"):
267                  email = None      f = open(dir + "/bugs.ubuntu")
268                  login = match.group(1)      for line in f.readlines():
269                  if word_RE.match(login):          (package, count) = line.split('|', 2)
270                      email = login + '@debian.org'          count = count.strip()
271                  elif login.find('@') >= 0:          ubuntu_bugs[package] = (count, "https://bugs.launchpad.net/ubuntu/+source/" + package)
272                      email = login      f.close()
                 if email:  
                     emails.append(email)  
                 line = line[match.end():]  
                 match = devel_php_RE.search(line)  
         f.close()  
     return emails  
273    
274  # write lowThresholdNmu info to a (global, i.e. not per-package) file  # write lowThresholdNmu info to a (global, i.e. not per-package) file
275  #  #
# Line 163  f.writelines(map(lambda s: "  <email>%s< Line 284  f.writelines(map(lambda s: "  <email>%s<
284  f.write("</emails>\n");  f.write("</emails>\n");
285  f.close()  f.close()
286    
287    # read the list of packages involved in transitions
288    transitions = read_transitions(os.path.join(dir, "transitions.yaml"))
289    
290    piuparts = read_piuparts(os.path.join(dir, "piuparts-sid.txt"))
291    
292    new_queue = read_NEW(os.path.join(dir, "new.822"))
293    
294    # read QA lintian info
295    lintian = read_lintian_info(os.path.join(dir, "lintian.qa-list.txt"))
296    
297  # read the list of packages indexed by svnbuildstat.debian.net  # read the list of packages indexed by svnbuildstat.debian.net
298  svnbuildstat = {}  svnbuildstat = {}
299  f = open(os.path.join(dir, "svnbuildstat_list.txt"))  f = open(os.path.join(dir, "svnbuildstat_list.txt"))
# Line 170  for pkgname in map(string.rstrip, f.read Line 301  for pkgname in map(string.rstrip, f.read
301      svnbuildstat[pkgname] = True      svnbuildstat[pkgname] = True
302  f.close()  f.close()
303    
304    # read info gathered from dehs.alioth.debian.org
305    dehs = {}
306    for pkgname, version in read_dehs(os.path.join(dir, "dehs_out_of_date.txt")):
307        if not dehs.has_key(pkgname):
308            dehs[pkgname] = {}
309        dehs[pkgname]['newer'] = version
310    for pkgname, msg in read_dehs(os.path.join(dir, "dehs_error.txt")):
311        if not dehs.has_key(pkgname):
312            dehs[pkgname] = {}
313        dehs[pkgname]['error'] = msg
314    
315    # read short descriptions
316    shortdescs = read_shortdesc(os.path.join(dir, "shortdesc.txt"))
317    
318  # Create the XML documents  # Create the XML documents
319  while 1:  while 1:
320      line = sys.stdin.readline()      line = sys.stdin.readline()
# Line 178  while 1: Line 323  while 1:
323    
324      doc = implementation.createDocument(None, "other", None)      doc = implementation.createDocument(None, "other", None)
325      root_elt = doc.documentElement      root_elt = doc.documentElement
326        hash = hash_name(pkg)
     hash = pkg[0]  
     if pkg[0:3] == "lib":  
         hash = pkg[0:4]  
327    
328      # Add debcheck availability info      # Add debcheck availability info
329      dc_sig = ""      dc_sig = ""
330      elt = doc.createElement("debcheck")      elt = doc.createElement("debcheck")
331      for dist in ("stable", "testing", "unstable"):      for dist in ("oldstable", "stable", "testing", "unstable"):
332          if debcheck[dist].has_key(pkg):          if debcheck[dist].has_key(pkg):
333              elt.setAttribute(dist, "yes")              elt.setAttribute(dist, "yes")
334              dc_sig += "y"              dc_sig += "y"
# Line 194  while 1: Line 336  while 1:
336              elt.setAttribute(dist, "no")              elt.setAttribute(dist, "no")
337              dc_sig += "n"              dc_sig += "n"
338      root_elt.appendChild(elt)      root_elt.appendChild(elt)
339    
340        # Add NEW queue versions, if any
341        if new_queue.has_key(pkg):
342            root_elt.setAttribute("new_version", new_queue[pkg])
343            new_queue_sig = 'y'
344        else:
345            new_queue_sig = 'n'
346    
347      # Add debconf templates availibilty info      # Add debconf templates availibilty info
348      if debconf.has_key(pkg):      if debconf.has_key(pkg):
# Line 210  while 1: Line 359  while 1:
359    
360      # Get BTS stats      # Get BTS stats
361      elt = doc.createElement("bugs")      elt = doc.createElement("bugs")
362      (s_rc, s_normal, s_wishlist, s_fixed, s_patch) = (0,0,0,0,0)      (s_rc, s_rc_m, s_normal, s_normal_m, s_wishlist, s_wishlist_m, s_fixed,
363      binlist = sources.get(pkg, [])              s_fixed_m, s_patch, s_patch_m) = \
364                        srcbugs.get(pkg, [0,0,0,0,0,0,0,0,0,0])
365        binlist = source2binaries.get(pkg, [])
366      binlist.sort()      binlist.sort()
367      subsig = ""      subsig = ""
368      for binary in binlist:      for binary in binlist:
369          sub_elt = doc.createElement("item")          sub_elt = doc.createElement("item")
370          sub_elt.setAttribute("name", binary)          sub_elt.setAttribute("name", binary)
371          (rc, normal, wishlist, fixed, patch) = bugs.get(binary, ["0","0","0","0","0"])          (rc, normal, wishlist, fixed, patch) = bugs.get(binary, [0,0,0,0,0])
372          sub_elt.setAttribute("rc", rc)          sub_elt.setAttribute("rc", "%d" % rc)
373          sub_elt.setAttribute("normal", normal)          sub_elt.setAttribute("normal", "%d" % normal)
374          sub_elt.setAttribute("wishlist", wishlist)          sub_elt.setAttribute("wishlist", "%d" % wishlist)
375          sub_elt.setAttribute("fixed", fixed)          sub_elt.setAttribute("fixed", "%d" % fixed)
376          sub_elt.setAttribute("patch", patch)          sub_elt.setAttribute("patch", "%d" % patch)
         rc = string.atoi(rc)  
         normal = string.atoi(normal)  
         wishlist = string.atoi(wishlist)  
         fixed = string.atoi(fixed)  
         patch = string.atoi(patch)  
377          all = rc + normal + wishlist + fixed          all = rc + normal + wishlist + fixed
378          sub_elt.setAttribute("all", "%d" % all)          sub_elt.setAttribute("all", "%d" % all)
379          elt.appendChild(sub_elt)          elt.appendChild(sub_elt)
# Line 235  while 1: Line 381  while 1:
381              subsig = "%s|%d|%d" % (subsig, all, patch)              subsig = "%s|%d|%d" % (subsig, all, patch)
382          else:          else:
383              subsig = "%d|%d" % (all, patch)              subsig = "%d|%d" % (all, patch)
384          s_rc += rc  
         s_normal += normal  
         s_wishlist += wishlist  
         s_fixed += fixed  
         s_patch += patch  
     if (pkg not in binlist): # Source package needs to be counted too  
         (rc, normal, wishlist, fixed, patch) = bugs.get(pkg, ["0","0","0","0","0"])  
         s_rc += string.atoi(rc)  
         s_normal += string.atoi(normal)  
         s_wishlist += string.atoi(wishlist)  
         s_fixed += string.atoi(fixed)  
         s_patch += string.atoi(patch)  
   
385      elt.setAttribute("rc", "%d" % s_rc)      elt.setAttribute("rc", "%d" % s_rc)
386        if s_rc != s_rc_m:
387            elt.setAttribute("rc_m", "%d" % s_rc_m)
388      elt.setAttribute("normal", "%d" % s_normal)      elt.setAttribute("normal", "%d" % s_normal)
389        if s_normal != s_normal_m:
390            elt.setAttribute("normal_m", "%d" % s_normal_m)
391      elt.setAttribute("wishlist", "%d" % s_wishlist)      elt.setAttribute("wishlist", "%d" % s_wishlist)
392        if s_wishlist != s_wishlist_m:
393            elt.setAttribute("wishlist_m", "%d" % s_wishlist_m)
394      elt.setAttribute("fixed", "%d" % s_fixed)      elt.setAttribute("fixed", "%d" % s_fixed)
395        if s_fixed != s_fixed_m:
396            elt.setAttribute("fixed_m", "%d" % s_fixed_m)
397      elt.setAttribute("patch", "%d" % s_patch)      elt.setAttribute("patch", "%d" % s_patch)
398      elt.setAttribute("all", "%d" % (s_fixed + s_wishlist + s_normal + s_rc))      if s_patch != s_patch_m:
399            elt.setAttribute("patch_m", "%d" % s_patch_m)
400        s_all = s_fixed + s_wishlist + s_normal + s_rc
401        s_all_m = s_fixed_m + s_wishlist_m + s_normal_m + s_rc_m
402        elt.setAttribute("all", "%d" % s_all)
403        if s_all != s_all_m:
404            elt.setAttribute("all_m", "%d" % s_all_m)
405      root_elt.appendChild(elt)      root_elt.appendChild(elt)
406        if gift_bugs.has_key(pkg):
407            s_gift = gift_bugs[pkg]
408        else:
409            s_gift = 0
410        elt.setAttribute("gift", str(s_gift))
411        if help_bugs.has_key(pkg):
412            s_help = help_bugs[pkg]
413        else:
414            s_help = 0
415        elt.setAttribute("help", str(s_help))
416    
417      # Get WNPP information. [PvR]      # Get WNPP information. [PvR]
418      if wnpp.has_key(pkg):      if wnpp.has_key(pkg):
# Line 292  while 1: Line 450  while 1:
450      else:      else:
451          root_elt.setAttribute("override", "no")          root_elt.setAttribute("override", "no")
452    
453      # Get watch information [FG]      # Add Ubuntu information
454      if watch.has_key(pkg):      if ubuntu_versions.has_key(pkg):
455          new = str(watch[pkg]['new'])          elt = doc.createElement("ubuntu")
456          warn = watch[pkg]['warning']          (version, url) = ubuntu_versions[pkg]
457          url = watch[pkg]['url']          ubuntu_sig = "ubuntu/ " + version
458          elt = doc.createElement("watch")          elt.setAttribute("version", unicode(version, 'UTF8', 'replace'))
459          elt.setAttribute("new", unicode(new,'UTF8','replace'))          elt.setAttribute("url", unicode(url, 'UTF8', 'replace'))
460          elt.setAttribute("warning", unicode(warn,'UTF8','replace'))          if ubuntu_bugs.has_key(pkg):
461          elt.setAttribute("url", unicode(url,'UTF8','replace'))             elt.setAttribute("bugs", "yes")
462               elt_bugs = doc.createElement("bugs")
463               (count, url) = ubuntu_bugs[pkg]
464               ubuntu_sig += "ubuntubugs/" + count
465               elt_bugs.setAttribute("count", unicode(count, 'UTF8', 'replace'))
466               elt_bugs.setAttribute("url", unicode(url, 'UTF8', 'replace'))
467               elt.appendChild(elt_bugs)
468            if ubuntu_patches.has_key(pkg):
469               elt.setAttribute("patch", "yes")
470               elt_patch = doc.createElement("patch")
471               (version, url) = ubuntu_patches[pkg]
472               ubuntu_sig += "ubuntupatch/" + version
473               elt_patch.setAttribute("version", unicode(version, 'UTF8', 'replace'))
474               elt_patch.setAttribute("url", unicode(url, 'UTF8', 'replace'))
475               elt.appendChild(elt_patch)
476          root_elt.appendChild(elt)          root_elt.appendChild(elt)
477          root_elt.setAttribute("watch", "yes")          root_elt.setAttribute("ubuntu", "yes")
478          watch_sig = new      else:
479          if warn != '':          root_elt.setAttribute("ubuntu", "no")
480              watch_sig = watch_sig + ("/W%d" % len(warn))          ubuntu_sig = "n"
481          if url != '':  
482              watch_sig = watch_sig + ("/U%d" % len(url))      # Get DEHS information
483      else:      if dehs.has_key(pkg):
484          root_elt.setAttribute("watch", "no")          elt = doc.createElement('dehs')
         watch_sig = "n"  
   
     # Add patches informations [FG]  
     if patches.has_key(pkg):  
         elt = doc.createElement("patches")  
         patch_sig = ""  
         distros = patches[pkg].keys()  
         distros.sort()  
         for distro in distros:  
            child = doc.createElement("item")  
            (version, url) = patches[pkg][distro]  
            child.setAttribute("distro", unicode(distro, 'UTF8', 'replace'))  
            child.setAttribute("version", unicode(version, 'UTF8', 'replace'))  
            child.setAttribute("url", unicode(url, 'UTF8', 'replace'))  
            elt.appendChild(child)  
            patch_sig += "%s/%s " % (distro, version)  
485          root_elt.appendChild(elt)          root_elt.appendChild(elt)
486          root_elt.setAttribute("patches", "yes")          root_elt.setAttribute('dehs', 'yes')
487            if dehs[pkg].has_key('newer'):
488                elt.setAttribute('newer', dehs[pkg]['newer'])
489            if dehs[pkg].has_key('error'):
490                elt.setAttribute('error', 'yes')
491            dehs_sig = 'y'
492      else:      else:
493          root_elt.setAttribute("patches", "no")          root_elt.setAttribute('dehs', 'no')
494          patch_sig = "n"          dehs_sig = 'n'
495    
496      # add svnbuildstat info      # add svnbuildstat info
497      if svnbuildstat.has_key(pkg):      if svnbuildstat.has_key(pkg):
# Line 342  while 1: Line 503  while 1:
503          root_elt.setAttribute("svnbuildstat", "no")          root_elt.setAttribute("svnbuildstat", "no")
504          svnbuildstat_sig = "n"          svnbuildstat_sig = "n"
505    
506        # add piuparts info
507        if piuparts.has_key(pkg):
508            #elt = doc.createElement("piuparts")
509            #root_elt.appendChild(elt)
510            root_elt.setAttribute("piuparts", "yes")
511            piuparts_sig = "y"
512        else:
513            root_elt.setAttribute("piuparts", "no")
514            piuparts_sig = "n"
515    
516        # add transitions info
517        if transitions.has_key(pkg):
518            elt = doc.createElement("transitions")
519            for id in transitions[pkg]:
520                trans_elt = doc.createElement("transition")
521                trans_elt.setAttribute("name", id)
522                elt.appendChild(trans_elt)
523            root_elt.setAttribute("transitions", "yes")
524            root_elt.appendChild(elt)
525            transitions_sig = "y"
526        else:
527            root_elt.setAttribute("transitions", "no")
528            transitions_sig = "n"
529    
530        # add lintian QA info
531        if lintian.has_key(pkg):
532            (errs, warns) = lintian[pkg]
533            elt = doc.createElement("lintian")
534            elt.setAttribute("errors", str(errs))
535            elt.setAttribute("warnings", str(warns))
536            root_elt.appendChild(elt)
537            root_elt.setAttribute("lintian", "yes")
538            lintian_sig = (errs, warns)
539        else:
540            root_elt.setAttribute("lintian", "no")
541            lintian_sig = (0, 0)
542    
543        # add short descriptions
544        elt = doc.createElement("descriptions")
545        root_elt.appendChild(elt)
546        if shortdescs.has_key(pkg):
547            for package, shortdesc in shortdescs[pkg].iteritems():
548                desc_elt = doc.createElement("shortdesc")
549                elt.appendChild(desc_elt)
550                desc_elt.setAttribute("package", package)
551                desc_text = doc.createTextNode(shortdesc)
552                desc_elt.appendChild(desc_text)
553            shortdesc_sig = str(shortdescs[pkg]).__hash__()
554                # XXX hash(str(...)) does not work: WTF?
555        else:
556            shortdesc_sig = ''.__hash__()
557    
558      # TODO: try to do that signature checking before the creation of XML DOM      # TODO: try to do that signature checking before the creation of XML DOM
559      # Build the sig and check if anything changed      # Build the sig and check if anything changed
560      sig = (pts.get(pkg, "0"), dc_sig, wnpp_sig, override_sig, watch_sig,      sig = (pts.get(pkg, "0"), dc_sig, wnpp_sig, override_sig, dehs_sig,
561              patch_sig, s_rc, s_normal, s_wishlist, s_fixed, subsig,              ubuntu_sig, s_rc, s_normal, s_wishlist, s_fixed, s_gift, s_help,
562              svnbuildstat_sig)              subsig, svnbuildstat_sig, transitions_sig, lintian_sig,
563                shortdesc_sig, piuparts_sig, new_queue_sig)
564      if sigs.has_key(pkg) and sig == sigs[pkg] and \      if sigs.has_key(pkg) and sig == sigs[pkg] and \
565              os.path.isfile("%s/%s/%s/other.xml" % (odir, hash, pkg)):              os.path.isfile("%s/%s/%s/other.xml" % (odir, hash, pkg)):
566          continue          continue
# Line 355  while 1: Line 569  while 1:
569      # Output the data to the XML file      # Output the data to the XML file
570      try:      try:
571          f = open("%s/%s/%s/other.xml" % (odir, hash, pkg), "w")          f = open("%s/%s/%s/other.xml" % (odir, hash, pkg), "w")
572          ext.PrettyPrint(doc, f, "iso-8859-1")          ext.PrettyPrint(doc, f, "utf-8")
573          f.close()          f.close()
574      except:      except Exception, msg:
575          sys.stderr.write("Output problem for " + pkg + "/other.xml\n");          sys.stderr.write("Output problem for " + pkg + "/other.xml (%s)\n" %
576                    msg);
577    
578  # Store the signatures  # Store the signatures
579  f = open(odir + "/other.sigs", "w")  f = open(odir + "/other.sigs", "w")

Legend:
Removed from v.1800  
changed lines
  Added in v.2225

  ViewVC Help
Powered by ViewVC 1.1.5