Go to most recent revision | Compare with Previous | Blame | View Log
__version__ = "$Revision: 6799 $"__date__ = "$Date: 2005-08-25 08:22:14 -0700 (Thu, 25 Aug 2005) $"__copyright__ = "Copyright (c) 2003-2005 Open Source Applications Foundation"__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"import sys, osimport application.Globalsimport application.Utility as Utilityfrom repository.persistence.RepositoryError \import RepositoryOpenDeniedError, ExclusiveOpenDeniedErrordef main():message = "while trying to start.""""Process any command line switches and any environment variable values"""application.Globals.options = Utility.initOptions()application.Globals.chandlerDirectory = Utility.locateChandlerDirectory()os.chdir(application.Globals.chandlerDirectory)Utility.initLogging(application.Globals.options)def realMain():if __debug__ and application.Globals.options.wing:"""Check for -wing command line argument; if specified, try to connect toan already-running WingIDE instance. See:http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#wingIDE.for details."""import wingdbstubif __debug__ and application.Globals.options.komodo:"""Check for -komodo command line argument; if specified, try to connect toan already-running Komodo instance. See:http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#Komodo.for details."""import dbgp.clientdbgp.client.brk()from application.Application import wxApplication"""redirect stdio and stderr to a dialog if we're running the debug version.This is done to catch asserts, which otherwise will never get seen bypeople who run Chandler using the launchers, e.g. Aparna. If you'rerunning release you can also set things up so that you can seestderr and stdout if you run in a shell or from wing with a console.useBestVisual, uses best screen resolutions on some old computers. SeewxApp.SetUseBestVisual"""app = wxApplication(redirect=__debug__, useBestVisual=True)app.MainLoop()if application.Globals.options.nocatch:# When debugging, it's handy to run without the outer exception frameimport logging, traceback, wxrealMain()else:# The normal way: wrap the app in an exception frametry:import logging, traceback, wxrealMain()except (RepositoryOpenDeniedError, ExclusiveOpenDeniedError):message = "Another instance of Chandler currently has the " \"repository open."logging.exception(message)dialog = wx.MessageDialog(None, message, "Chandler", wx.OK | wx.ICON_INFORMATION)dialog.ShowModal()dialog.Destroy()except Utility.SchemaMismatchError:logging.info("User chose not to clear the repository. Exiting.")except Exception:type, value, stack = sys.exc_info()formattedBacktrace = "".join (traceback.format_exception (type, value, stack, 5))message = ("Chandler encountered an unexpected problem %s\n" + \"Here are the bottom 5 frames of the stack:\n%s") % (message, formattedBacktrace)logging.exception(message)# @@@ 25Issue - Cannot create wxItems if the app failed to initializedialog = wx.MessageDialog(None, message, "Chandler", wx.OK | wx.ICON_INFORMATION)dialog.ShowModal()dialog.Destroy()#Reraising the exception, so wing catches it.raise#@@@Temporary testing tool written by Morgen -- DJA#import util.timing#print "\nTiming results:\n"#util.timing.results()if __name__== "__main__":main()