Esempio n. 1
0
    def setUp(self):
        # This setup is needed because we'd like to be able to use
        # --locale on the command line to test a given locale. So,
        # basically the code below is copy-and-pasted out of Utility.py
        # to make sure that everything gets initialized in the right
        # order.
        needInit = self.view is None

        # We always store a list of all failures, so that we can report them
        # all rather than fail on the first.
        self.failures = []

        if needInit:
            Utility.initLogging(Globals.options)
            type(self).view = NullRepositoryView()

            parcelPath = Utility.initParcelEnv(Globals.options, Globals.chandlerDirectory)
            pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options, Globals.options.pluginPath)

            Utility.initI18n(Globals.options)

            Utility.initParcels(Globals.options, self.view, parcelPath)
            Utility.initPlugins(Globals.options, self.view, pluginEnv, pluginEggs)
        # We don't want to import these globally, because they will
        # trigger parcel loading, and that will cause i18n to be set
        # up before the above call to initI18n, which will mean --locale
        # won't work on the command line. So, instead, we stash these
        # in instance variables.
        self.Menu = schema.importString("osaf.framework.blocks.Menu")
        self.MenuItem = schema.importString("osaf.framework.blocks.MenuItem")
Esempio n. 2
0
def startup(**kwds):
    global view

    Globals.chandlerDirectory = Utility.locateChandlerDirectory()
    if not Globals.chandlerDirectory:
        print "Please set CHANDLERHOME"
        return None
    os.chdir(Globals.chandlerDirectory)

    Utility.initLocale('en')

    Globals.options = Utility.initOptions(Globals.chandlerDirectory, **kwds)
    profileDir = Globals.options.profileDir

    Utility.initLogging(Globals.options)

    parcelPath = Utility.initParcelEnv(Globals.chandlerDirectory,
                                       Globals.options.parcelPath)

    view = Utility.initRepository(
        Utility.locateRepositoryDirectory(profileDir), Globals.options)

    if not Utility.verifySchema(view):
        print "Schema mismatch.  Try again with startup(create=True)"
        return None

    Utility.initCrypto(Globals.options.profileDir)
    Utility.initParcels(view, parcelPath)

    if Globals.options.createData:
        import GenerateItemsFromFile
        GenerateItemsFromFile.RunScript(view)

    return view
Esempio n. 3
0
def startup(**kwds):
    global view

    Globals.chandlerDirectory = Utility.locateChandlerDirectory()
    if not Globals.chandlerDirectory:
        print "Please set CHANDLERHOME"
        return None
    os.chdir(Globals.chandlerDirectory)

    Utility.initLocale('en')

    Globals.options = Utility.initOptions(Globals.chandlerDirectory, **kwds)
    profileDir = Globals.options.profileDir

    Utility.initLogging(Globals.options)

    parcelPath = Utility.initParcelEnv(Globals.chandlerDirectory,
                                       Globals.options.parcelPath)

    view = Utility.initRepository(Utility.locateRepositoryDirectory(profileDir),
                                  Globals.options)

    if not Utility.verifySchema(view):
        print "Schema mismatch.  Try again with startup(create=True)"
        return None

    Utility.initCrypto(Globals.options.profileDir)
    Utility.initParcels(view, parcelPath)

    if Globals.options.createData:
        import GenerateItemsFromFile
        GenerateItemsFromFile.RunScript(view)

    return view
Esempio n. 4
0
    def setUp(self):
        # This setup is needed because we'd like to be able to use
        # --locale on the command line to test a given locale. So,
        # basically the code below is copy-and-pasted out of Utility.py
        # to make sure that everything gets initialized in the right
        # order.
        needInit = (self.view is None)

        # We always store a list of all failures, so that we can report them
        # all rather than fail on the first.
        self.failures = []

        if needInit:
            Utility.initLogging(Globals.options)
            type(self).view = NullRepositoryView()

            parcelPath = Utility.initParcelEnv(Globals.options,
                                               Globals.chandlerDirectory)
            pluginEnv, pluginEggs = Utility.initPluginEnv(
                Globals.options, Globals.options.pluginPath)

            Utility.initI18n(Globals.options)

            Utility.initParcels(Globals.options, self.view, parcelPath)
            Utility.initPlugins(Globals.options, self.view, pluginEnv,
                                pluginEggs)
        # We don't want to import these globally, because they will
        # trigger parcel loading, and that will cause i18n to be set
        # up before the above call to initI18n, which will mean --locale
        # won't work on the command line. So, instead, we stash these
        # in instance variables.
        self.Menu = schema.importString('osaf.framework.blocks.Menu')
        self.MenuItem = schema.importString('osaf.framework.blocks.MenuItem')
