Cacheability Improvements
[planet-ucc.git] / update-planet
index c0634bb..843c4ce 100755 (executable)
@@ -7,9 +7,12 @@
 # (c) 2004, Davyd Madeley <[email protected]>
 #
 
+# standard python modules
 import sys, codecs
+# planetUCC modules
 import XMLParse2 as XMLParse, XMLWriter, CacheHandler
-import XHTMLWriter, RSS2Writer
+# planetUCC output plugins
+import XHTMLWriter, RSS2Writer, RSS1Writer
 
 # step 1: read in the config and check each object from cache
 cache  = CacheHandler.CacheHandler()
@@ -25,6 +28,7 @@ for feed in open('feedlist').readlines():
                        sys.stderr.write('DEBUG: update-planet: something went wrong retrieving feed\n')
 
 # step 2: process each feed
+tainted        = False
 blogs  = []
 for feed in feeds:
        # XMLParse2 takes two paramaters, a URL and a CacheObject
@@ -33,11 +37,18 @@ for feed in feeds:
                blog.blogTitle  = feed[0]
                blog.feedURL    = feed[1]
                blogs.append(blog)
+               # check the old copy of the cache, vs the new copy
+               if not feed[2] or not feed[2].cache or not blog or not blog.cache or feed[2].cache != blog.cache:
+                       tainted = True
                # write the cache back down to disk
                cache.storeBlog(blog)
        else:
                pass
 
+if not tainted:
+       sys.stderr.write('PlanetUCC: no objects have changed in the cache, not updating\n')
+       sys.exit(1)
+
 # step 3: sift the feeds
 xmlwriter      = XMLWriter.XMLWriter(blogs)
 
@@ -46,10 +57,13 @@ try:
        codecs.open('planet.html', 'wb', 'utf-8').write(xmlwriter.write(XHTMLWriter.XHTMLWriter))
 except:
        sys.stderr.write('DEBUG: update-planet: could not write planet.html, aborting\n')
-       raise
 
 try:
        codecs.open('rss2.xml', 'wb', 'utf-8').write(xmlwriter.write(RSS2Writer.RSS2Writer))
 except:
        sys.stderr.write('DEBUG: update-planet: could not write rss2.xml, aborting\n')
-       raise
+
+try:
+       codecs.open('rss1.xml', 'wb', 'utf-8').write(xmlwriter.write(RSS1Writer.RSS1Writer))
+except:
+       sys.stderr.write('DEBUG: update-planet: could not write rss1.xml, aborting\n')

UCC git Repository :: git.ucc.asn.au