More accurately track and report http status
This commit is contained in:
parent
9d85882503
commit
777cd9b603
@ -80,6 +80,7 @@ Base = [
|
||||
['title', String, 'title_detail', 'value'],
|
||||
['title_plain', Plain, 'title_detail', 'value'],
|
||||
['url', String, 'links', {'rel':'self'}, 'href'],
|
||||
['url', String, 'planet_http_location'],
|
||||
]
|
||||
|
||||
Items = [
|
||||
|
@ -128,7 +128,9 @@ def spiderFeed(feed):
|
||||
|
||||
# process based on the HTTP status code
|
||||
log = planet.logger
|
||||
if data.status == 301 and data.has_key("entries") and len(data.entries)>0:
|
||||
if data.status == 200 and data.has_key("url"):
|
||||
data.feed['planet_http_location'] = data.url
|
||||
elif data.status == 301 and data.has_key("entries") and len(data.entries)>0:
|
||||
log.warning("Feed has moved from <%s> to <%s>", feed, data.url)
|
||||
data.feed['planet_http_location'] = data.url
|
||||
elif data.status == 304:
|
||||
@ -194,14 +196,6 @@ def spiderFeed(feed):
|
||||
# perform user configured scrub operations on the data
|
||||
scrub(feed, data)
|
||||
|
||||
# write the feed info to the cache
|
||||
if not os.path.exists(sources): os.makedirs(sources)
|
||||
xdoc=minidom.parseString('''<feed xmlns:planet="%s"
|
||||
xmlns="http://www.w3.org/2005/Atom"/>\n''' % planet.xmlns)
|
||||
reconstitute.source(xdoc.documentElement, data.feed, data.bozo)
|
||||
write(xdoc.toxml('utf-8'), filename(sources, feed))
|
||||
xdoc.unlink()
|
||||
|
||||
# write each entry to the cache
|
||||
cache = config.cache_directory()
|
||||
for entry in data.entries:
|
||||
@ -240,6 +234,14 @@ def spiderFeed(feed):
|
||||
write(output, cache_file)
|
||||
os.utime(cache_file, (mtime, mtime))
|
||||
|
||||
# write the feed info to the cache
|
||||
if not os.path.exists(sources): os.makedirs(sources)
|
||||
xdoc=minidom.parseString('''<feed xmlns:planet="%s"
|
||||
xmlns="http://www.w3.org/2005/Atom"/>\n''' % planet.xmlns)
|
||||
reconstitute.source(xdoc.documentElement, data.feed, data.bozo)
|
||||
write(xdoc.toxml('utf-8'), filename(sources, feed))
|
||||
xdoc.unlink()
|
||||
|
||||
def spiderPlanet():
|
||||
""" Spider (fetch) an entire planet """
|
||||
log = planet.getLogger(config.log_level())
|
||||
|
@ -37,9 +37,24 @@
|
||||
<xsl:sort select="planet:name"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<li>
|
||||
<a href="{atom:link[@rel='self']/@href}" title="subscribe">
|
||||
<!-- icon -->
|
||||
<a title="subscribe">
|
||||
<xsl:choose>
|
||||
<xsl:when test="planet:http_location">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="planet:http_location"/>
|
||||
</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="atom:link[@rel='self']/@href">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="atom:link[@rel='self']/@href"/>
|
||||
</xsl:attribute>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<img src="images/feed-icon-10x10.png" alt="(feed)"/>
|
||||
</a>
|
||||
|
||||
<!-- name -->
|
||||
<a href="{atom:link[@rel='alternate']/@href}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="planet:message">
|
||||
|
Loading…
x
Reference in New Issue
Block a user