annotate util.py @ 51:8eee0e671696

set our custom window icon on all dialogs
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 18 May 2010 02:32:33 +0200
parents 03358c113170
children 254d5b89a6ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
9ede118b93ef move session creation into its own module
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1
35
aaec263f07ca Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 34
diff changeset
2 from datetime import datetime, timedelta
34
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
3 from Feed import Feed
13
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
4 import logging
12
9ede118b93ef move session creation into its own module
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5
13
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
6 logger = logging.getLogger("database")
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
7
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
8 def configureLogging():
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
9 logging.basicConfig(level=logging.DEBUG)
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
10 logging.getLogger("sqlalchemy").setLevel(logging.INFO)
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
11 logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN)
591ecc2a99bd move logging configuration to the util module, configure logging for sqlalchemy
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
12
34
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
13 def loadFeeds(session=None, filename="feeds.txt"):
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
14 file = open(filename)
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
15 for line in file:
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
16 (title, rss_url) = line.split("|")
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
17 # remove the newline
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
18 rss_url = rss_url.rstrip()
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
19 feed = Feed(title, rss_url)
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
20 session.add(feed)
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
21 file.close()
5813e3c10f14 move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 28
diff changeset
22 session.commit()
35
aaec263f07ca Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 34
diff changeset
23
aaec263f07ca Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 34
diff changeset
24 def forceUpdateAllFeeds(session=None):
aaec263f07ca Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 34
diff changeset
25 for feed in Feed.all(session):
aaec263f07ca Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 34
diff changeset
26 feed.next_update = datetime.now() - timedelta(minutes=1)
aaec263f07ca Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 34
diff changeset
27 session.commit()
43
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 37
diff changeset
28
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 37
diff changeset
29 def str2bool(string):
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 37
diff changeset
30 return string.lower() in ["yes", "true", "t", "1"]
46
03358c113170 Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
31
03358c113170 Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
32 def bool2str(bool):
03358c113170 Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
33 if bool:
03358c113170 Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
34 return "True"
03358c113170 Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
35 else:
03358c113170 Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
36 return "False"