diff --git a/atomstrom.py b/atomstrom.py index 1fe6109..c40ccd5 100755 --- a/atomstrom.py +++ b/atomstrom.py @@ -171,22 +171,22 @@ def process_feed_entry(session, feed, entry): def fetch_single_feed(session, feed): print 'processing %s' % feed.url - query = session.query(Feedinfo).filter(Feedinfo.feed_id==feed.id) + thisfeedinfo = session.query(Feedinfo).\ + filter(Feedinfo.feed_id==feed.id).\ + first() fetched = False - # TODO: remove exception, see above - try: - feed.feedinfo = query.one() + if thisfeedinfo: + feed.feedinfo = thisfeedinfo nextfetch = (feed.feedinfo.lastfetched + timedelta(minutes=feed.frequency)) if datetime.now() > nextfetch: - print 'fetching...' + print 'feed known, fetching...' parser = feedparser.parse(feed.url) fetched = True feed.feedinfo.update(parser) else: print 'not fetching before: %s' % nextfetch - except Exception, e: - print 'this feed seems to be new' - print 'fetching...' + else: + print 'feed seems to be new, fetching...' parser = feedparser.parse(feed.url) fetched = True feed.feedinfo = Feedinfo(parser)