Mercurial > hg > Feedworm
changeset 108:e50d446f9942 python3
updates fro python3
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 29 Mar 2011 03:17:30 +0200 |
parents | 863599e84269 |
children | e079faa547b8 |
files | FeedUpdater.py feedupdate-main.py |
diffstat | 2 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/FeedUpdater.py Thu Mar 17 02:56:56 2011 +0100 +++ b/FeedUpdater.py Tue Mar 29 03:17:30 2011 +0200 @@ -13,7 +13,7 @@ for feed in allFeeds: try: FeedUpdater(session, feed).update() - except FeedUpdateException, fue: + except FeedUpdateException as fue: log.warn("problems while updating feed " + feed.rss_url + ": " + str(fue)) session.commit()
--- a/feedupdate-main.py Thu Mar 17 02:56:56 2011 +0100 +++ b/feedupdate-main.py Tue Mar 29 03:17:30 2011 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import Database from datetime import datetime, timedelta @@ -7,6 +7,7 @@ import logging import Mapping from sqlalchemy.sql import and_ +import sys import util logger = logging.getLogger("feedupdater") @@ -16,7 +17,7 @@ for feed in allFeeds: logger.info("feed: " + feed.name) for entry in feed.entries: - print entry.title + print(entry.title) def expireFeedEntries(session): expireDate = _calculateExpireDate() @@ -32,15 +33,22 @@ delta = timedelta(days=30) return now - delta +def checkPythonVersion(): + version = sys.version_info + if version[0] < 3: + print("feedupdate-main must run on Python 3") + sys.exit(1) + if __name__ == "__main__": + checkPythonVersion() util.configureLogging() session = Database.createSession() - + #util.loadFeeds(session) #util.forceUpdateAllFeeds(session) #listFeeds(session) #OpmlImport.createFeedsFromOPML(session, "feed-data/feeds.opml.xml") FeedUpdater.updateAllFeeds(session) expireFeedEntries(session) - + session.close()