home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / main.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  41.0 KB  |  1,360 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from __future__ import with_statement
  5. import os.path as os
  6. import wx
  7. import sys
  8. import logging
  9. import platform
  10. import traceback
  11. from time import time
  12. from path import path
  13. from traceback import print_exc
  14. from config import platformName, newMenubar
  15. from logging import getLogger
  16. log = getLogger()
  17. info = log.info
  18. IDLE_CHECK_MS = 2000
  19. IDLE_CHECK_MOUSE_DISTANCE = 10
  20. LOG_FILENAME = 'digsby.log.csv'
  21. LOG_SPEED_LIMIT = 0.4 * 1024 * 1024
  22. LOG_SPEED_WINDOW = 10
  23. USE_HANGING_THREAD_DAEMON = True
  24. EXIT_TIMEOUT_SECS = 30
  25. TASKBAR_REFRESH_MS = 5 * 60 * 1000
  26. if not getattr(sys, 'REVISION', 'dev') != 'dev' and '--multi' not in sys.argv:
  27.     pass
  28. USE_SINGLE_INSTANCE = '--single' in sys.argv
  29. APP_NAME = u'Digsby'
  30.  
  31. def init_threadpool():
  32.     if getattr(wx, 'WXPY', False):
  33.         add_before_cb = add_before_cb
  34.         add_after_cb = add_after_cb
  35.         import util.threads.bgthread
  36.         add_before_cb(wx.SipNewThread)
  37.         add_after_cb(wx.SipEndThread)
  38.     
  39.     ThreadPool = ThreadPool
  40.     import util.threads.threadpool
  41.     ThreadPool(5)
  42.  
  43. if USE_SINGLE_INSTANCE:
  44.     from singleinstance import SingleInstanceApp
  45.     DigsbyAppBase = SingleInstanceApp
  46. else:
  47.     DigsbyAppBase = wx.App
  48. from gui.app.mainMenuEvents import MainMenuEventHandler
  49.  
  50. class DigsbyApp(DigsbyAppBase, MainMenuEventHandler):
  51.     
  52.     def OnFatalException(self):
  53.         
  54.         try:
  55.             where_string = where_string
  56.             import common.commandline
  57.             print >>sys.stderr, where_string(duplicates = True)
  58.             sys.stderr.flush()
  59.         except Exception:
  60.             e = None
  61.             print_exc()
  62.  
  63.  
  64.     
  65.     def __init__(self):
  66.         if USE_SINGLE_INSTANCE:
  67.             DigsbyAppBase.__init__(self, appname = APP_NAME, redirect = False)
  68.         else:
  69.             DigsbyAppBase.__init__(self, redirect = False)
  70.         if sys.DEV:
  71.             import gui.app as gui
  72.             gui.app.addThreadChecksToClassRecursive(wx)
  73.         
  74.         MainMenuEventHandler.__init__(self)
  75.         self.global_hotkeys = { }
  76.         self.next_hotkey_id = 0
  77.         self.PreShutdown = []
  78.  
  79.     
  80.     def Restart(self):
  81.         oldval = getattr(self, 'restarting', False)
  82.         self.restarting = True
  83.         if not self.DigsbyCleanupAndQuit():
  84.             self.restarting = oldval
  85.         
  86.  
  87.     
  88.     def AfterStartup(self):
  89.         if getattr(self, '_afterstartup', False):
  90.             return None
  91.         
  92.         self._afterstartup = True
  93.         log.info('AfterStartup')
  94.         import socks
  95.         import util
  96.         import wx
  97.         import util.callbacks as util
  98.         util.callbacks.register_call_later('MainThread', wx.CallAfter)
  99.         socks.setdefaultproxy(**util.GetProxyInfo())
  100.         import urllib
  101.         log.debug('system default proxy information: %r', urllib._getproxies())
  102.         if 'wxMSW' in wx.PlatformInfo:
  103.             self.setup_fullscreen()
  104.         
  105.         self.init_hotkeys()
  106.         init_threadpool()
  107.         self.init_plugins()
  108.         import wx
  109.         if 'wxMSW' in wx.PlatformInfo and sys.opts.cpuwatch:
  110.             CPUWatch = CPUWatch
  111.             import util.perfmon
  112.             self.cpu_watcher = CPUWatch()
  113.         
  114.         
  115.         try:
  116.             
  117.             try:
  118.                 import webview
  119.             except ImportError:
  120.                 import wx.webview as wx
  121.  
  122.         except Exception:
  123.             print >>sys.stderr, 'Warning: error preloading webkit'
  124.  
  125.         if 'wxMSW' in wx.PlatformInfo:
  126.             import util.checkoptions as util
  127.             util.checkoptions.start_checking()
  128.         
  129.  
  130.     
  131.     def OnInit(self):
  132.         self.SetExitOnFrameDelete(False)
  133.         log.info('SetExitOnFrameDelete(False)')
  134.         set_app_info(self)
  135.         self.Bind(wx.EVT_POWER_SUSPENDED, self.OnSuspend)
  136.         self.Bind(wx.EVT_POWER_RESUME, self.OnResume)
  137.         self.Bind(wx.EVT_MENU, self.DigsbyCleanupAndQuit, id = wx.ID_EXIT)
  138.         wx.IdleEvent.SetMode(wx.IDLE_PROCESS_SPECIFIED)
  139.         wx.UpdateUIEvent.SetMode(wx.UPDATE_UI_PROCESS_SPECIFIED)
  140.         wx.SystemOptions.SetOptionInt('mac.textcontrol-use-mlte', 1)
  141.         wx.SystemOptions.SetOptionInt('mac.textcontrol-use-spell-checker', 1)
  142.         if os.name == 'nt':
  143.             self.setup_crash_reporting()
  144.         
  145.         import stdpaths
  146.         stdpaths.init_wx()
  147.         sys.comtypes_dir = stdpaths.userlocaldata
  148.         if not getattr(sys, 'DEV', False):
  149.             
  150.             try:
  151.                 self._get_release_type()
  152.             except Exception:
  153.                 e = None
  154.                 log.error('Error getting release type %r', e)
  155.             except:
  156.                 None<EXCEPTION MATCH>Exception
  157.             
  158.  
  159.         None<EXCEPTION MATCH>Exception
  160.         return True
  161.  
  162.     
  163.     def GetCmdLine(self):
  164.         exe = sys.executable.decode(sys.getfilesystemencoding())
  165.         if getattr(sys, 'frozen', False) == 'windows_exe':
  166.             args = sys.argv[1:]
  167.         else:
  168.             args = sys.argv[:]
  169.         return ' '.join([
  170.             exe] + args)
  171.  
  172.     
  173.     def setup_crash_reporting(self, username = None):
  174.         if not sys.opts.crashreporting:
  175.             print >>sys.stderr, 'Crash reporting is disabled.'
  176.             return None
  177.         
  178.         crash_cmd = self.GetCmdLine()
  179.         crash_cmd += ' --crashreport %s'
  180.         if username is not None:
  181.             crash_cmd += ' --crashuser %s' % username
  182.         
  183.         self.SetCrashCommand(crash_cmd)
  184.         if sys.opts.full_crashdump:
  185.             flag = wx.CRASH_REPORT_LOCATION | wx.CRASH_REPORT_STACK | wx.CRASH_REPORT_LOCALS | wx.CRASH_REPORT_GLOBALS
  186.             self.crash_report_flags = flag
  187.         
  188.         crashdump_dir = sys.opts.crashdump_dir
  189.         if crashdump_dir:
  190.             isdir = isdir
  191.             abspath = abspath
  192.             pathjoin = join
  193.             normpath = normpath
  194.             import os.path
  195.             
  196.             try:
  197.                 crashdump_dir = abspath(crashdump_dir)
  198.                 if not isdir(sys.opts.crashdump_dir):
  199.                     os.makedirs(crashdump_dir)
  200.             except Exception:
  201.                 print_exc()
  202.  
  203.             if not username:
  204.                 pass
  205.             filename = 'Digsby_%s_%s.dmp' % ('', str(time()))
  206.             filename = normpath(pathjoin(crashdump_dir, filename))
  207.             wx.CrashReport.SetFileName(filename)
  208.             print >>sys.stderr, 'Dumpfile: %r' % wx.CrashReport.GetFileName()
  209.         
  210.         wx.HandleFatalExceptions()
  211.  
  212.     
  213.     def OnSuspend(self, e):
  214.         profile = profile
  215.         import common
  216.         p = profile()
  217.         if p is not None:
  218.             p.hibernate()
  219.         
  220.  
  221.     
  222.     def OnResume(self, e):
  223.         profile = profile
  224.         import common
  225.         p = profile()
  226.         if p is not None:
  227.             p.unhibernate(20)
  228.         
  229.  
  230.     
  231.     def setup_fullscreen(self):
  232.         FullscreenApp = FullscreenApp
  233.         import gui.native.helpers
  234.         imhub = imhub
  235.         import gui.imwin
  236.         RepeatTimer = RepeatTimer
  237.         Delegate = Delegate
  238.         import util
  239.         self.on_fullscreen = Delegate()
  240.         self._fs_app_running = None((RepeatTimer, 1), (lambda : (None, wx.CallAfter)((lambda : self.on_fullscreen(FullscreenApp())))
  241. ))
  242.         self._fs_app_running.start()
  243.         (self.on_fullscreen,) += (lambda val: None if not val else None)
  244.  
  245.     finish_init = False
  246.     
  247.     def ShowSplash(self, autologin_override = None, kicked = False):
  248.         log = getLogger('splash')
  249.         self.OnBuddyListShown = []
  250.         
  251.         def splash_success(info):
  252.             self.AfterStartup()
  253.             import digsbyprofile
  254.             
  255.             def signin_success(on_gui_load):
  256.                 log.info('wx.CallAfter(self.FinishInit, %r)', on_gui_load)
  257.                 wx.CallAfter(self.FinishInit, on_gui_load)
  258.  
  259.             
  260.             def signin_error(err = (None, (None, None), None)):
  261.                 if getattr(self, 'finish_init', False):
  262.                     log.info('signin error on reconnect')
  263.                     conn = digsbyprofile.profile
  264.                     oldcon = conn.connection
  265.                     protocol = protocol
  266.                     import common
  267.                     
  268.                     try:
  269.                         conn.connection.offline_reason = protocol.Reasons.CONN_FAIL
  270.                         log.info('conn.connection1 %r', conn.connection)
  271.                     except AttributeError:
  272.                         log.info('conn.connection2 %r', conn.connection)
  273.  
  274.                     log.info('conn.offline_changed(CONN_FAIL)')
  275.                     conn.offline_changed(None, 'offline_reason', None, protocol.Reasons.CONN_FAIL)
  276.                     
  277.                     try:
  278.                         conn.connection.change_state(protocol.Statuses.OFFLINE)
  279.                         log.info('conn.connection3 %r', conn.connection)
  280.                     except AttributeError:
  281.                         log.info('conn.connection4 %r', conn.connection)
  282.  
  283.                     conn.connection_state_changed(oldcon, 'state', protocol.Statuses.CONNECTING, protocol.Statuses.OFFLINE)
  284.                     conn.account_manager.on_offline_change(conn, None, None, None)
  285.                 else:
  286.                     self._login_controller.proto_error(err)
  287.  
  288.             return digsbyprofile.signin(info['username'].replace(' ', ''), info['password'], success = signin_success, error = signin_error)
  289.  
  290.         if 'wxMSW' in wx.PlatformInfo:
  291.             preload_comctrls()
  292.         
  293.         LoginController = LoginController
  294.         import digsbysplash
  295.         login_controller = LoginController(splash_success, autologin_override = autologin_override)
  296.         self._login_controller = login_controller
  297.         self.SetTopWindow(login_controller.window)
  298.         wx.CallAfter(login_controller.ShowWindow)
  299.         if kicked:
  300.             wx.CallAfter(wx.MessageBox, message = _('Your digsby password has been changed. Please log back in with the new password.'), caption = _('Password Changed'))
  301.         
  302.         self.finish_init = False
  303.         return True
  304.  
  305.     
  306.     def SetupTaskbarIcon(self):
  307.         BuddyListTaskBarIcon = BuddyListTaskBarIcon
  308.         import gui.buddylist.buddylistframe
  309.         skin = skin
  310.         import gui
  311.         icon = skin.get('AppDefaults.TaskbarIcon')
  312.         self.tbicon = None(BuddyListTaskBarIcon, icon = 'tooltip' if not getattr(sys, 'DEV', None) else 'Digsby DEV')
  313.         if 'wxMSW' in wx.PlatformInfo:
  314.             self.tbicon.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnShowHideBuddylist)
  315.             
  316.             refresh = lambda : self.tbicon.SetIcon(icon)
  317.             self.tray_refresh_timer = wx.PyTimer(refresh)
  318.             self.tray_refresh_timer.Start(TASKBAR_REFRESH_MS, False)
  319.         
  320.  
  321.     
  322.     def FinishInit(self, on_gui_load = None):
  323.         log.info('FinishInit enter')
  324.         import digsbyprofile
  325.         profile = digsbyprofile.profile
  326.         if self.finish_init:
  327.             log.info('finish init was already called, setting profile to ONLINE')
  328.             
  329.             try:
  330.                 return profile.connection.change_state(profile.connection.Statuses.ONLINE)
  331.             finally:
  332.                 log.info('returning  profile.connection.change_state(ONLINE)')
  333.  
  334.         
  335.         self.finish_init = True
  336.         login_controller = self._login_controller
  337.         del self._login_controller
  338.         if login_controller.cancelling:
  339.             log.info('splash screen is cancelled...returning profile.disconnect()')
  340.             return profile.disconnect()
  341.         
  342.         log.info('wx.CallAfter(login_controller.DestroyWindow)')
  343.         wx.CallAfter(login_controller.DestroyWindow)
  344.         autologin = not wx.GetKeyState(wx.WXK_SHIFT)
  345.         log.info('autologin for IM accounts: %r', autologin)
  346.         import gui.skin as gui
  347.         log.info('gui.textutil.default_font()')
  348.         gui.textutil.default_font()
  349.         
  350.         def preload_fonts():
  351.             log.info('preloading fonts')
  352.             n = len(list(gui.textutil.GetFonts()))
  353.             log.info('preloaded %d fonts', n)
  354.  
  355.         log.info('wx.CallAfter(preload_fonts)')
  356.         wx.CallAfter(preload_fonts)
  357.         if 'wxMSW' in wx.PlatformInfo:
  358.             set_comtypes_gendir = set_comtypes_gendir
  359.             import gui.native.win.winutil
  360.             log.info('wx.CallAfter(set_comtypes_gendir)')
  361.             wx.CallAfter(set_comtypes_gendir)
  362.         
  363.         import stdpaths
  364.         import util
  365.         log.info('setting resource paths')
  366.         gui.skin.set_resource_paths([
  367.             util.program_dir() / 'res',
  368.             stdpaths.userdata,
  369.             stdpaths.config])
  370.         changeskin = gui.skin.set_active
  371.         
  372.         def on_skin_load():
  373.             log.info('on_skin_load callback called, calling PostSkin')
  374.             self.PostSkin(autologin = autologin, success = on_gui_load)
  375.             log.info("changing profile's connection state to ONLINE")
  376.             profile.connection.change_state(profile.connection.Statuses.ONLINE)
  377.             profile._have_connected = True
  378.  
  379.         if os.name == 'nt':
  380.             log.info('setting up crash reporting')
  381.             self.setup_crash_reporting(username = profile.username)
  382.         
  383.         pref = pref
  384.         import common
  385.         
  386.         def foo():
  387.             log.info('calling gui.skin.set_active')
  388.             changeskin(pref('appearance.skin'), pref('appearance.variant'), callback = on_skin_load)
  389.  
  390.         log.info('wx.CallAfter(foo)')
  391.         wx.CallAfter(foo)
  392.  
  393.     
  394.     def PostSkin(self, autologin = False, success = None):
  395.         log.info('PostSkin enter, creating BuddyListFrame')
  396.         BuddyListFrame = BuddyListFrame
  397.         import gui.buddylist.buddylistframe
  398.         self.buddy_frame = BuddyListFrame(None, title = _('Buddy List'), name = 'Buddy List', style = wx.DEFAULT_FRAME_STYLE | wx.FRAME_NO_TASKBAR)
  399.         if newMenubar:
  400.             self.register_handlers()
  401.         
  402.         log.info('BuddyListFrame created')
  403.         
  404.         def muchlater():
  405.             log.info('muchlater enter')
  406.             self.idletimer = wx.PyTimer(self.not_idle)
  407.             self.idletimer.Start(IDLE_CHECK_MS)
  408.             
  409.             def show_buddylist_frame():
  410.                 pref = pref
  411.                 import common
  412.                 if pref('buddylist.show_on_startup', type = bool, default = True):
  413.                     self.buddy_frame.Show(True)
  414.                 
  415.                 self.SetTopWindow(self.buddy_frame)
  416.                 Delegate = Delegate
  417.                 import util
  418.                 log.info('calling and clearing OnBuddyListShown w/ %r', autologin)
  419.                 Delegate(self.OnBuddyListShown)(autologin = autologin)
  420.                 del self.OnBuddyListShown[:]
  421.                 
  422.                 def memevent():
  423.                     memory_event = memory_event
  424.                     import gui.native
  425.                     memory_event()
  426.  
  427.                 wx.CallLater(60000, memevent)
  428.                 if platformName == 'win':
  429.                     page_out_ram = page_out_ram
  430.                     import gui.native.win.process
  431.                     wx.CallLater(1000, page_out_ram)
  432.                 
  433.  
  434.             wx.CallAfter(show_buddylist_frame)
  435.  
  436.         wx.CallAfter(muchlater)
  437.         log.info('setting up task bar icon')
  438.         self.SetupTaskbarIcon()
  439.  
  440.     
  441.     def MacOpenFile(self, filename):
  442.         log.info('File dragged to dock icon: ' + filename)
  443.  
  444.     
  445.     def toggle_prefs(self):
  446.         import digsbyprofile
  447.         if not hasattr(digsbyprofile, 'profile') or digsbyprofile.profile is None:
  448.             return wx.MessageBox(_('Please login first.'), _('Advanced Preferences'))
  449.         
  450.         pref = pref
  451.         import common
  452.         if not __debug__ and sys.REVISION == 'dev' or pref('debug.advanced_prefs', False):
  453.             return None
  454.         
  455.         profile = digsbyprofile.profile
  456.         import prefs
  457.         if not self.buddy_frame:
  458.             pass
  459.         prefs.edit(profile.prefs, profile.defaultprefs, None)
  460.  
  461.     
  462.     def toggle_crust(self):
  463.         pref = pref
  464.         import common
  465.         if not getattr(sys, 'DEV', False):
  466.             pass
  467.         can_show_console = pref('debug.console', False)
  468.         if not can_show_console:
  469.             return None
  470.         
  471.         self.make_crust()
  472.         self.crust.toggle_shown()
  473.         if self.crust.IsShown():
  474.             self.crust.FocusInput()
  475.         
  476.  
  477.     
  478.     def make_crust(self):
  479.         if not hasattr(self, 'crust') or not (self.crust):
  480.             import gui.shell as gui
  481.             tlws = wx.GetTopLevelWindows()
  482.             self.crust = gui.shell.PyCrustFrame(None)
  483.             if tlws:
  484.                 parent = tlws[0]
  485.                 parent.crust = self.crust
  486.             
  487.         
  488.  
  489.     
  490.     def toggle_sorting(self):
  491.         profile = profile
  492.         import common
  493.         prefs = profile.prefs
  494.         if prefs:
  495.             if prefs.get('buddylist.allow_sorting_change', False):
  496.                 prefs['buddylist.sorting'] = not prefs.get('buddylist.sorting', True)
  497.             
  498.         
  499.  
  500.     
  501.     def not_idle(self, e = None):
  502.         pref = pref
  503.         profile = profile
  504.         import common
  505.         import digsbyprofile as d
  506.         if not profile.prefs:
  507.             return self.idletimer.Start()
  508.         
  509.         set_idle_after = pref('messaging.idle_after', 20 * d.IDLE_UNIT, type = int)
  510.         GetUserIdleTime = GetUserIdleTime
  511.         import gui.native.helpers
  512.         t = GetUserIdleTime()
  513.         min_idle = IDLE_CHECK_MS
  514.         Hook = Hook
  515.         import peak.util.plugins
  516.         for hook in Hook('digsby.app.idle'):
  517.             
  518.             try:
  519.                 next = int(hook(t))
  520.             except Exception:
  521.                 traceback.print_exc()
  522.                 continue
  523.  
  524.             if next < min_idle and next > 0:
  525.                 min_idle = next
  526.                 continue
  527.         
  528.         if t < set_idle_after * 1000:
  529.             profile.reset_timers()
  530.             profile.return_from_idle()
  531.         
  532.         self.idletimer.Start(min_idle)
  533.  
  534.     
  535.     def OnSaved(self):
  536.         log.info('profile.save SUCCESS, shutting down')
  537.         return self.do_shutdown()
  538.  
  539.     
  540.     def OnSaveError(self):
  541.         log.warning('error saving blobs')
  542.         return self.do_shutdown()
  543.  
  544.     
  545.     def DigsbyCleanupAndQuit(self, e = None):
  546.         traceguard = traceguard
  547.         Delegate = Delegate
  548.         import util
  549.         traceguard.__enter__()
  550.         
  551.         try:
  552.             for win in wx.GetTopLevelWindows():
  553.                 ImFrame = ImFrame
  554.                 import gui.imwin.imtabs
  555.                 if isinstance(win, ImFrame):
  556.                     if not win.Close():
  557.                         return False
  558.                     
  559.                 win.Close()
  560.         finally:
  561.             pass
  562.  
  563.         if getattr(self, 'shutting_down', False):
  564.             return False
  565.         
  566.         self.shutting_down = True
  567.         Hook = Hook
  568.         import peak.util.plugins
  569.         for hook in Hook('digsby.app.exit'):
  570.             hook()
  571.         
  572.         log.info('DigsbyCleanupAndQuit')
  573.         log.info('shutting down single instance server')
  574.         traceguard.__enter__()
  575.         
  576.         try:
  577.             if USE_SINGLE_INSTANCE:
  578.                 self.StopSingleInstanceServer()
  579.         finally:
  580.             pass
  581.  
  582.         if USE_HANGING_THREAD_DAEMON:
  583.             HangingThreadDaemon = HangingThreadDaemon
  584.             import util
  585.             log.info('starting shutdown timer daemon')
  586.             HangingThreadDaemon(wait = EXIT_TIMEOUT_SECS, sysexit = True).start()
  587.         
  588.         log.info('calling PreShutdown')
  589.         Delegate(self.PreShutdown)()
  590.         log.info('  saving and disconnecting profiles and accounts')
  591.         traceguard.__enter__()
  592.         
  593.         try:
  594.             log.info('destroying main tray icon...')
  595.             if getattr(self, 'tbicon', None) is not None:
  596.                 self.tbicon.Destroy()
  597.                 self.tbicon = None
  598.             
  599.             frame = getattr(self, 'buddy_frame', None)
  600.             if frame:
  601.                 if frame.IsShown():
  602.                     frame.on_close(exiting = True)
  603.                 
  604.                 log.info('destroying %r', frame)
  605.                 frame.on_destroy()
  606.             
  607.             traceguard.__enter__()
  608.             
  609.             try:
  610.                 popup = popup
  611.                 import gui
  612.                 popup.cancel_all()
  613.             finally:
  614.                 pass
  615.  
  616.             for tlw in wx.GetTopLevelWindows():
  617.                 tlw.Close(True)
  618.         finally:
  619.             pass
  620.  
  621.         profile = profile
  622.         import digsbyprofile
  623.         if profile and profile.connection:
  624.             profile.save(success = self.OnSaved, error = self.OnSaveError)
  625.         else:
  626.             self.OnSaved()
  627.         return True
  628.  
  629.     
  630.     def OnExit(self, event = None):
  631.         log.info('OnExit')
  632.         log.info('  replacing wx.CallAfter')
  633.         
  634.         wx.CallAfter = lambda f, *a, **k: f(*a, **k)
  635.  
  636.     
  637.     def do_shutdown(self):
  638.         traceguard = traceguard
  639.         import util
  640.         log.info('do_shutdown')
  641.         traceguard.__enter__()
  642.         
  643.         try:
  644.             timer = getattr(self, 'tray_refresh_timer', None)
  645.             if timer is not None:
  646.                 timer.Stop()
  647.             
  648.             log.info('  ok')
  649.         finally:
  650.             pass
  651.  
  652.         dbg = log.debug
  653.         
  654.         def _after_disconnect():
  655.             log.info('joining with TimeoutThread')
  656.             traceguard.__enter__()
  657.             
  658.             try:
  659.                 timeout_thread = timeout_thread
  660.                 import util.threads
  661.                 timeout_thread.join()
  662.             finally:
  663.                 pass
  664.  
  665.             log.info('joined with TimeoutThread')
  666.             log.info('joining with AsyncoreThread')
  667.             traceguard.__enter__()
  668.             
  669.             try:
  670.                 import AsyncoreThread
  671.                 AsyncoreThread.end_thread()
  672.                 AsyncoreThread.join()
  673.             finally:
  674.                 pass
  675.  
  676.             log.info('joining ThreadPool')
  677.             ThreadPool = ThreadPool
  678.             import util.threads.threadpool
  679.             ThreadPool().joinAll()
  680.             log.info('done joining ThreadPool')
  681.             dbg('exit main loop...')
  682.             self.ExitMainLoop()
  683.             dbg('clean exit.')
  684.  
  685.         dbg('disconnecting profile')
  686.         traceguard.__enter__()
  687.         
  688.         try:
  689.             profile = profile
  690.             import common
  691.             if profile and hasattr(profile, 'disconnect'):
  692.                 profile.disconnect(success = _after_disconnect)
  693.             else:
  694.                 _after_disconnect()
  695.         finally:
  696.             pass
  697.  
  698.  
  699.     
  700.     def init_hotkeys(self):
  701.         input = input_manager
  702.         import gui.input.inputmanager
  703.         skin = skin
  704.         import gui
  705.         input.AddGlobalContext(_('Global Shortcuts'), 'Global')
  706.         if getattr(sys, 'DEV', False):
  707.             input.AddGlobalContext(_('Debug Global Shortcuts'), 'Debug')
  708.         
  709.         input.AddClassContext(_('Text Controls'), 'TextControls', wx.TextCtrl)
  710.         resdir = skin.resourcedir()
  711.         KEYS_YAML = 'keys.yaml'
  712.         yaml_sources = (resdir / KEYS_YAML, resdir / platformName / KEYS_YAML)
  713.         for yaml in yaml_sources:
  714.             if yaml.exists():
  715.                 log.info('loading keyboard shortcuts from %s', yaml)
  716.                 input.LoadKeys(yaml)
  717.                 continue
  718.         
  719.         actions = [
  720.             ('TextControls.SelectAll', (lambda textctrl: textctrl.SetSelection(-1, -1))),
  721.             ('TextControls.DeletePreviousWord', 'gui.toolbox.DeleteWord'),
  722.             (('Global.DigsbyShell.ToggleShow',), (lambda win: self.toggle_crust())),
  723.             (('Global.AdvancedPrefs.ToggleShow',), (lambda win: self.toggle_prefs())),
  724.             (('Global.Skin.Reload',), (lambda win: skin.reload())),
  725.             (('BuddyList.Sorting.Toggle',), (lambda win: self.toggle_sorting())),
  726.             ('Debug.XMLConsole', 'common.commandline.xmlconsole'),
  727.             ('Debug.JavaScriptConsole', 'gui.browser.jsconsole.show_console')]
  728.         addcb = input.AddActionCallback
  729.         for name, action_cb in actions:
  730.             addcb(name, action_cb)
  731.         
  732.         input.BindWxEvents(self)
  733.  
  734.     
  735.     def AddGlobalHotkey(self, keys, callback):
  736.         id = self.next_hotkey_id
  737.         self.next_hotkey_id += 1
  738.         keycodes = keycodes
  739.         import gui.toolbox
  740.         (modifiers, key) = keycodes(keys)
  741.         self.buddy_frame.RegisterHotKey(id, modifiers, key)
  742.         self.buddy_frame.Bind(wx.EVT_HOTKEY, callback, id = id)
  743.         self.global_hotkeys[(modifiers, key, callback)] = id
  744.  
  745.     
  746.     def RemoveGlobalHotkey(self, keys, callback):
  747.         keycodes = keycodes
  748.         import gui.toolbox
  749.         (modifiers, key) = keycodes(keys)
  750.         id = self.global_hotkeys.pop((modifiers, key, callback))
  751.         self.buddy_frame.UnregisterHotKey(id)
  752.  
  753.     
  754.     def init_plugins(self):
  755.         import stdpaths
  756.         import plugin_manager
  757.         import common
  758.         paths = [
  759.             stdpaths.userdata / 'plugins',
  760.             stdpaths.config / 'plugins']
  761.         
  762.         try:
  763.             PLUGINS_PATH = path(__file__.decode('filesys')).parent / u'plugins'
  764.         except Exception:
  765.             e = None
  766.             traceback.print_exc()
  767.             PLUGINS_PATH = None
  768.  
  769.         paths.append(PLUGINS_PATH)
  770.         sys.path.extend(map(str, paths))
  771.         for pth in paths:
  772.             
  773.             try:
  774.                 if pth is not None:
  775.                     plugin_manager.scan(pth)
  776.             continue
  777.             except Exception:
  778.                 traceback.print_exc()
  779.                 continue
  780.             
  781.  
  782.         
  783.         
  784.         try:
  785.             common.protocolmeta.proto_update_types()
  786.         except Exception:
  787.             None<EXCEPTION MATCH>Exception
  788.             None<EXCEPTION MATCH>Exception
  789.             traceback.print_exc()
  790.         except:
  791.             None<EXCEPTION MATCH>Exception
  792.  
  793.  
  794.     
  795.     def should_check_for_updates(self):
  796.         retval = True
  797.         reason = None
  798.         if not sys.opts.allow_update:
  799.             retval = False
  800.             reason = 'sys.opts.allow_updates == False'
  801.         
  802.         if platform.platform().find('Windows-2000') != -1:
  803.             retval = False
  804.             reason = 'Windows 2000'
  805.         
  806.         if not retval:
  807.             log.info('Not checking for updates because: %r', reason)
  808.         
  809.         return retval
  810.  
  811.     
  812.     def _manifest_path_from_yaml(self, yaml_loc):
  813.         import syck
  814.         import urllib2
  815.         urlopen_ts = urlopen_ts
  816.         import AutoUpdate
  817.         
  818.         try:
  819.             response = urlopen_ts(yaml_loc)
  820.         except urllib2.URLError:
  821.             e = None
  822.             log.error('Couldnt get yaml (%r): %r', yaml_loc, e)
  823.             return sentinel
  824.         except Exception:
  825.             e = None
  826.             log.error('update failed: Error opening %r for reading. (%r)', yaml_loc, e)
  827.  
  828.         
  829.         try:
  830.             data = response.read()
  831.         except Exception:
  832.             return sentinel
  833.  
  834.         
  835.         try:
  836.             ui = syck.load(data)
  837.         except Exception:
  838.             print_exc()
  839.             ui = None
  840.  
  841.         if ui is None:
  842.             return sentinel
  843.         
  844.         all = ui.get('all', { })
  845.         if not ui.get(platformName, None):
  846.             pass
  847.         mine = { }
  848.         release_type = self._get_release_type()
  849.         merged = all.copy()
  850.         merged.update(mine)
  851.         manifest_path = merged.get(release_type, merged.get('release', None))
  852.         if manifest_path is None:
  853.             return sentinel
  854.         else:
  855.             return manifest_path
  856.  
  857.     
  858.     def _get_release_type(self):
  859.         import stdpaths
  860.         import util
  861.         import syck
  862.         _DigsbyApp__tag = getattr(sys, 'TAG')
  863.         if _DigsbyApp__tag:
  864.             return _DigsbyApp__tag
  865.         
  866.         tag = 'release'
  867.         tag_fname = 'tag.yaml'
  868.         for fpath in (stdpaths.userlocaldata / tag_fname, util.program_dir() / tag_fname):
  869.             
  870.             try:
  871.                 
  872.                 try:
  873.                     f = _[2]
  874.                     yaml = syck.load(f)
  875.                     tag = yaml['tag']
  876.                 finally:
  877.                     pass
  878.  
  879.             continue
  880.             except Exception:
  881.                 e = None
  882.                 log.debug("Didn't get a release tag from %r: %r", fpath, e)
  883.                 continue
  884.             
  885.  
  886.         
  887.         log.info('Got release tag: %r', tag)
  888.         sys.TAG = tag
  889.         return tag
  890.  
  891.     
  892.     def check_for_updates(self, manifest_path_path, success = None, error = None):
  893.         import sys
  894.         import hashlib
  895.         import util.httplib2 as httplib2
  896.         import urlparse
  897.         import path
  898.         http_date_to_timestamp = http_date_to_timestamp
  899.         urlopen_ts = urlopen_ts
  900.         import AutoUpdate
  901.         
  902.         def try_and_whine(callable):
  903.             
  904.             try:
  905.                 result = callable()
  906.             except Exception:
  907.                 print >>sys.stderr, 'error calling %s' % util.funcinfo(callable)
  908.                 print >>sys.stderr, 'giving up on update check'
  909.                 print_exc()
  910.                 return sentinel
  911.  
  912.             return result
  913.  
  914.         release_type = self._get_release_type()
  915.         
  916.         try:
  917.             if manifest_path_path.endswith('.yaml'):
  918.                 manifest_location = self._manifest_path_from_yaml(manifest_path_path)
  919.             else:
  920.                 manifest_location = (None, try_and_whine)((lambda : urlopen_ts(manifest_path_path).read()))
  921.         except Exception:
  922.             (None, None)
  923.             (None, None)
  924.             print_exc()
  925.             manifest_location = sentinel
  926.         except:
  927.             (None, None)
  928.  
  929.         print >>sys.stderr, 'manifest location:', manifest_location
  930.         if manifest_location is sentinel:
  931.             return None if error is not None else None
  932.         
  933.         manifest_url = manifest_location
  934.         conn = httplib2.Http()
  935.         
  936.         try:
  937.             (headers, content) = conn.request(manifest_url, 'HEAD')
  938.         except Exception:
  939.             print_exc()
  940.             headers = { }
  941.  
  942.         rmtime = headers.get('x-amz-meta-mtime', None)
  943.         if rmtime is None:
  944.             rmtime = headers.get('last-modified', None)
  945.             if rmtime is not None:
  946.                 rmtime = http_date_to_timestamp(rmtime)
  947.             
  948.         
  949.         if rmtime is not None:
  950.             
  951.             try:
  952.                 rmtime = int(rmtime)
  953.             except (TypeError, ValueError):
  954.                 rmtime = None
  955.             except:
  956.                 None<EXCEPTION MATCH>(TypeError, ValueError)
  957.             
  958.  
  959.         None<EXCEPTION MATCH>(TypeError, ValueError)
  960.         import util
  961.         prog_dir = util.program_dir()
  962.         mymanifest_path = path.path(prog_dir) / path.path(manifest_location).splitpath()[-1]
  963.         print >>sys.stderr, mymanifest_path
  964.         needs_update = True
  965.         if mymanifest_path.exists():
  966.             lmtime = int(mymanifest_path.mtime)
  967.         else:
  968.             lmtime = 0
  969.         if lmtime == rmtime:
  970.             print >>sys.stderr, 'Local MTime matches remote. Not downloading manifest. (local=%r, remote=%r)' % (lmtime, rmtime)
  971.             needs_update = False
  972.         else:
  973.             print >>sys.stderr, 'MTime mismatch. Downloading manifest. (local=%r, remote=%r)' % (lmtime, rmtime)
  974.             if mymanifest_path.exists():
  975.                 mymanifest_digest = mymanifest_path.read_md5()
  976.             else:
  977.                 mymanifest_digest = None
  978.             manifest_resp = (None, try_and_whine)((lambda : urlopen_ts(manifest_location)))
  979.             if manifest_resp is sentinel:
  980.                 return None if error is not None else None
  981.             
  982.             if 'gzip' in manifest_resp.headers.get('Content-Encoding', ''):
  983.                 import gzip
  984.                 import StringIO
  985.                 manifest_resp = (None, None, try_and_whine)((lambda : gzip.GzipFile(fileobj = StringIO.StringIO(manifest_resp.read()))))
  986.                 if manifest_resp is sentinel:
  987.                     return None if error is not None else None
  988.                 
  989.             
  990.             webman_hash = hashlib.md5()
  991.             
  992.             try:
  993.                 bytes = manifest_resp.read(8192)
  994.                 while bytes:
  995.                     webman_hash.update(bytes)
  996.                     bytes = manifest_resp.read(8192)
  997.             except Exception:
  998.                 print_exc()
  999.                 return None if error is not None else None
  1000.             finally:
  1001.                 manifest_resp.close()
  1002.  
  1003.             webdigest = webman_hash.digest()
  1004.             print >>sys.stderr, repr(mymanifest_digest), repr(webdigest), mymanifest_digest == webdigest
  1005.             if mymanifest_digest == webdigest:
  1006.                 needs_update = False
  1007.             
  1008.         if sys.opts.force_update:
  1009.             needs_update = True
  1010.         
  1011.         if success is not None:
  1012.             success(needs_update, manifest_location)
  1013.         
  1014.  
  1015.     
  1016.     def OnRaiseBuddyList(self, e = None):
  1017.         frame = self.buddy_list
  1018.         docker = frame.docker
  1019.         if docker.AutoHide and docker.docked:
  1020.             if docker.autohidden:
  1021.                 docker.ComeBack()
  1022.             
  1023.             frame.Raise()
  1024.         elif not frame.IsActive():
  1025.             frame.Raise()
  1026.         
  1027.  
  1028.     
  1029.     def OnShowHideBuddylist(self, e = None):
  1030.         frame = self.buddy_frame
  1031.         docker = getattr(frame, 'docker', None)
  1032.         if docker is not None and frame.IsShown():
  1033.             if getattr(docker, 'Enabled', False) and docker.docked:
  1034.                 if docker.autohidden:
  1035.                     docker.ComeBack()
  1036.                 
  1037.                 frame.Raise()
  1038.                 return None
  1039.             
  1040.         
  1041.         shown = frame.Visible
  1042.         frame.Show(not shown)
  1043.         if not shown:
  1044.             if frame.IsIconized():
  1045.                 frame.Iconize(False)
  1046.             
  1047.             frame.EnsureInScreen()
  1048.             frame.Raise()
  1049.         
  1050.  
  1051.  
  1052.  
  1053. class StdErrFilter(object):
  1054.     
  1055.     def filter(self, record):
  1056.         return record.name != 'stderr'
  1057.  
  1058.  
  1059.  
  1060. class MyStdErr(object):
  1061.     has_stderr = True
  1062.     
  1063.     def write(self, s):
  1064.         
  1065.         try:
  1066.             self.stderrlog.error(s.rstrip())
  1067.         except:
  1068.             pass
  1069.  
  1070.         if MyStdErr.has_stderr:
  1071.             
  1072.             try:
  1073.                 sys.__stderr__.write(s)
  1074.             MyStdErr.has_stderr = False
  1075.  
  1076.         
  1077.  
  1078.     
  1079.     def flush(self):
  1080.         if MyStdErr.has_stderr:
  1081.             
  1082.             try:
  1083.                 sys.__stderr__.flush()
  1084.             MyStdErr.has_stderr = False
  1085.  
  1086.         
  1087.  
  1088.  
  1089.  
  1090. def get_logdir():
  1091.     return os.path.join(wx.StandardPaths.Get().GetUserLocalDataDir(), 'Logs')
  1092.  
  1093.  
  1094. def get_last_log_file_name():
  1095.     return os.path.join(get_logdir(), LOG_FILENAME)
  1096.  
  1097.  
  1098. def get_std_redirect_file():
  1099.     path = path
  1100.     import path
  1101.     return str((path(get_logdir()) / 'systemlog.txt').abspath())
  1102.  
  1103.  
  1104. def setup_log_system():
  1105.     global full_loggers
  1106.     wx.Log.SetActiveTarget(wx.LogStderr())
  1107.     if sys.opts.no_log:
  1108.         return None
  1109.     
  1110.     path = path
  1111.     import path
  1112.     import traceback
  1113.     DisablingStream = DisablingStream
  1114.     DelayedStreamLimiter = DelayedStreamLimiter
  1115.     LimitedFileSize = LimitedFileSize
  1116.     import fileutil
  1117.     sys.stdout = DisablingStream(sys.__stdout__)
  1118.     sys.stderr = MyStdErr()
  1119.     stderrlog = logging.getLogger('stderr')
  1120.     sys.stderr.stderrlog = stderrlog
  1121.     root = logging.Logger.root
  1122.     root.stream = sys.stderr
  1123.     root.setLevel(1)
  1124.     gzipFileHandler = gzipFileHandler
  1125.     CloseFileHandler = CloseFileHandler
  1126.     CSVFormatter = CSVFormatter
  1127.     CSV_HEADERS = CSV_HEADERS
  1128.     import csvlogging
  1129.     logdir = path(get_logdir())
  1130.     if not logdir.exists():
  1131.         logdir.makedirs()
  1132.     
  1133.     logfilebase = logfile = logdir / LOG_FILENAME
  1134.     N = 2
  1135.     while True:
  1136.         
  1137.         try:
  1138.             f = open(logfile, 'wb')
  1139.         continue
  1140.         print_exc()
  1141.         logfile = logfilebase + ' (%d)' % N
  1142.         N += 1
  1143.         if N > 100:
  1144.             raise AssertionError
  1145.         
  1146.  
  1147.         f = open(logfile, 'wb')
  1148.         continue
  1149.     sys.LOGFILE_NAME = logfile
  1150.     f.write(CSV_HEADERS)
  1151.     f.close()
  1152.     hdlr = CloseFileHandler(DelayedStreamLimiter(LimitedFileSize(sys.LOGFILE_NAME, 20971520, 10485760, initmode = 'ab'), limit = LOG_SPEED_LIMIT, window = LOG_SPEED_WINDOW))
  1153.     hdlr.setFormatter(CSVFormatter())
  1154.     full_loggers = [
  1155.         hdlr]
  1156.     root.addHandler(hdlr)
  1157.     if hasattr(wx, 'SetLogFile'):
  1158.         log_redirect = get_std_redirect_file()
  1159.         if not wx.SetLogFile(log_redirect):
  1160.             print sys.stderr, 'Could not redirect log file to %s' % log_redirect
  1161.         else:
  1162.             import datetime
  1163.             wx.LogMessage(datetime.datetime.now().isoformat())
  1164.     
  1165.     init_stdout()
  1166.     if not __debug__:
  1167.         logging.info('logger started - rev %s', sys.REVISION)
  1168.     
  1169.     print >>sys.stderr, 'testing stderr'
  1170.     print >>sys.stdout, 'testing stdout'
  1171.  
  1172.  
  1173. class ConsoleFormatter(logging.Formatter):
  1174.     
  1175.     def format(self, record):
  1176.         if record.exc_info and not (record.exc_text):
  1177.             record.exc_text = self.formatException(record.exc_info)
  1178.         
  1179.         exc = None if record.exc_text else ''
  1180.         return ''.join([
  1181.             '%-20s' % record.name,
  1182.             record.threadName[:4],
  1183.             '-',
  1184.             '%-4s | ' % record.levelname[:4],
  1185.             '%s' % record.getMessage(),
  1186.             exc])
  1187.  
  1188.  
  1189.  
  1190. def init_stdout():
  1191.     DelayedStreamLimiter = DelayedStreamLimiter
  1192.     import fileutil
  1193.     console = None
  1194.     root = logging.Logger.root
  1195.     
  1196.     try:
  1197.         sys.stdout.write('Testing if sys.stdout is safe...\n')
  1198.     except:
  1199.         root.info('stdout disabled')
  1200.  
  1201.     root.info('stdout enabled')
  1202.     console = logging.StreamHandler(DelayedStreamLimiter(sys.stdout, limit = LOG_SPEED_LIMIT, window = LOG_SPEED_WINDOW))
  1203.     console.setLevel(1)
  1204.     console.setFormatter(ConsoleFormatter())
  1205.     if console is not None:
  1206.         logging.getLogger('').addHandler(console)
  1207.     
  1208.     if console is not None:
  1209.         console.addFilter(StdErrFilter())
  1210.     
  1211.  
  1212. startup_begin = 0
  1213.  
  1214. def check_dependencies():
  1215.     
  1216.     try:
  1217.         import tlslite
  1218.     except ImportError:
  1219.         pass
  1220.  
  1221.     print >>sys.stderr, 'WARNING! tlslite is on PYTHONPATH, and will cause SSL problems. Please remove it: %r' % tlslite.__file__
  1222.  
  1223.  
  1224. def set_update_tag():
  1225.     tag = sys.opts.updatetag
  1226.     import syck
  1227.     if tag is not None:
  1228.         import stdpaths
  1229.         
  1230.         try:
  1231.             
  1232.             try:
  1233.                 f = _[2]
  1234.                 syck.dump({
  1235.                     'tag': tag }, f)
  1236.             finally:
  1237.                 pass
  1238.  
  1239.         except Exception:
  1240.             pass
  1241.         except:
  1242.             None<EXCEPTION MATCH>Exception
  1243.         
  1244.  
  1245.     None<EXCEPTION MATCH>Exception
  1246.  
  1247.  
  1248. def main():
  1249.     global startup_begin
  1250.     startup_begin = time()
  1251.     if platformName == 'win' and sys.opts.crashreport:
  1252.         if 'wxMSW' in wx.PlatformInfo:
  1253.             preload_comctrls()
  1254.         
  1255.         return send_crash_report()
  1256.     
  1257.     if sys.opts.profile:
  1258.         set_profilers_enabled = set_profilers_enabled
  1259.         import util
  1260.         set_profilers_enabled(True)
  1261.     
  1262.     digsby_app = DigsbyApp()
  1263.     wx.ConfigBase.Set(wx.FileConfig())
  1264.     setup_log_system()
  1265.     log_system_info()
  1266.     digsby_app.ShowSplash()
  1267.     set_update_tag()
  1268.     if sys.opts.profile:
  1269.         currentThread = currentThread
  1270.         import threading
  1271.         use_profiler = use_profiler
  1272.         all_profilers = all_profilers
  1273.         import util
  1274.         if sys.opts.profile > 1:
  1275.             RepeatTimer = RepeatTimer
  1276.             import util
  1277.             
  1278.             def get_reports():
  1279.                 print '\n\n'.join((lambda .0: for p in .0:
  1280. p.report())(all_profilers().itervalues()))
  1281.  
  1282.             digsby_app._profile_timer = RepeatTimer(30, get_reports)
  1283.             digsby_app._profile_timer.start()
  1284.         
  1285.         return use_profiler(currentThread(), digsby_app.MainLoop)
  1286.     else:
  1287.         return digsby_app.MainLoop()
  1288.  
  1289.  
  1290. def send_crash_report():
  1291.     a = wx.PySimpleApp()
  1292.     format_exc = format_exc
  1293.     import traceback
  1294.     set_app_info(a)
  1295.     CrashDialog = CrashDialog
  1296.     import crashgui
  1297.     msg = _('There was an error submitting your crash report.')
  1298.     
  1299.     try:
  1300.         diag = CrashDialog()
  1301.         diag.CenterOnScreen()
  1302.         diag.RequestUserAttention()
  1303.         if wx.ID_OK == diag.ShowModal():
  1304.             import util.diagnostic as d
  1305.             last_log = get_last_log_file_name()
  1306.             diagobj = d.load_crash(sys.opts.crashreport, last_log, username = sys.opts.crashuser, description = diag.Description)
  1307.             if diagobj.succeeded:
  1308.                 msg = _('Crash report submitted successfully.')
  1309.             
  1310.         else:
  1311.             return None
  1312.     except Exception:
  1313.         print_exc()
  1314.  
  1315.     if False:
  1316.         msg += '\n\n' + _('Would you like to restart Digsby now?')
  1317.         if wx.YES == wx.MessageBox(msg, _('Crash Report'), style = wx.YES_NO | wx.YES_DEFAULT):
  1318.             cmd = sys.executable.decode(sys.getfilesystemencoding())
  1319.             if not getattr(sys, 'frozen', False) == 'windows_exe':
  1320.                 cmd += ' ' + sys.argv[0]
  1321.             
  1322.             wx.Execute(cmd)
  1323.         
  1324.     
  1325.  
  1326.  
  1327. def log_system_info():
  1328.     import locale
  1329.     clock = clock
  1330.     import time
  1331.     startup_time = clock() * 1000
  1332.     log.info('Digsby rev %s', sys.REVISION)
  1333.     log.info('started up in %s ms', startup_time)
  1334.     log.info(' '.join(wx.PlatformInfo) + ' wx v' + '.'.join((lambda .0: for c in .0:
  1335. str(c))(wx.VERSION)))
  1336.     log.info('Platform: %r', ' '.join(platform.uname()).strip())
  1337.     log.info('Python ' + sys.version)
  1338.     log.info('locale: ' + str(locale.getdefaultlocale()))
  1339.     log.info('user local data dir: %r', wx.StandardPaths.Get().GetUserLocalDataDir())
  1340.     log.info('__debug__ is %r', __debug__)
  1341.  
  1342.  
  1343. def set_app_info(app):
  1344.     app.SetAppName(APP_NAME)
  1345.     app.SetVendorName(u'dotSyntax')
  1346.     app.SetAppName(APP_NAME)
  1347.     app.SetClassName(APP_NAME)
  1348.  
  1349. if 'wxMSW' in wx.PlatformInfo:
  1350.     
  1351.     def preload_comctrls():
  1352.         windll = windll
  1353.         import ctypes
  1354.         windll.comctl32.InitCommonControls()
  1355.  
  1356.  
  1357. if __name__ == '__main__':
  1358.     raise AssertionError('run Digsby.py')
  1359.  
  1360.