Merge lp:~jibel/ubuntu-qa-tools/report_updates.ircreport into lp:ubuntu-qa-tools

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: 395
Proposed branch: lp:~jibel/ubuntu-qa-tools/report_updates.ircreport
Merge into: lp:ubuntu-qa-tools
Diff against target: 118 lines (+35/-15)
1 file modified
sru-report-tools/report_updates (+35/-15)
To merge this branch: bzr merge lp:~jibel/ubuntu-qa-tools/report_updates.ircreport
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+32461@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

This looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sru-report-tools/report_updates'
2--- sru-report-tools/report_updates 2010-05-28 21:50:12 +0000
3+++ sru-report-tools/report_updates 2010-08-12 16:07:40 +0000
4@@ -23,6 +23,8 @@
5
6 from launchpadlib.credentials import Credentials
7
8+pockets = ('updates','security','proposed')
9+
10 def lp_connect(use_edge=True, beta=False):
11 global no_lpnet
12 cachedir = os.path.expanduser('~/.launchpadlib/cache')
13@@ -53,25 +55,12 @@
14
15 lp = lp_connect()
16
17-# You're kidding me, I have to define my own UTC tzinfo class?!
18-class UTC(datetime.tzinfo):
19- """UTC"""
20-
21- def utcoffset(self, dt):
22- return datetime.timedelta(0)
23-
24- def tzname(self, dt):
25- return "UTC"
26-
27- def dst(self, dt):
28- return datetime.timedelta(0)
29-
30 date = sys.argv[1]
31 if len(sys.argv) == 3:
32 enddate = datetime.datetime.strptime(sys.argv[2], "%Y-%m-%d")
33 else:
34 enddate = datetime.datetime.fromtimestamp(time.time())
35-enddate = enddate.replace(tzinfo=UTC())
36+enddate = enddate.replace(tzinfo=None)
37
38 ubuntu = lp.distributions['ubuntu']
39 archive = ubuntu.main_archive
40@@ -81,6 +70,23 @@
41 series = filter(lambda x: x.name != ubuntu.current_series.name and x.active, ubuntu.series)
42 #series = filter(lambda x: x.active, ubuntu.series)
43
44+def generate_irc_report(pubhistory):
45+ """ Generate the report for the IRC meeting """
46+
47+ print "=== Stable Release Updates for the past week ==="
48+ for release, publications in sorted(pubhistory.iteritems()):
49+ msg = ""
50+ total = 0
51+ for pocket in pockets:
52+ total += len(publications[pocket])
53+ msg += " * %d packages published to %s-%s: %s\n" % \
54+ (len(publications[pocket]), release.name, pocket,
55+ ", ".join(sorted([x.source_package_name for x in publications[pocket]])))
56+
57+ msg = "* A total of %d packages have been published to %s\n%s" % (
58+ total, release.name, msg)
59+ print msg
60+
61 def printhdr():
62 print "|| pocket || package || version || component || date published ||"
63
64@@ -95,7 +101,7 @@
65 date = datetime.datetime.strptime(raw_date[:11], "%Y-%m-%dT%H:%M:%S")
66 else:
67 date = raw_date
68- return date
69+ return date.replace(tzinfo=None)
70
71 def printline(type, package):
72 try:
73@@ -107,6 +113,9 @@
74 %(type, package.source_package_name, package.source_package_version, \
75 package.component_name, None)
76
77+publications = {}
78+
79+print "== Stable Release Updates Activity report for the past week ==\n\n"
80 for release in series:
81 pcnt = ucnt = pdcnt = scnt = 0
82 proposed = []
83@@ -151,6 +160,11 @@
84 updates.sort(lambda x, y: cmp(x.source_package_name, y.source_package_name))
85 security.sort(lambda x, y: cmp(x.source_package_name, y.source_package_name))
86
87+ publications[release] = {
88+ 'proposed':list(proposed),
89+ 'updates':list(updates),
90+ 'security':list(security)
91+ }
92
93 print '=== %s changes ===' %(release.name)
94 printhdr()
95@@ -163,6 +177,8 @@
96 p.source_package_version == u.source_package_version:
97 skip = False
98 break
99+ if not skip:
100+ publications[release]['proposed'].remove(p)
101 proposed_deleted.append(p)
102 if skip:
103 continue
104@@ -181,6 +197,7 @@
105 skip = True
106 break
107 if skip:
108+ publications[release]['updates'].remove(p)
109 continue
110 ucnt += 1
111 printline("Updates", p)
112@@ -197,3 +214,6 @@
113 print "Totals for %s: proposed = %d updates = %d proposed-deleted = %s security = %d" \
114 %(release.name, pcnt, ucnt, pdcnt, scnt)
115 print
116+
117+
118+generate_irc_report(publications)