Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make list of publishable feeds configurable, per:

http://lists.planetplanet.org/archives/devel/2010-June/002149.html

Also change use of stderr to log, and provide a main program entry point
which can be used to initiate publishing.
  • Loading branch information...
commit 399b0f052ab30aafc37e848e8850c8ca0f95de61 1 parent e51f58a
@rubys authored
View
3  docs/config.html
@@ -126,6 +126,9 @@ <h3 id="planet"><code>[planet]</code></h3>
subscribers. See
the <a href="http://code.google.com/p/pubsubhubbub/"> PubSubHubbub
home page</a> for more information.</dd>
+<dt><ins>pubsubhubbub_feeds</ins></dt>
+<dd>List of feeds to publish. Defaults to <code>atom.xml rss10.xml
+rss20.xml</code>.</dd>
</dl>
<p>Additional options can be found in
<a href="normalization.html#overrides">normalization level overrides</a>.</p>
View
1  planet/config.py
@@ -106,6 +106,7 @@ def define_tmpl_int(name, default):
define_planet('output_dir', 'output')
define_planet('spider_threads', 0)
define_planet('pubsubhubbub_hub', '')
+ define_planet_list('pubsubhubbub_feeds', 'atom.xml rss10.xml rss20.xml')
define_planet_int('new_feed_items', 0)
define_planet_int('feed_timeout', 20)
View
23 planet/publish.py
@@ -1,15 +1,26 @@
import os, sys
import urlparse
+import planet
import pubsubhubbub_publisher as PuSH
def publish(config):
+ log = planet.logger
hub = config.pubsubhubbub_hub()
link = config.link()
+
+ # identify feeds
+ feeds = []
if hub and link:
for root, dirs, files in os.walk(config.output_dir()):
- xmlfiles = [urlparse.urljoin(link, f) for f in files if f in ['atom.xml', 'rss10.xml', 'rss20.xml']]
- try:
- PuSH.publish(hub, xmlfiles)
- except PuSH.PublishError, e:
- sys.stderr.write("PubSubHubbub publishing error: %s\n" % e)
- break
+ for file in files:
+ if file in config.pubsubhubbub_feeds():
+ feeds.append(urlparse.urljoin(link, file))
+
+ # publish feeds
+ if feeds:
+ try:
+ PuSH.publish(hub, feeds)
+ for feed in feeds:
+ log.info("Published %s to %s\n" % (feed, hub))
+ except PuSH.PublishError, e:
+ log.error("PubSubHubbub publishing error: %s\n" % e)
View
17 publish.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+"""
+Main program to run just the splice portion of planet
+"""
+
+import os.path
+import sys
+from planet import publish, config
+
+if __name__ == '__main__':
+
+ if len(sys.argv) == 2 and os.path.isfile(sys.argv[1]):
+ config.load(sys.argv[1])
+ publish.publish(config)
+ else:
+ print "Usage:"
+ print " python %s config.ini" % sys.argv[0]
Please sign in to comment.
Something went wrong with that request. Please try again.