Ejemplo 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")
Ejemplo n.º 2
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')
Ejemplo 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
Ejemplo 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
Ejemplo n.º 5
0
    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)

    outputDir = os.path.join(Globals.chandlerDirectory, 'docs')

    if os.path.isfile('Chandler.py'):
        if not os.path.isdir(outputDir):
            _mkdirs(outputDir)

        generateModelDocs(Globals.chandlerDirectory, view, outputDir)
        generateDocs(outputDir)
    else:
        print "Error: Currently gen_docs.py assumes it is running in the chandler/ directory"

    Utility.stopWakeup()
    Utility.stopTwisted()
Ejemplo n.º 6
0
    def onInstallPluginsEvent(self, event):

        patterns = "%s|*.tar.gz;*.tar|%s (*.*)|*.*" % (_(u"tar archives"),
                                                       _(u"All files"))
        dlg = wx.FileDialog(None, _(u"Install Plugin"), "", "", patterns,
                            wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            archive = dlg.GetPath()
        else:
            archive = None
        dlg.Destroy()

        if archive is not None:
            options = Globals.options

            # find writable path on options.pluginPath
            # it is assumed that, unless the user changed the defaults,
            # that pluginPath contains at least a path relative to CHANDLERHOME
            # and another relative to the user's PROFILEDIR, in that order,
            # so that plugins are installed in a shared directory (when
            # CHANDLERHOME is shared) by default.

            for pluginsDir in options.pluginPath:
                try:
                    if not os.path.exists(pluginsDir):
                        os.makedirs(pluginsDir)
                except OSError:
                    continue
                if os.access(pluginsDir, os.W_OK):
                    break
            else:
                raise ValueError, ('no writable path in pluginPath',
                                   options.pluginPath)

            try:
                from setuptools.command.easy_install import main
                from distutils.log import _global_log
                from util.string_utils import nocase_replace

                # patch distutils' logger with logging's
                # distutils logging levels happen to be one tenth of logging's
                # Also ensure that we don't write full profileDir to log,
                # which would be a security issue.
                def log(level, msg, args):
                    if msg:
                        if wx.Platform == '__WXMSW__':
                            msg = nocase_replace(msg,
                                                 Globals.options.profileDir,
                                                 '$PROFILEDIR')
                        else:
                            msg = msg.replace(Globals.options.profileDir,
                                              '$PROFILEDIR')

                    logger.log(level * 10, msg, *args)

                _log = _global_log._log
                _global_log._log = log

                try:
                    main([
                        '--multi-version', '--install-dir', pluginsDir, archive
                    ])
                except:
                    logger.exception("Plugin installation failed")
                    # Could be a SystemExit exception, since we called a
                    # main() directly.
            finally:
                _global_log._log = _log

            env, eggs = Utility.initPluginEnv(options, options.pluginPath)
            prefs = Utility.initPlugins(options, self.itsView, env, eggs)

            # Update the menus
            self.widget.GetSubMenu().pluginPrefs = prefs.get('plugins', {})
            self.synchronizeWidget()
            self.refreshMenus(self.itsView)
Ejemplo n.º 7
0
    def onInstallPluginsEvent(self, event):

        patterns = "%s|*.tar.gz;*.tar|%s (*.*)|*.*" %(_(u"tar archives"),
                                                      _(u"All files"))
        dlg = wx.FileDialog(None, _(u"Install Plugin"), "", "", patterns,
                            wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            archive = dlg.GetPath()
        else:
            archive = None
        dlg.Destroy()

        if archive is not None:
            options = Globals.options

            # find writable path on options.pluginPath
            # it is assumed that, unless the user changed the defaults,
            # that pluginPath contains at least a path relative to CHANDLERHOME
            # and another relative to the user's PROFILEDIR, in that order,
            # so that plugins are installed in a shared directory (when
            # CHANDLERHOME is shared) by default.

            for pluginsDir in options.pluginPath:
                try:
                    if not os.path.exists(pluginsDir):
                        os.makedirs(pluginsDir)
                except OSError:
                    continue
                if os.access(pluginsDir, os.W_OK):
                    break
            else:
                raise ValueError, ('no writable path in pluginPath',
                                   options.pluginPath)

            try:
                from setuptools.command.easy_install import main
                from distutils.log import _global_log
                from util.string_utils import nocase_replace
                
                # patch distutils' logger with logging's
                # distutils logging levels happen to be one tenth of logging's
                # Also ensure that we don't write full profileDir to log,
                # which would be a security issue.
                def log(level, msg, args):
                    if msg:
                        if wx.Platform == '__WXMSW__':
                            msg = nocase_replace(msg,
                                                 Globals.options.profileDir,
                                                '$PROFILEDIR')
                        else:
                            msg = msg.replace(Globals.options.profileDir,
                                              '$PROFILEDIR')
                            
                    logger.log(level * 10, msg, *args)

                _log = _global_log._log
                _global_log._log = log

                try:
                    main(['--multi-version', '--install-dir', pluginsDir, archive])
                except:
                    logger.exception("Plugin installation failed")
                    # Could be a SystemExit exception, since we called a
                    # main() directly.
            finally:
                _global_log._log = _log

            env, eggs = Utility.initPluginEnv(options, options.pluginPath)
            prefs = Utility.initPlugins(options, self.itsView, env, eggs)

            # Update the menus
            self.widget.GetSubMenu().pluginPrefs = prefs.get('plugins', {})
            self.synchronizeWidget()
            self.refreshMenus(self.itsView);
Ejemplo n.º 8
0
    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)

    outputDir = os.path.join(Globals.chandlerDirectory, 'docs')

    if os.path.isfile('Chandler.py'):
        if not os.path.isdir(outputDir):
            _mkdirs(outputDir)

        generateModelDocs(Globals.chandlerDirectory, view, outputDir)
        generateDocs(outputDir)
    else:
        print "Error: Currently gen_docs.py assumes it is running in the chandler/ directory"

    Utility.stopWakeup()
    Utility.stopTwisted()