Mercurial > hg > Feedworm
annotate feedupdate-main.py @ 26:f9a3223182c5
add a window icon
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 29 Apr 2010 06:47:22 +0200 |
parents | 42a225be7e56 |
children | 5813e3c10f14 |
rev | line source |
---|---|
2
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
2 |
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
3 from Feed import Feed |
4
e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
2
diff
changeset
|
4 from FeedUpdater import updateAllFeeds |
11
e87c54b3a216
use the logging framework for printing messages
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
6
diff
changeset
|
5 import logging |
14
42a225be7e56
first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
13
diff
changeset
|
6 from util import configureLogging, createSession |
2
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
7 |
11
e87c54b3a216
use the logging framework for printing messages
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
6
diff
changeset
|
8 logger = logging.getLogger("feedupdater") |
e87c54b3a216
use the logging framework for printing messages
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
6
diff
changeset
|
9 |
2
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
10 def createFeed(session): |
5
bfd47f55d85b
add the updated date of the feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
4
diff
changeset
|
11 if len(session.query(Feed).all()) == 0: |
bfd47f55d85b
add the updated date of the feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
4
diff
changeset
|
12 newFeed = Feed("Joel on Software", "http://www.joelonsoftware.com/rss.xml") |
bfd47f55d85b
add the updated date of the feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
4
diff
changeset
|
13 session.add(newFeed) |
bfd47f55d85b
add the updated date of the feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
4
diff
changeset
|
14 session.commit() |
2
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
15 |
4
e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
2
diff
changeset
|
16 def listFeeds(session): |
e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
2
diff
changeset
|
17 allFeeds = session.query(Feed) |
e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
2
diff
changeset
|
18 for feed in allFeeds: |
11
e87c54b3a216
use the logging framework for printing messages
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
6
diff
changeset
|
19 logger.info("feed: " + feed.name) |
4
e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
2
diff
changeset
|
20 for entry in feed.entries: |
e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
2
diff
changeset
|
21 print entry.title |
e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
2
diff
changeset
|
22 |
2
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
23 if __name__ == "__main__": |
13
591ecc2a99bd
move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
12
diff
changeset
|
24 configureLogging() |
12
9ede118b93ef
move session creation into its own module
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
11
diff
changeset
|
25 session = createSession() |
2
8a624ee48a74
First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
26 |
6
87317ba41816
add a creation date for the feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
5
diff
changeset
|
27 createFeed(session) |
87317ba41816
add a creation date for the feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
5
diff
changeset
|
28 updateAllFeeds(session) |
87317ba41816
add a creation date for the feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
5
diff
changeset
|
29 #listFeeds(session) |