Esempio n. 1
0
    def test_no_app_w_name(self):
        destroy_app()
        name = 'tnawn'

        data_dirs = get_data_dirs(app_name=name)
        self.data_dirs_correct_structure(data_dirs)
        self.assertTrue(wx.GetApp()==None)
Esempio n. 2
0
def load_all_plugins(data_dirs=None, module_suffix=None, **kwargs):
    '''Load file_interpreters and methods from all levels.'''
    if data_dirs is None:
        data_dirs = get_data_dirs(**kwargs)
    if module_suffix is None:
        module_suffix = str(uuid.uuid4()).replace('-','_')

    plugin_levels = {}
    loaded_plugins = defaultdict(SubstringDict)
    for level in ['builtins', 'application', 'user']:
        for plugin_type in ['file_interpreters', 'methods', 
                'data_interpreters', 'visualizations']:
            plugin_dir = data_dirs[level][plugin_type]
            plugins = load_plugins_from_dir(plugin_dir, module_suffix)
            for plugin in plugins:
                plugin_levels[plugin] = level
                category = get_plugin_category(plugin)
                if plugin.name in loaded_plugins[category].keys():
                    # already loaded this plugin.
                    existing_plugin = loaded_plugins[category][plugin.name]
                    existing_level = plugin_levels[existing_plugin]
                    warn('plugin "%s" loaded from "%s level" is replacing one loaded from "%s level".' % (plugin.name, level, existing_level))

                loaded_plugins[category][plugin.name] = plugin
    return loaded_plugins
Esempio n. 3
0
 def save_strategies(self):
     strategy_path = get_data_dirs(app_name='spikepy')[
             'user']['strategies']
     for strategy in self.strategies.values():
         if strategy.fullpath is None:
             fullpath = os.path.join(strategy_path, 
                     '%s%s' % (strategy.name, self._managed_file_type))
             strategy.fullpath = fullpath
             strategy.save(fullpath)
Esempio n. 4
0
 def load_all_strategies(self):
     '''
     Load all the strategies "builtins", "application", and "user".
     '''
     # load strategies (first builtins, then application, then user)
     for level in ['builtins', 'application', 'user']:
         strategy_path = get_data_dirs(app_name='spikepy')[
                 level]['strategies']
         self.load_strategies(strategy_path)
Esempio n. 5
0
    def test_w_app_no_name(self):
        destroy_app()
        external_name = 'external'
        app = wx.App()
        app.SetAppName(external_name)

        data_dirs = get_data_dirs()
        self.data_dirs_correct_structure(data_dirs)
        self.assertFalse(wx.GetApp()==None)
        if app is not None:
            self.assertTrue(app.GetAppName()==external_name)
Esempio n. 6
0
def load_config(level, **kwargs):
    '''Return the configuration if it passes validation.'''
    data_dirs = path_utils.get_data_dirs(**kwargs)
    config_dir = data_dirs[level]['configuration']
    fullpath = os.path.join(config_dir, 'spikepy.ini')
    config = configobj.ConfigObj(fullpath, 
                                 configspec=get_default_configspec(**kwargs))
    validator = Validator()
    result = config.validate(validator, preserve_errors=True)
    if result == True:
        return config
    else:
        raise ConfigError("Reading in configuration file at %s has failed!\nFailure status: %s" % (fullpath, configobj.flatten_errors(config, result)))
Esempio n. 7
0
def get_default_configspec(**kwargs):
    '''Return the fullpath to the default configspec.'''
    data_dirs = path_utils.get_data_dirs(**kwargs)
    default_config_dir = data_dirs['builtins']['configuration']
    return os.path.join(default_config_dir, 'spikepy.configspec')
Esempio n. 8
0
    def test_no_app_no_name(self):
        destroy_app()

        data_dirs = get_data_dirs()
        self.data_dirs_correct_structure(data_dirs)
        self.assertTrue(wx.GetApp()==None)
Esempio n. 9
0
Copyright (C) 2011  David Morton

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import wx

from spikepy.common import path_utils

print "\nSpikepy configuration directories on platform: %s (%s)" % (wx.Platform, 
                                                        path_utils.platform())

data_dirs = path_utils.get_data_dirs(app_name='spikepy')

for level in data_dirs.keys():
    print "\n\t--%s--" % (level[0].upper() + level[1:].lower())
    for key, value in data_dirs[level].items():
        print "\t\t%s: %s" % (key, value)