← Back to team overview

ubuntu-bugcontrol team mailing list archive

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

 

Jean-Baptiste Lallement has proposed merging lp:~jibel/ubuntu-qa-tools/report_updates.ircreport into lp:ubuntu-qa-tools.

Requested reviews:
  Ubuntu Bug Control (ubuntu-bugcontrol)

-- 
https://code.launchpad.net/~jibel/ubuntu-qa-tools/report_updates.ircreport/+merge/32461
Your team Ubuntu Bug Control is requested to review the proposed merge of lp:~jibel/ubuntu-qa-tools/report_updates.ircreport into lp:ubuntu-qa-tools.
=== modified file 'sru-report-tools/report_updates'
--- sru-report-tools/report_updates	2010-05-28 21:50:12 +0000
+++ sru-report-tools/report_updates	2010-08-12 16:07:40 +0000
@@ -23,6 +23,8 @@
 
 from launchpadlib.credentials import Credentials
 
+pockets = ('updates','security','proposed')
+
 def lp_connect(use_edge=True, beta=False):
     global no_lpnet
     cachedir = os.path.expanduser('~/.launchpadlib/cache')
@@ -53,25 +55,12 @@
 
 lp = lp_connect()
 
-# You're kidding me, I have to define my own UTC tzinfo class?!
-class UTC(datetime.tzinfo):
-    """UTC"""
-
-    def utcoffset(self, dt):
-        return datetime.timedelta(0)
-
-    def tzname(self, dt):
-        return "UTC"
-
-    def dst(self, dt):
-        return datetime.timedelta(0)
-
 date = sys.argv[1]
 if len(sys.argv) == 3:
     enddate = datetime.datetime.strptime(sys.argv[2], "%Y-%m-%d")
 else:
     enddate = datetime.datetime.fromtimestamp(time.time())
-enddate = enddate.replace(tzinfo=UTC())
+enddate = enddate.replace(tzinfo=None)
 
 ubuntu = lp.distributions['ubuntu']
 archive = ubuntu.main_archive
@@ -81,6 +70,23 @@
 series = filter(lambda x: x.name != ubuntu.current_series.name and x.active, ubuntu.series)
 #series = filter(lambda x: x.active, ubuntu.series)
 
+def generate_irc_report(pubhistory):
+    """ Generate the report for the IRC meeting """
+
+    print "=== Stable Release Updates for the past week ==="
+    for release, publications in sorted(pubhistory.iteritems()):
+        msg = ""
+        total = 0
+        for pocket in pockets:
+            total += len(publications[pocket])
+            msg += "  * %d packages published to %s-%s: %s\n" % \
+                    (len(publications[pocket]), release.name, pocket,
+            ", ".join(sorted([x.source_package_name for x in publications[pocket]])))
+
+        msg = "* A total of %d packages have been published to %s\n%s" % (
+            total, release.name, msg)
+        print msg
+
 def printhdr():
      print "|| pocket || package || version || component || date published ||"
 
@@ -95,7 +101,7 @@
             date = datetime.datetime.strptime(raw_date[:11], "%Y-%m-%dT%H:%M:%S")
     else:
         date = raw_date
-    return date
+    return date.replace(tzinfo=None)
 
 def printline(type, package):
     try:
@@ -107,6 +113,9 @@
           %(type, package.source_package_name, package.source_package_version, \
             package.component_name, None)
 
+publications = {}
+
+print "== Stable Release Updates Activity report for the past week ==\n\n"
 for release in series:
     pcnt = ucnt = pdcnt = scnt = 0
     proposed = []
@@ -151,6 +160,11 @@
     updates.sort(lambda x, y: cmp(x.source_package_name, y.source_package_name))
     security.sort(lambda x, y: cmp(x.source_package_name, y.source_package_name))
 
+    publications[release] = {
+        'proposed':list(proposed),
+        'updates':list(updates),
+        'security':list(security)
+    }
 
     print '=== %s changes ===' %(release.name)
     printhdr()
@@ -163,6 +177,8 @@
                    p.source_package_version == u.source_package_version:
                     skip = False
                     break
+            if not skip:
+                publications[release]['proposed'].remove(p)
             proposed_deleted.append(p)
         if skip:
             continue
@@ -181,6 +197,7 @@
                 skip = True
                 break
         if skip:
+            publications[release]['updates'].remove(p)
             continue
         ucnt += 1
         printline("Updates", p)
@@ -197,3 +214,6 @@
     print "Totals for %s: proposed = %d updates = %d proposed-deleted = %s security = %d" \
           %(release.name, pcnt, ucnt, pdcnt, scnt)
     print
+
+
+generate_irc_report(publications)