Esempio n. 5
0
 def setUp(self):
     Globals.options = Utility.initOptions()
     Globals.options.ramdb = True
     Utility.initLogging(Globals.options)
     self.views = []
     for i in xrange(2):
         view = Utility.initRepository("", Globals.options, True)
         view.name = "test_view_%d" % i
         self.views.append(view)
         Utility.initTimezone(Globals.options, view)
 def setUp(self):
     Globals.options = Utility.initOptions()
     Globals.options.ramdb = True
     Utility.initLogging(Globals.options)
     self.views = []
     for i in xrange(2):
         view = Utility.initRepository("", Globals.options, True)
         view.name = "test_view_%d" % i
         self.views.append(view)
         Utility.initTimezone(Globals.options, view)
Esempio n. 7
0
def startup(chandlerDirectory=None, **kwds):
    global view, commitOnExit

    Globals.options = Utility.initOptions(**kwds)
    if chandlerDirectory is None:
        Globals.chandlerDirectory = Utility.locateChandlerDirectory()
    else:
        Globals.chandlerDirectory = chandlerDirectory

    os.chdir(Globals.chandlerDirectory)
    Utility.initI18n(Globals.options)

    profileDir = Globals.options.profileDir

    Utility.initLogging(Globals.options)

    parcelPath = Utility.initParcelEnv(Globals.options,
                                       Globals.chandlerDirectory)
    pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options,
                                                  Globals.options.pluginPath)

    Globals.options.getPassword = getPassword
    repoDir = Utility.locateRepositoryDirectory(profileDir, Globals.options)
    view = Utility.initRepository(repoDir, Globals.options)

    verify, repoVersion, schemaVersion = Utility.verifySchema(view)
    if not verify:
        print "Schema mismatch (%s vs %s).  Try again with startup(create=True)" % (
            repoVersion, schemaVersion)
        return None

    Utility.initCrypto(Globals.options.profileDir)
    Utility.initParcels(Globals.options, view, parcelPath)
    Utility.initPlugins(Globals.options, view, pluginEnv, pluginEggs)
    Utility.initTimezone(Globals.options, view)

    if Globals.options.reload:
        from osaf import dumpreload
        dumpreload.reload(view, Globals.options.reload)

    return view
Esempio n. 8
0
def startup(chandlerDirectory=None, **kwds):
    global view, commitOnExit

    Globals.options = Utility.initOptions(**kwds)
    if chandlerDirectory is None:
        Globals.chandlerDirectory = Utility.locateChandlerDirectory()
    else:
        Globals.chandlerDirectory = chandlerDirectory

    os.chdir(Globals.chandlerDirectory)
    Utility.initI18n(Globals.options)

    profileDir = Globals.options.profileDir

    Utility.initLogging(Globals.options)

    parcelPath = Utility.initParcelEnv(Globals.options, 
                                       Globals.chandlerDirectory)
    pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options,
                                                  Globals.options.pluginPath)

    Globals.options.getPassword = getPassword
    repoDir = Utility.locateRepositoryDirectory(profileDir, Globals.options)
    view = Utility.initRepository(repoDir, Globals.options)

    verify, repoVersion, schemaVersion = Utility.verifySchema(view)
    if not verify:
        print "Schema mismatch (%s vs %s).  Try again with startup(create=True)" %(repoVersion, schemaVersion)
        return None

    Utility.initCrypto(Globals.options.profileDir)
    Utility.initParcels(Globals.options, view, parcelPath)
    Utility.initPlugins(Globals.options, view, pluginEnv, pluginEggs)
    Utility.initTimezone(Globals.options, view)

    if Globals.options.reload:
        from osaf import dumpreload
        dumpreload.reload(view, Globals.options.reload)

    return view
