/[qa]/trunk/mia/status.py
ViewVC logotype

Contents of /trunk/mia/status.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 191 - (show annotations) (download) (as text)
Sun May 27 16:52:42 2001 UTC (12 years ago) by tbm
File MIME type: text/x-python
File size: 4925 byte(s)
Heh, only single words are allowed; why did noone tell me?
1 # The module which forms the heart of the MIA scripts
2 # Copyright (C) 2001 Martin Michlmayr <tbm@cyrius.com>
3 # $Id$
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19
20 # This is a collection of software to track down developers who are
21 # Missing In Action (MIA).
22
23 # To Veronika, who is missing in action -- action's not the same without her.
24 # -- tbm
25
26
27 import os, stat, sys, re, time, string
28
29 days = 21
30 origin = '/org/qa.debian.org/mia/db'
31
32 info = { }
33 matches = { }
34
35 def find_status(path=origin):
36 files = []
37
38 try:
39 for file in os.listdir(path):
40 root, ext = os.path.splitext(file)
41 if ext == '.summary':
42 files.append(root)
43 except OSError:
44 print 'Cannot find directory of database: %s' % path
45 sys.exit(1)
46
47 return files
48
49
50 def read_status(files):
51 for file in files:
52 try:
53 summary = open(origin + '/' + file + '.summary', 'r')
54 except IOError:
55 print 'Cannot open summary file %s' % file
56 sys.exit(1)
57
58 info[file] = { }
59
60 for line in summary.readlines():
61 result = re.search("(\d+):\s*(.*)", line)
62
63 if result is not None:
64 info[file][int(result.group(1))] = result.group(2)
65 else:
66 print 'Error parsing file %s: %s' % (file, line)
67 sys.exit(1)
68
69 summary.close()
70
71
72 def write_status(file, id, summary):
73 try:
74 status = open(origin + '/' + file + '.summary', 'a')
75 except IOError:
76 print 'Cannot open summary file to write!'
77 sys.exit(1)
78
79 string = str(id) + ': ' + summary + '\n'
80 status.write(string)
81 status.close()
82
83
84 def get_all_files():
85 files = info.keys()
86 files.sort()
87 return files
88
89
90 def get_selected_files(pattern):
91 files = get_all_files()
92 selection = [ ]
93 cpattern = re.compile(pattern, re.I)
94 for file in files:
95 if grep_items(file, cpattern):
96 selection.append(file)
97 return selection
98
99
100 def grep_items(file, cpattern):
101 for item in info[file].values():
102 if cpattern.search(item):
103 return 1
104
105
106 def print_history(file):
107 all_contacts = info[file].keys()
108 all_contacts.sort()
109 for when in all_contacts:
110 date = time.gmtime(int(when))
111 print ' %s: %.60s' % (time.strftime('%Y-%m-%d', date), info[file][when])
112
113
114 def latest(file):
115 return max(info[file].keys())
116
117
118 def should_check(file, ttl=days):
119 if (time.time() - latest(file)) > (ttl * 3600 * 24):
120 return 1
121
122
123 def compile_matches():
124 matches['ignore'] = [ 'willfix' ]
125 matches['in'] = [ 'S-V', 'FHS', 'RC', 'NMU', 'Hint', 'email' ]
126 matches['out'] = [ 'Fixed', 'Orphaned', 'Orphaning', 'Removed',
127 'Removing', 'Hijack' ]
128 matches['latest'] = [ 'Maintainer has no packages anymore', 'Retired',
129 'Retiring' ]
130
131 for key in matches.keys():
132 matches[key] = map(string.lower, matches[key])
133
134
135 def last_is_final(file):
136 if string.lower(info[file][latest(file)]) in matches['latest']:
137 return 1
138
139
140 def has_stuff_todo(file):
141 if last_is_final(file):
142 return
143
144 found = { }
145 for key in matches.keys():
146 found[key] = { }
147
148 for entry in info[file].values():
149 fields = re.split(':\s+', entry, 2)
150 if len(fields) > 1:
151 what = re.split('\s+|&', fields[0])[0]
152 packages = re.split(',\s*', string.lower(fields[1]))
153 for key in matches.keys():
154 if string.lower(what) in matches[key]:
155 for package in packages:
156 found[key][package] = 1
157 break
158 else:
159 print 'Error: do not know what to do with "%s"' % what
160 sys.exit(1)
161
162 # temporary hack to show cases without any INs.
163 if not found['in']:
164 return [ 'no-todo-list' ]
165
166 for item in found['out'].keys():
167 try:
168 del found['in'][item]
169 except KeyError:
170 print 'Warning: "%s" was not on the TODO list' % item
171
172 if found['in']:
173 # something has not been dealt with yet
174 outstanding = found['in'].keys()
175 outstanding.sort()
176 return outstanding
177
178
179 # 'main()'
180
181 compile_matches()
182

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5