Mercurial > hg > Feedworm
view util.py @ 35:aaec263f07ca
Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 05 May 2010 03:07:59 +0200 |
parents | 5813e3c10f14 |
children | 22214d79ed41 |
line wrap: on
line source
from ConfigParser import ConfigParser from datetime import datetime, timedelta from Feed import Feed import logging import socket logger = logging.getLogger("database") def configureLogging(): logging.basicConfig(level=logging.DEBUG) logging.getLogger("sqlalchemy").setLevel(logging.INFO) logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN) def loadDatabaseUrl(): hostname = socket.gethostname() filename = "database-%s.ini" % hostname logger.debug("loading database configuration from " + filename) parser = ConfigParser(); parser.read(filename) return parser.get("database", "url") def loadFeeds(session=None, filename="feeds.txt"): file = open(filename) for line in file: (title, rss_url) = line.split("|") # remove the newline rss_url = rss_url.rstrip() feed = Feed(title, rss_url) session.add(feed) file.close() session.commit() def forceUpdateAllFeeds(session=None): for feed in Feed.all(session): feed.next_update = datetime.now() - timedelta(minutes=1) session.commit()