Esempio n. 9
0
 def setUp(self):
     Globals.options = Utility.initOptions()
     Utility.initLogging(Globals.options)
     self.view = NullRepositoryView()
     Utility.initTimezone(Globals.options, self.view)
Esempio n. 10
0
def main():
    message = "while trying to start."

    application.Globals.chandlerDirectory = Utility.locateChandlerDirectory()

    os.chdir(application.Globals.chandlerDirectory)
    """
    Process any command line switches and any environment variable values
    """
    application.Globals.options = Utility.initOptions(
        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 to
            an already-running WingIDE instance.  See:
              http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#wingIDE.
            for details.
            """
            import wingdbstub
        if __debug__ and application.Globals.options.komodo:
            """
            Check for -komodo command line argument; if specified, try to connect to
            an already-running Komodo instance.  See:
              http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#Komodo.
            for details.
            """
            import dbgp.client
            dbgp.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 by
        people who run Chandler using the launchers, e.g. Aparna. If you're
        running release you can also set things up so that you can see
        stderr and stdout if you run in a shell or from wing with a console.
          useBestVisual, uses best screen resolutions on some old computers. See
        wxApp.SetUseBestVisual
        """
        #app = wxApplication(redirect=__debug__, useBestVisual=True)
        app = wxApplication(redirect=False, useBestVisual=True)
        app.MainLoop()

    if application.Globals.options.nocatch:
        # When debugging, it's handy to run without the outer exception frame
        import logging, traceback, wx
        realMain()
    else:
        # The normal way: wrap the app in an exception frame

        try:
            import logging, traceback, wx
            realMain()

        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 initialize
            dialog = wx.MessageDialog(None, message, "Chandler",
                                      wx.OK | wx.ICON_INFORMATION)
            dialog.ShowModal()
            dialog.Destroy()

            #Reraising the exception, so wing catches it.
            raise
Esempio n. 11
0
cause *all* modules in all sub-packages of that package to be imported.)

"""

import sys

from unittest import main
from application import Globals, Utility
from util import test_finder

if __name__ == '__main__':

    if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'):  # XXX
        print __doc__
        sys.exit(2)

    options = Utility.initOptions()
    Utility.initI18n(options)
    Utility.initLogging(options)

    # Rebuild the command line for unittest.main
    args = [sys.argv[0]]
    if options.verbose:
        args.append('-v')
    if options.quiet:
        args.append('-q')
    # options.args has all the leftover arguments from Utility
    sys.argv = args + options.args

    main(module=None, testLoader=test_finder.ScanningLoader())
Esempio n. 12
0
"""

import sys

from unittest import main
from application import Globals, Utility
from util import test_finder


if __name__ == '__main__':

    if len(sys.argv)<2 or sys.argv[1] in ('-h','--help'):   # XXX
        print __doc__
        sys.exit(2)

    options = Utility.initOptions()
    Utility.initI18n(options)
    Utility.initLogging(options)

    # Rebuild the command line for unittest.main
    args = [sys.argv[0]]
    if options.verbose:
        args.append('-v')
    if options.quiet:
        args.append('-q')
    # options.args has all the leftover arguments from Utility
    sys.argv = args + options.args

    main(module=None, testLoader=test_finder.ScanningLoader())

