def main():
# Initialise the logging module and configure it for our console logging.
# I'll factor this out soon so it's less convoluted.
# There's probably a better way of doing this with the Gui version,
# but we have to start somewhere. :) - gtk
# logging.basicConfig()
handler = logging.handlers.MemoryHandler(65536)
#handler.formatter = conlogging.ConsoleFormatter("%(message)s", wrap=False)
log.addHandler(handler)
log.propagate = 0
logging.addLevelName(SPAM, "SPAM")
# Parse our configuration files.
# I'll factor this out soon so it's less convoluted.
parser = makeCommandLineParser()
options, args = parser.parse_args()
if options.debug:
log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
try:
config = Configuration(options)
except RunTwiceError, e:
quiet = False
config = e.value
if "Win" in platform.system() and config["listen_port"]:
#Try to raise the app.
import xmlrpclib, win32gui
try:
s = xmlrpclib.Server("http://localhost:%d" % config["listen_port"])
s.wake()
h = s.getHwnd()
win32gui.SetForegroundWindow(h)
quiet = True
if options.add_feed:
s.addFeed(options.add_feed)
elif options.add_feed_from_rss:
s.addFeedFromRss(options.add_feed_from_rss)
except:
pass
if not quiet:
app = wx.App()
app.MainLoop()
currentlanguage = LanguageModule.ENGLISH
#TODO: Safely read the screen language. State is currently
#being used by the other running process.
stringtable = LanguageModule.StringTable(currentlanguage)
alert = wx.MessageDialog(None, stringtable.GetText(currentlanguage, "str_other_copy_running"), style=wx.OK)
response = alert.ShowModal()
alert.Destroy()
sys.exit(0)
if options.debug: # just in case config file over-rode it
log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
# Open our state database.
state = statemodule.open(config)
ipodder = core.iPodder(config,state)
try:
myApp = iPodderGui(ipodder,options)
listener = iPodderSubscribeListener(myApp,config)
listener.start()
myApp.MainLoop()
finally:
state.close()
ipodder.history.close()
if __name__ == '__main__':
main()