/[qa]/trunk/data/wnpp/gen-orphaned
ViewVC logotype

Contents of /trunk/data/wnpp/gen-orphaned

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2738 - (show annotations) (download)
Mon Apr 16 16:41:41 2012 UTC (2 years, 6 months ago) by geissert
File size: 5230 byte(s)
/org -> /srv
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 Generates the orphan.txt file used by orphaned.wml.
6 This version is basically a complete rewrite from the previous version
7 and was changed to use the SOAP interface to query the BTS instead of the LDAP
8 bridge.
9 It requires the following Debian packages:
10
11 * Python 2.6
12 * python-soappy
13
14 Please change paths configured below if necessary
15 """
16
17 # Copyright (C) 2001, 2002, 2003, 2004 Martin Michlmayr <tbm@cyrius.com>
18 # 2011 Arno Töll <debian@toell.net>
19 #
20 # This program is free software; you can redistribute it and/or modify
21 # it under the terms of the GNU General Public License as published by
22 # the Free Software Foundation; either version 2 of the License, or
23 # (at your option) any later version.
24
25 # This program is distributed in the hope that it will be useful,
26 # but WITHOUT ANY WARRANTY; without even the implied warranty of
27 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 # GNU General Public License for more details.
29
30 # You should have received a copy of the GNU General Public License
31 # along with this program; if not, write to the Free Software
32 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
33 # MA 02110-1301, USA.
34
35
36 from __future__ import print_function
37
38 import sys
39 import re
40 import string
41 import SOAPpy
42 import time
43
44
45 MAINTAINER_FILE = '/srv/qa.debian.org/data/ftp/Maintainers'
46 OUTPUT_FILE = '/srv/qa.debian.org/data/orphaned.txt'
47 URL = 'http://bugs.debian.org/cgi-bin/soap.cgi'
48 NAMESPACE = 'Debbugs/SOAP'
49
50 ###
51 ### Nothing else should be changed below
52 ###
53
54 class OrphanedPackage( object ):
55 def __repr__( self ):
56 return( "%s\n%s\n%d\n%s\n%s\n%d\n\n"
57 % ( self._package, self._maintainer, self._bugid, self._title, self._reporter, self._age ) )
58
59 def __init__( self, package, maintainer, bugid, title, reporter, age ):
60 self._package = package
61 self._maintainer = maintainer
62 self._bugid = bugid
63 self._title = title
64 self._reporter = reporter
65 self._age = age
66
67
68 try:
69 input = open( MAINTAINER_FILE, 'r' )
70 except ( IOError, OSError ) as e:
71 print( "Couldn't access maintainer file `%s': %s" % ( MAINTAINER_FILE, e ) )
72 sys.exit( 1 )
73
74
75 maintainers = { }
76 orphaned = []
77
78 for line in input.readlines():
79 line = string.rstrip( re.sub( '\s+', ' ', line ) )
80 package, maintainer = string.split( line, ' ', 1 )
81 maintainers[package] = maintainer
82
83 input.close()
84
85 try:
86 server = SOAPpy.SOAPProxy( URL, NAMESPACE, simplify_objects = 1 )
87 raw_bugs = server.get_status( server.get_bugs( "package", "wnpp" ) )
88 except ( Exception ) as e:
89 print( "Can't access SOAP interface on %s (ns: %s): %s" % ( URL, NAMESPACE, e ) )
90 sys.exit( 1 )
91
92 if ( not raw_bugs or 'item' not in raw_bugs ):
93 print( "Could not retrieve any bugs (but no apparent error occurred)\n" )
94 sys.exit( 0 )
95
96 # Force argument to be a list, SOAPpy returns a dictionary instead of a dictionary list
97 # if a single bug was found. Not this were likely after all :>
98 if ( not isinstance( raw_bugs['item'], list ) ):
99 raw_bugs['item'] = ( raw_bugs['item'], )
100
101 for bugs in raw_bugs['item']:
102 current_bug = bugs['value']
103
104 # Skip bugs being done or archived
105 if ( len(current_bug['done']) or current_bug['archived']) :
106 continue
107
108 # Skip merged bugs which have an older counterpart
109 if ( current_bug['mergedwith'] ):
110 merged_bug = int( min( str.split(str(current_bug['mergedwith']) ) ) )
111 # This is the "jwilk hack(TM)". This is, to add bugs nonetheless which are
112 # duplicates of older ones, but the older is not tagged Orphaned ("O:")
113 for remaining_bugs in raw_bugs['item']:
114 if ( remaining_bugs['key'] == merged_bug ):
115 merged_bug = remaining_bugs['value']
116 break
117 else:
118 print("Could not retrieve expected duplicate bug in WNPP list\n")
119 sys.exit(1)
120
121 if ( current_bug['id'] > merged_bug['id'] and merged_bug['subject'].startswith("O:") ):
122 continue
123
124 # Skip packages with illegal subject line
125 parsed_subject = re.match( "(\w+):\s+(\S+)", current_bug['subject'] )
126 if ( not parsed_subject ):
127 continue
128
129 # Skip Non-O bugs
130 #if ( parsed_subject.group( 1 ) not in ( "O", "RFA" ) ):
131 if ( parsed_subject.group( 1 ) != "O" ):
132 continue
133
134 package = parsed_subject.group( 2 ).lower()
135
136 if ( not len( package ) ):
137 continue
138
139 # Skip packages where the maintainer is not listed in the maintainers file
140 if ( package not in maintainers ):
141 continue
142
143 # Skip packages already owned by the QA team
144 if ( string.count( maintainers[package], 'debian-qa@lists.debian.org' ) or
145 string.count( maintainers[package], 'packages@qa.debian.org' ) ):
146 continue
147
148 orphaned.append( OrphanedPackage( package = package,
149 maintainer = maintainers[package],
150 bugid = current_bug['id'],
151 title = current_bug['subject'],
152 reporter = current_bug['originator'],
153 age = int( time.time() - current_bug['date'] ) / 86400
154 ) )
155
156
157 try:
158 output = open( OUTPUT_FILE, 'w' )
159 except ( IOError, OSError ) as e:
160 print( "Output file not accessible `%s': %s" % ( MAINTAINER_FILE, e ) )
161 sys.exit( 1 )
162
163
164 output.write( str( len( orphaned ) ) + "\n\n" )
165 for orphaned_package in sorted( orphaned, key = lambda x: x._age, reverse=True ): # sort by age:
166 output.write( str( orphaned_package ) )
167
168 # vim: ts=4:expandtab:shiftwidth=4:

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5