comparison FeedUpdater.py @ 11:e87c54b3a216

use the logging framework for printing messages
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 27 Apr 2010 20:18:22 +0200
parents 01a86b178e60
children bdd1296a4b8c
comparison
equal deleted inserted replaced
10:01a86b178e60 11:e87c54b3a216
1 1
2 from datetime import datetime 2 from datetime import datetime
3 from Feed import Feed 3 from Feed import Feed
4 from FeedEntry import FeedEntry 4 from FeedEntry import FeedEntry
5 import feedparser 5 import feedparser
6 import logging
6 7
7 STATUS_OK = 200 8 STATUS_OK = 200
9 logger = logging.getLogger("FeedUpdater")
8 10
9 def updateAllFeeds(session): 11 def updateAllFeeds(session):
10 allFeeds = session.query(Feed) 12 allFeeds = session.query(Feed)
11 for feed in allFeeds: 13 for feed in allFeeds:
12 try: 14 try:
13 FeedUpdater(session, feed).update() 15 FeedUpdater(session, feed).update()
14 except FeedUpdateException: 16 except FeedUpdateException:
15 print("problems while updating feed " + feed.rss_url) 17 logger.warn("problems while updating feed " + feed.rss_url)
16 session.commit() 18 session.commit()
17 19
18 class FeedUpdater(object): 20 class FeedUpdater(object):
19 def __init__(self, session, feed): 21 def __init__(self, session, feed):
20 self.session = session 22 self.session = session