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.
This commit is contained in:
parent
e51f58a2c4
commit
399b0f052a
@ -126,6 +126,9 @@ hub when feeds are published, speeding delivery of updates to
|
|||||||
subscribers. See
|
subscribers. See
|
||||||
the <a href="http://code.google.com/p/pubsubhubbub/"> PubSubHubbub
|
the <a href="http://code.google.com/p/pubsubhubbub/"> PubSubHubbub
|
||||||
home page</a> for more information.</dd>
|
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>
|
</dl>
|
||||||
<p>Additional options can be found in
|
<p>Additional options can be found in
|
||||||
<a href="normalization.html#overrides">normalization level overrides</a>.</p>
|
<a href="normalization.html#overrides">normalization level overrides</a>.</p>
|
||||||
|
@ -106,6 +106,7 @@ def __init__():
|
|||||||
define_planet('output_dir', 'output')
|
define_planet('output_dir', 'output')
|
||||||
define_planet('spider_threads', 0)
|
define_planet('spider_threads', 0)
|
||||||
define_planet('pubsubhubbub_hub', '')
|
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('new_feed_items', 0)
|
||||||
define_planet_int('feed_timeout', 20)
|
define_planet_int('feed_timeout', 20)
|
||||||
|
@ -1,15 +1,26 @@
|
|||||||
import os, sys
|
import os, sys
|
||||||
import urlparse
|
import urlparse
|
||||||
|
import planet
|
||||||
import pubsubhubbub_publisher as PuSH
|
import pubsubhubbub_publisher as PuSH
|
||||||
|
|
||||||
def publish(config):
|
def publish(config):
|
||||||
|
log = planet.logger
|
||||||
hub = config.pubsubhubbub_hub()
|
hub = config.pubsubhubbub_hub()
|
||||||
link = config.link()
|
link = config.link()
|
||||||
|
|
||||||
|
# identify feeds
|
||||||
|
feeds = []
|
||||||
if hub and link:
|
if hub and link:
|
||||||
for root, dirs, files in os.walk(config.output_dir()):
|
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']]
|
for file in files:
|
||||||
try:
|
if file in config.pubsubhubbub_feeds():
|
||||||
PuSH.publish(hub, xmlfiles)
|
feeds.append(urlparse.urljoin(link, file))
|
||||||
except PuSH.PublishError, e:
|
|
||||||
sys.stderr.write("PubSubHubbub publishing error: %s\n" % e)
|
# publish feeds
|
||||||
break
|
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)
|
||||||
|
17
publish.py
Executable file
17
publish.py
Executable file
@ -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]
|
Loading…
x
Reference in New Issue
Block a user