fixed missing import
This commit is contained in:
parent
752794115e
commit
33da084705
12
atomstrom.py
12
atomstrom.py
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from models import Base, Feed, Feedinfo, Entry
|
from models import Base, Feed, Feedinfo, Entry
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine, desc
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import feedparser
|
import feedparser
|
||||||
@ -143,7 +143,7 @@ def process_feed_entry(session, feed, entry):
|
|||||||
session.commit()
|
session.commit()
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
print ' new entry <%s>' % entry.title
|
# print ' new entry <%s>' % entry.title
|
||||||
thisentry = Entry(entry)
|
thisentry = Entry(entry)
|
||||||
if feed.resolveredirects:
|
if feed.resolveredirects:
|
||||||
print ' fetching final link <%s>' % entry.link
|
print ' fetching final link <%s>' % entry.link
|
||||||
@ -180,16 +180,24 @@ def fetch_single_feed(session, feed):
|
|||||||
nextfetch = (feed.feedinfo.lastfetched + timedelta(minutes=feed.frequency))
|
nextfetch = (feed.feedinfo.lastfetched + timedelta(minutes=feed.frequency))
|
||||||
if datetime.now() > nextfetch:
|
if datetime.now() > nextfetch:
|
||||||
print 'feed known, fetching...'
|
print 'feed known, fetching...'
|
||||||
|
try:
|
||||||
parser = feedparser.parse(feed.url)
|
parser = feedparser.parse(feed.url)
|
||||||
fetched = True
|
fetched = True
|
||||||
feed.feedinfo.update(parser)
|
feed.feedinfo.update(parser)
|
||||||
|
except:
|
||||||
|
print 'ERROR parsing feed'
|
||||||
|
print sys.exc_info()
|
||||||
else:
|
else:
|
||||||
print 'not fetching before: %s' % nextfetch
|
print 'not fetching before: %s' % nextfetch
|
||||||
else:
|
else:
|
||||||
print 'feed seems to be new, fetching...'
|
print 'feed seems to be new, fetching...'
|
||||||
|
try:
|
||||||
parser = feedparser.parse(feed.url)
|
parser = feedparser.parse(feed.url)
|
||||||
fetched = True
|
fetched = True
|
||||||
feed.feedinfo = Feedinfo(parser)
|
feed.feedinfo = Feedinfo(parser)
|
||||||
|
except:
|
||||||
|
print 'ERROR parsing feed'
|
||||||
|
print sys.exc_info()
|
||||||
|
|
||||||
if fetched:
|
if fetched:
|
||||||
print 'processing feed entries:'
|
print 'processing feed entries:'
|
||||||
|
Loading…
Reference in New Issue
Block a user