Esempio n. 1
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. 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(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. 4
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
    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)
    e_options.simple_term = True
    e_options.parse = True
    e_options.introspect = True
    e_options.include_log = True
    e_options.target = os.path.join(outputDir, 'api')
    e_options.verbosity = 4

    epydoc.cli.main(e_options, names)


if __name__ == '__main__':
    Globals.options = Utility.initOptions()
    Globals.options.create = True
    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)
Esempio n. 7
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. 8
0
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

import sys
import unittest
import itertools
from application import schema, Globals, Utility
from chandlerdb.persistence.RepositoryView import NullRepositoryView

Globals.chandlerDirectory = Utility.locateChandlerDirectory()
Globals.options = Utility.initOptions()


class MenuTestCase(unittest.TestCase):
    """
    Tests of consistent mnemonics/shortcuts in Chandler's menus.
    """

    view = None

    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
Esempio n. 9
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. 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