Attachment 'ipodder_main.py'

Download

   1 def main():
   2     # Initialise the logging module and configure it for our console logging.
   3     # I'll factor this out soon so it's less convoluted.
   4     # There's probably a better way of doing this with the Gui version, 
   5     # but we have to start somewhere. :) - gtk
   6     # logging.basicConfig()
   7     handler = logging.handlers.MemoryHandler(65536)
   8     #handler.formatter = conlogging.ConsoleFormatter("%(message)s", wrap=False)
   9     log.addHandler(handler)
  10     log.propagate = 0
  11     logging.addLevelName(SPAM, "SPAM")
  12 
  13     # Parse our configuration files.
  14     # I'll factor this out soon so it's less convoluted.
  15     parser = makeCommandLineParser()
  16     options, args = parser.parse_args()
  17     if options.debug: 
  18         log.setLevel(logging.DEBUG)
  19     else:
  20         log.setLevel(logging.INFO)
  21     try:
  22         config = Configuration(options)
  23     except RunTwiceError, e:
  24         quiet = False
  25         config = e.value
  26         if "Win" in platform.system() and config["listen_port"]:
  27             #Try to raise the app.
  28             import xmlrpclib, win32gui
  29             try:
  30                 s = xmlrpclib.Server("http://localhost:%d" % config["listen_port"])
  31                 s.wake()
  32                 h = s.getHwnd()
  33                 win32gui.SetForegroundWindow(h)
  34                 quiet = True
  35                 if options.add_feed:
  36                     s.addFeed(options.add_feed)
  37                 elif options.add_feed_from_rss:
  38                     s.addFeedFromRss(options.add_feed_from_rss)
  39             except:
  40                 pass
  41 
  42         if not quiet:
  43             app = wx.App()
  44             app.MainLoop()
  45 
  46             currentlanguage = LanguageModule.ENGLISH
  47             #TODO: Safely read the screen language.  State is currently
  48             #being used by the other running process.
  49             stringtable = LanguageModule.StringTable(currentlanguage)
  50             alert = wx.MessageDialog(None, stringtable.GetText(currentlanguage, "str_other_copy_running"), style=wx.OK)
  51             response = alert.ShowModal()
  52             alert.Destroy()
  53         sys.exit(0)
  54         
  55     if options.debug: # just in case config file over-rode it
  56         log.setLevel(logging.DEBUG)
  57     else:
  58         log.setLevel(logging.INFO)
  59 
  60     # Open our state database.
  61     state = statemodule.open(config)
  62     
  63     ipodder = core.iPodder(config,state)
  64 
  65     try: 
  66         myApp = iPodderGui(ipodder,options)
  67         listener = iPodderSubscribeListener(myApp,config)
  68         listener.start()
  69         myApp.MainLoop()
  70     finally: 
  71         state.close()
  72         ipodder.history.close()
  73 
  74 if __name__ == '__main__':
  75     main()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-10-04 09:16:04, 77.9 KB) [[attachment:ipodder.jpg]]
  • [get | view] (2009-10-04 09:16:04, 2.6 KB) [[attachment:ipodder_main.py]]
  • [get | view] (2009-10-04 09:16:04, 4.4 KB) [[attachment:ipodder_main.py.html]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.