Esempio n. 13
0
def main():
    message = "while trying to start."

    application.Globals.chandlerDirectory = Utility.locateChandlerDirectory()

    os.chdir(application.Globals.chandlerDirectory)

    """
    Process any command line switches and any environment variable values
    """
    application.Globals.options = Utility.initOptions(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 to
            an already-running WingIDE instance.  See:
              http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#wingIDE.
            for details.
            """
            import wingdbstub
        if __debug__ and application.Globals.options.komodo:
            """
            Check for -komodo command line argument; if specified, try to connect to
            an already-running Komodo instance.  See:
              http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#Komodo.
            for details.
            """
            import dbgp.client

            dbgp.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 by
        people who run Chandler using the launchers, e.g. Aparna. If you're
        running release you can also set things up so that you can see
        stderr and stdout if you run in a shell or from wing with a console.
          useBestVisual, uses best screen resolutions on some old computers. See
        wxApp.SetUseBestVisual
        """
        # app = wxApplication(redirect=__debug__, useBestVisual=True)
        app = wxApplication(redirect=False, useBestVisual=True)
        app.MainLoop()

    if application.Globals.options.nocatch:
        # When debugging, it's handy to run without the outer exception frame
        import logging, traceback, wx

        realMain()
    else:
        # The normal way: wrap the app in an exception frame

        try:
            import logging, traceback, wx

            realMain()

        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 initialize
            dialog = wx.MessageDialog(None, message, "Chandler", wx.OK | wx.ICON_INFORMATION)
            dialog.ShowModal()
            dialog.Destroy()

            # Reraising the exception, so wing catches it.
            raise
Esempio n. 14
0
 def setUp(self):
     Globals.options = Utility.initOptions()
     Globals.options.ramdb = True
     Utility.initLogging(Globals.options)
     self.view = Utility.initRepository("", Globals.options, True)
     Utility.initTimezone(Globals.options, self.view)
Esempio n. 15
0
 def setUp(self):
     Globals.options = Utility.initOptions()
     Utility.initLogging(Globals.options)
     self.view = NullRepositoryView()
     Utility.initTimezone(Globals.options, self.view)
Esempio n. 16
0
 def setUp(self):
     Globals.options = Utility.initOptions()
     Globals.options.ramdb = True
     Utility.initLogging(Globals.options)
     self.view = Utility.initRepository("", Globals.options, True)
     Utility.initTimezone(Globals.options, self.view)
Esempio n. 17
0
    Globals.chandlerDirectory = Utility.locateChandlerDirectory()

    os.chdir(Globals.chandlerDirectory)
    Utility.initI18n(Globals.options)

    profileDir = os.path.abspath(
        os.path.join(Globals.chandlerDirectory, '..', 'doc_profile'))

    if not os.path.isdir(profileDir):
        _mkdirs(profileDir)

    print Globals.chandlerDirectory
    print profileDir

    Utility.initLogging(Globals.options)

    parcelPath = Utility.initParcelEnv(Globals.options,
                                       Globals.chandlerDirectory)
    pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options,
                                                  Globals.options.pluginPath)

    view = Utility.initRepository(profileDir, Globals.options)

    verify, repoVersion, schemaVersion = Utility.verifySchema(view)

    Utility.initCrypto(Globals.options.profileDir)
    Utility.initParcels(Globals.options, view, parcelPath)
    Utility.initPlugins(Globals.options, view, pluginEnv, pluginEggs)
    Utility.initTimezone(Globals.options, view)
Esempio n. 18
0
    def realMain():
        
        from application import feedback
        feedback.initRuntimeLog(Globals.options.profileDir)
        
        Globals.chandlerDirectory = Utility.locateChandlerDirectory()
    
        os.chdir(Globals.chandlerDirectory)
        Utility.initLogging(Globals.options)

        if __debug__ and Globals.options.wing:
            # Check for -wing command line argument; if specified, try to 
            # connect to an already-running WingIDE instance. See
            # http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#wingIDE
            # for details.

            import wingdbstub

        if __debug__ and Globals.options.komodo:
            # Check for -komodo command line argument; if specified, try to 
            # connect to an already-running Komodo instance. See
            # http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#Komodo
            # for details.

            import dbgp.client
            dbgp.client.brk()

        from application.Application import wxApplication

        # Redirect stdio and stderr to a dialog if a non-default --catch option 
        # was specified. This is done to catch asserts, which otherwise will
        # never get seen by people who run Chandler using the launchers, e.g.
        # Aparna. If you're running release you can also set things up so 
        # that you can see stderr and stdout if you run in a shell or from
        # wing with a console.
        redirect = Globals.options.catch == 'normal'
        
        # useBestVisual: See wxApp.SetUseBestVisual (Only applicable
        # for X-Windows based systems) On some older computers the
        # default visual may only have a depth of 8 although 24-bit
        # visuals are available. (SGI is notorious for this.) Setting
        # this to True will cause the best visual to be used instead.
        # Unfortunatly on some systems with a 32-bit visual available
        # this can cause problems if the default GTK theme expects to
        # use only 24.  (See Bug #9295) So for now we'll default this
        # to False.  If this becomes a problem in the future then we
        # should add a command-line option for it or perhaps find a
        # way to detect if the display depth is < 24.  (Note there is
        # a chicken-and-egg problem with wx.GetDisplayDepth() as it
        # needs to have the app created before it can be called.)
        useBestVisual = False
        
        app = wxApplication(redirect=redirect, useBestVisual=useBestVisual)

        exitValue = getattr(app, 'exitValue', 0)
        if exitValue:
            return exitValue

        app.MainLoop()

        return getattr(app, 'exitValue', 0)
