incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1437856 - in /incubator/public/trunk/incuvoter: incuvoter.py votestatus.py
Date Thu, 24 Jan 2013 04:00:48 GMT
Author: brane
Date: Thu Jan 24 04:00:48 2013
New Revision: 1437856

URL: http://svn.apache.org/viewvc?rev=1437856&view=rev
Log:
Incuvoter: Switch to Markmail feed and fix bugs revealed by different feed formatting.

Modified:
    incubator/public/trunk/incuvoter/incuvoter.py
    incubator/public/trunk/incuvoter/votestatus.py

Modified: incubator/public/trunk/incuvoter/incuvoter.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/incuvoter/incuvoter.py?rev=1437856&r1=1437855&r2=1437856&view=diff
==============================================================================
--- incubator/public/trunk/incuvoter/incuvoter.py (original)
+++ incubator/public/trunk/incuvoter/incuvoter.py Thu Jan 24 04:00:48 2013
@@ -33,11 +33,15 @@ import collections
 import datetime
 import feedparser
 import sqlite3
+import time
 
 
 class FeedParser(object):
-
-    __feed_url = 'http://mail-archives.apache.org/mod_mbox/incubator-general/?format=atom'
+    # FIXME: Our own feed seems to be woefully incomplete. Use Markmail's for now.
+    #__feed_url = 'http://mail-archives.apache.org/mod_mbox/incubator-general/?format=atom'
+    __feed_url = ('http://markmail.org/atom/list:org.apache.incubator.general+date:'
+                  + datetime.datetime.utcnow().strftime('%Y%m')  # current month
+                  + '+order:date-forward')
 
     __subject_rx = re.compile(
         # Skip anything before the first tag
@@ -61,7 +65,8 @@ class FeedParser(object):
     def record(self, database):
         feed_updated = self.feed.get('updated', None)
         if not feed_updated:
-            return
+            feed_updated = database.Vote.timefmt(datetime.datetime.utcnow())
+            #return
 
         votes = []
         for e in self.feed.entries:
@@ -74,11 +79,20 @@ class FeedParser(object):
                 continue
 
             subject = parsed.group('subject')
-            updated = max(e.get('created', None), e.get('updated', None))
+            created = e.get('created_parsed', None)
+            if created:
+                created = datetime.datetime.fromtimestamp(time.mktime(created))
+            updated = e.get('updated_parsed', None)
+            if updated:
+                updated = datetime.datetime.fromtimestamp(time.mktime(updated))
+            if updated and created and created > updated:
+                updated = created
+            updated = database.Vote.timefmt(updated)
             if parsed.group('firstres') or parsed.group('secondres'):
                 closed = updated
             else:
                 closed = None
+
             votes.append(self.ParsedVote(subject.upper(),
                                          updated, closed, subject))
 
@@ -171,16 +185,24 @@ class FeedDatabase(object):
 
         @classmethod
         def timeobj(cls, datestring):
-            try:
-                return datetime.datetime.strptime(datestring, '%Y-%m-%dT%H:%M:%SZ')
-            except:
-                return datestring
+            return datetime.datetime.strptime(datestring, '%Y-%m-%d %H:%M:%S')
+
+        class __ZULU(datetime.tzinfo):
+            def utcoffset(self, dt):
+                return 0;
+            def dst(self, dt):
+                return timedelta(0)
+            def tzname(self,dt):
+                return "Z"
+        ZULU = __ZULU()
 
         @classmethod
         def timefmt(cls, dateobject):
             if isinstance(dateobject, datetime.datetime):
+                if dateobject.tzinfo:
+                    dateobject = dateobject.astimezone(cls.ZULU)
                 return dateobject.isoformat().replace('T', ' ')
-            return dateobject
+            return str(dateobject)
 
         @classmethod
         def find(cls, con, subject):
@@ -258,7 +280,7 @@ class FeedDatabase(object):
                        " WHERE closed IS NOT NULL ORDER BY closed DESC")
         obsolete = []
         for row in cursor.fetchall():
-            updated = self.timeobj(row['updated'])
+            updated = self.Vote.timeobj(row['updated'])
             if now - updated > datetime.timedelta(days = 30):
                 obsolete.append(row['sortkey'])
         if obsolete:

Modified: incubator/public/trunk/incuvoter/votestatus.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/incuvoter/votestatus.py?rev=1437856&r1=1437855&r2=1437856&view=diff
==============================================================================
--- incubator/public/trunk/incuvoter/votestatus.py (original)
+++ incubator/public/trunk/incuvoter/votestatus.py Thu Jan 24 04:00:48 2013
@@ -150,7 +150,7 @@ def refresh_page(target, database):
     else:
         current = ''
 
-    closed = []
+    resolved = []
     for vote in database.list_resolved_votes():
         noticed = vote.timeobj(vote.noticed)
         closed = vote.timeobj(vote.closed)
@@ -159,19 +159,19 @@ def refresh_page(target, database):
             klass = 'warn'
         else:
             klass = 'normal'
-        closed.append(__closed_row
-                      % dict(klass = klass,
-                             subject = __htmlescape(vote.subject),
-                             noticed = __htmlescape(vote.timefmt(noticed)),
-                             closed = __htmlescape(vote.timefmt(closed))))
-    if closed:
-        closed = __closed_table % '\n'.join(closed)
+        resolved.append(__closed_row
+                        % dict(klass = klass,
+                               subject = __htmlescape(vote.subject),
+                               noticed = __htmlescape(vote.timefmt(noticed)),
+                               closed = __htmlescape(vote.timefmt(closed))))
+    if resolved:
+        resolved = __closed_table % '\n'.join(resolved)
     else:
-        closed = ''
+        resolved = ''
 
     temp = target + '.temp'
     with open(temp, 'wt') as page:
-        page.write(__page_template % (current, closed))
+        page.write(__page_template % (current, resolved))
     os.rename(temp, target)
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message