extras-repoclosure rc-report.py,1.10,1.11
Michael Schwendt (mschwendt)
fedora-extras-commits at redhat.com
Wed Jul 19 15:03:37 UTC 2006
Author: mschwendt
Update of /cvs/fedora/extras-repoclosure
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4995
Modified Files:
rc-report.py
Log Message:
Enhance history information, so we save the timestamp of when a
broken package was discovered and keep this information until the
src.rpm name changes.
Use pickle for lazy serialisation.
Print age of a broken package in the summary.
Index: rc-report.py
===================================================================
RCS file: /cvs/fedora/extras-repoclosure/rc-report.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- rc-report.py 16 Jul 2006 14:01:43 -0000 1.10
+++ rc-report.py 19 Jul 2006 15:03:33 -0000 1.11
@@ -4,6 +4,7 @@
import commands
import datetime, time
import os, sys
+import pickle
import re
import smtplib
@@ -36,35 +37,36 @@
history = {}
incoming = {}
+ expired = {}
- def __init__(self): # Load history map file and expire its contents.
- try:
- f = file ('history.txt')
- for line in f:
- (srcrpm,timestamp) = line.rstrip().split(' ')
- (y,m,d) = timestamp.split('-')
- timestamp = datetime.date( int(y), int(m), int(d) )
- if ( timestamp+waitdelta > today ): # Filter out entries which are too old.
- self.history[srcrpm] = timestamp
- f.close()
- except IOError:
- print 'WARNING: could not open history file for reading'
- except:
- pass
+ def __init__(self,release): # Load history map file and expire its contents.
+ self.historyname = 'history-%s.pickle' % release
+ f = file(self.historyname,'r')
+ self.tmpdict = pickle.load(f)
+ f.close()
+ # Build up history/expired dicts.
+ for srcrpm,tmpdict in self.tmpdict.iteritems():
+ discovereddate = tmpdict['discovered']
+ if ( discovereddate+waitdelta > today ):
+ self.history[srcrpm] = self.tmpdict[srcrpm]
+ else:
+ # Filter out entries which are too old.
+ # We collect them in a different dict, so they are not
+ # lost when we discover that a src.rpm is still broken.
+ self.expired[srcrpm] = self.tmpdict[srcrpm]
def Save(self):
for srcrpm,timestamp in self.incoming.iteritems():
- self.Set(srcrpm,timestamp)
- try:
- f = file ('history.txt','w')
- for srcrpm,timestamp in self.history.iteritems():
- f.write( ('%s %s\n' % (srcrpm,timestamp)) )
- f.close()
- except:
- print 'WARNING: could not open history file for writing'
-
- def Set(self,srcrpmname,timestamp):
- self.history[srcrpmname] = timestamp
+ self.Set(srcrpm,timestamp,timestamp)
+ f = file(self.historyname,'w')
+ pickle.dump(self.history,f)
+ f.close()
+
+ def Set(self,srcrpmname,discovereddate,reporteddate):
+ self.history[srcrpmname] = {
+ 'discovered' : discovereddate,
+ 'reported' : reporteddate
+ }
def SetDelayed(self,srcrpmname,timestamp):
self.incoming[srcrpmname] = timestamp
@@ -73,11 +75,23 @@
try:
r = self.history[srcrpmname]
except KeyError:
- r = 0
+ try:
+ r = self.expired[srcrpmname]
+ self.Set(srcrpmname,r['discovered'],r['reported'])
+ except KeyError:
+ r = 0
return r
-
-
+ def GetAge(self,srcrpmname):
+ r = self.Get(srcrpmname)
+ if not r:
+ return ''
+ discovereddate = r['discovered']
+ d = today-discovereddate
+ if d.days > 7:
+ return '(%s days)' % d.days
+ return ''
+
def mail(smtp, fromaddr, toaddrs, replytoaddr, subject, body):
from email.Header import Header
from email.MIMEText import MIMEText
@@ -163,7 +177,7 @@
summail = ''
owners = PackageOwners()
-history = History()
+history = History(release)
report = {} # map, report[email], mail message body to be sent to somebody
pkgbyowner = {} # map, pkgbyowner[email], list of pkgids for all owner's broken packages
summary = {} # map of maps, summary[repoid][pkgid], unresolved deps line by line
@@ -179,6 +193,7 @@
print 'ERROR: could not open input file'
sys.exit(5)
+srcrpmdict = {}
for line in f:
if line.startswith('source rpm: '):
w = line.rstrip().split(' ')
@@ -186,7 +201,7 @@
srcrpm = w[2]
inbody = True
createreport = not (usehistory and history.Get(srcrpm))
- if not history.Get(srcrpm):
+ if usehistory and not history.Get(srcrpm):
history.SetDelayed(srcrpm,today)
else:
inbody = False
@@ -214,6 +229,7 @@
pkgid = w[1]+'-'+w[3]
pkgid2 = w[1]+' - '+w[3]
+ srcrpmdict[pkgid2] = srcrpm
if not pkgbyowner.has_key(ownedby):
pkgbyowner[ownedby] = [pkgid2]
else:
@@ -247,7 +263,10 @@
pkgs = pkgbyowner[owner]
pkgs.sort()
for pkg in pkgs:
- summail += ' '+pkg+'\n'
+ summail += ' '+pkg
+ srcrpm = srcrpmdict[pkg]
+ summail += ' '+history.GetAge(srcrpmdict[pkg])
+ summail += '\n'
summail += '\n'
if len(owners):
summail += '\n'
More information about the fedora-extras-commits
mailing list