示例#1
0
def setPluginDefaults(my_interface=None):
    """
    Set the plugin defaults for things like getting the defult plugin based upon class
    """
    from Ganga.Utility.Plugin import allPlugins
    # set the default value for the plugins
    from Ganga.Utility.Config import getConfig
    default_plugins_cfg = getConfig("Plugins")
    from Ganga.Utility.logging import getLogger
    logger = getLogger()
    for opt in default_plugins_cfg:
        try:
            category, tag = opt.split('_')
        except ValueError, err:
            logger.warning("do not understand option %s in [Plugins]", opt)
            logger.debug('Reason: want %s' % str(err))
        else:
            if tag == 'default':
                try:
                    allPlugins.setDefault(category, default_plugins_cfg[opt])
                except Ganga.Utility.Plugin.PluginManagerError as x:
                    logger.warning('cannot set the default plugin "%s": %s' %
                                   (opt, x))
            else:
                logger.warning("do not understand option %s in [Plugins]", opt)
示例#2
0
def setPluginDefaults(my_interface=None):
    """
    Set the plugin defaults for things like getting the defult plugin based upon class
    """
    from Ganga.Utility.Plugin import allPlugins
    # set the default value for the plugins
    from Ganga.Utility.Config import getConfig
    default_plugins_cfg = getConfig("Plugins")
    from Ganga.Utility.logging import getLogger
    logger = getLogger()
    for opt in default_plugins_cfg:
        try:
            category, tag = opt.split('_')
        except ValueError, err:
            logger.warning("do not understand option %s in [Plugins]", opt)
            logger.debug('Reason: want %s' % str(err))
        else:
            if tag == 'default':
                try:
                    allPlugins.setDefault(category, default_plugins_cfg[opt])
                except Ganga.Utility.Plugin.PluginManagerError as x:
                    logger.warning('cannot set the default plugin "%s": %s' % (opt, x))
            else:
                logger.warning("do not understand option %s in [Plugins]", opt)
示例#3
0
            exportToPublicInterface(n, cls._proxyClass, 'Classes')

# ------------------------------------------------------------------------------------
# set the default value for the plugins
default_plugins_cfg = getConfig("Plugins")

for opt in default_plugins_cfg:
    try:
        category, tag = opt.split('_')
    except ValueError, err:
        logger.warning("do not understand option %s in [Plugins]", opt)
        logger.debug('Reason: want %s' % str(err))
    else:
        if tag == 'default':
            try:
                allPlugins.setDefault(category, default_plugins_cfg[opt])
            except Ganga.Utility.Plugin.PluginManagerError as x:
                logger.warning('cannot set the default plugin "%s": %s' %
                               (opt, x))
        else:
            logger.warning("do not understand option %s in [Plugins]", opt)

# ------------------------------------------------------------------------------------
# set alias for default Batch plugin (it will not appear in the configuration)
# batch_default_name = getConfig('Configuration').getEffectiveOption('Batch')
# try:
#     batch_default = allPlugins.find('backends', batch_default_name)
# except Exception as x:
#     raise Ganga.Utility.Config.ConfigError('Check configuration. Unable to set default Batch backend alias (%s)' % str(x))
# else:
#     allPlugins.add(batch_default, 'backends', 'Batch')
示例#4
0
            exportToPublicInterface(n, getProxyClass(cls), 'Classes')

# ------------------------------------------------------------------------------------
# set the default value for the plugins
default_plugins_cfg = getConfig("Plugins")

for opt in default_plugins_cfg:
    try:
        category, tag = opt.split('_')
    except ValueError, err:
        logger.warning("do not understand option %s in [Plugins]", opt)
        logger.debug('Reason: want %s' % str(err))
    else:
        if tag == 'default':
            try:
                allPlugins.setDefault(category, default_plugins_cfg[opt])
            except Ganga.Utility.Plugin.PluginManagerError as x:
                logger.warning('cannot set the default plugin "%s": %s' % (opt, x))
        else:
            logger.warning("do not understand option %s in [Plugins]", opt)

# ------------------------------------------------------------------------------------
# set alias for default Batch plugin (it will not appear in the configuration)
# batch_default_name = getConfig('Configuration').getEffectiveOption('Batch')
# try:
#     batch_default = allPlugins.find('backends', batch_default_name)
# except Exception as x:
#     raise Ganga.Utility.Config.ConfigError('Check configuration. Unable to set default Batch backend alias (%s)' % str(x))
# else:
#     allPlugins.add(batch_default, 'backends', 'Batch')
#     exportToPublicInterface('Batch', batch_default._proxyClass, 'Classes')
示例#5
0
    
    """
    _category = 'mergers'
    _exportmethods = ['merge']
    _name = 'CustomMerger'
    _schema = AbstractMerger._schema.inherit_copy()
    _schema.datadict['module'] = FileItem(defvalue = None, doc='Path to a python module to perform the merge.')
        

    def __init__(self):
        super(CustomMerger,self).__init__(_CustomMergeTool())

    def merge(self, jobs, outputdir = None, ignorefailed = None, overwrite = None):
        if self.module is None or not self.module:
            logger.error('No custom module specified. The merge will end now')
            return AbstractMerger.success
        self.merge_tool.module = self.module
        #needed as exportmethods doesn't seem to cope with inheritance
        return super(CustomMerger,self).merge(jobs, outputdir, ignorefailed, overwrite)
    


#configure the plugins
allPlugins.add(_CustomMergeTool,'merge_tools','_CustomMergeTool') 
allPlugins.add(_TextMergeTool,'merge_tools','_TextMergeTool')
allPlugins.add(_RootMergeTool,'merge_tools','_RootMergeTool')        
#we need a default, but don't care much what it is
allPlugins.setDefault('merge_tools','_TextMergeTool')