Esempio n. 19
0
    def realMain():

        from application import feedback
        feedback.initRuntimeLog(Globals.options.profileDir)

        Globals.chandlerDirectory = Utility.locateChandlerDirectory()

        os.chdir(Globals.chandlerDirectory)
        Utility.initLogging(Globals.options)

        if __debug__ and Globals.options.wing:
            # Check for -wing command line argument; if specified, try to
            # connect to an already-running WingIDE instance. See
            # http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#wingIDE
            # for details.

            import wingdbstub

        if __debug__ and Globals.options.komodo:
            # Check for -komodo command line argument; if specified, try to
            # connect to an already-running Komodo instance. See
            # http://wiki.osafoundation.org/bin/view/Chandler/DebuggingChandler#Komodo
            # for details.

            import dbgp.client
            dbgp.client.brk()

        from application.Application import wxApplication

        # Redirect stdio and stderr to a dialog if a non-default --catch option
        # was specified. This is done to catch asserts, which otherwise will
        # never get seen by people who run Chandler using the launchers, e.g.
        # Aparna. If you're running release you can also set things up so
        # that you can see stderr and stdout if you run in a shell or from
        # wing with a console.
        redirect = Globals.options.catch == 'normal'

        # useBestVisual: See wxApp.SetUseBestVisual (Only applicable
        # for X-Windows based systems) On some older computers the
        # default visual may only have a depth of 8 although 24-bit
        # visuals are available. (SGI is notorious for this.) Setting
        # this to True will cause the best visual to be used instead.
        # Unfortunatly on some systems with a 32-bit visual available
        # this can cause problems if the default GTK theme expects to
        # use only 24.  (See Bug #9295) So for now we'll default this
        # to False.  If this becomes a problem in the future then we
        # should add a command-line option for it or perhaps find a
        # way to detect if the display depth is < 24.  (Note there is
        # a chicken-and-egg problem with wx.GetDisplayDepth() as it
        # needs to have the app created before it can be called.)
        useBestVisual = False

        app = wxApplication(redirect=redirect, useBestVisual=useBestVisual)

        exitValue = getattr(app, 'exitValue', 0)
        if exitValue:
            return exitValue

        app.MainLoop()

        return getattr(app, 'exitValue', 0)
Esempio n. 20
0
    Globals.options.verify = False

    Globals.chandlerDirectory = Utility.locateChandlerDirectory()

    os.chdir(Globals.chandlerDirectory)
    Utility.initI18n(Globals.options)

    profileDir = os.path.abspath(os.path.join(Globals.chandlerDirectory, '..', 'doc_profile'))

    if not os.path.isdir(profileDir):
        _mkdirs(profileDir)

    print Globals.chandlerDirectory
    print profileDir

    Utility.initLogging(Globals.options)

    parcelPath = Utility.initParcelEnv(Globals.options, 
                                       Globals.chandlerDirectory)
    pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options,
                                                  Globals.options.pluginPath)

    view = Utility.initRepository(profileDir, Globals.options)

    verify, repoVersion, schemaVersion = Utility.verifySchema(view)

    Utility.initCrypto(Globals.options.profileDir)
    Utility.initParcels(Globals.options, view, parcelPath)
    Utility.initPlugins(Globals.options, view, pluginEnv, pluginEggs)
    Utility.initTimezone(Globals.options, view)