def testBasic(self): # can we get to build packages? pluginloader.getPlugins([], self.rbuildCfg.pluginDirs) os.mkdir(self.rootDir + '/etc') self.rbuildCfg.store(open(self.rootDir + '/etc/rbuildrc', 'w')) self.checkRbuild('build packages', 'rbuild_plugins.buildpackages.BuildPackagesCommand.runCommand', [None, None, {}, ['build', 'packages']])
def testBasic(self): # can we get to build packages? pluginloader.getPlugins([], self.rbuildCfg.pluginDirs) os.mkdir(self.rootDir + '/etc') self.rbuildCfg.store(open(self.rootDir + '/etc/rbuildrc', 'w')) self.checkRbuild( 'build packages', 'rbuild_plugins.buildpackages.BuildPackagesCommand.runCommand', [None, None, {}, ['build', 'packages']])
def testBasic(self): # do plugins load? pluginMgr = pluginloader.getPlugins( [], self.rbuildCfg.pluginDirs, ) pluginMgr.getPlugin('build')
def getHandle(): cfg = handle.RbuildHandle.configClass(readConfigFiles=True) cfg.configLine("pluginDirs %s" % os.path.abspath( os.path.join(os.path.dirname(__file__), '..', 'plugins'))) plugins = pluginloader.getPlugins([], cfg.pluginDirs) h = handle.RbuildHandle(cfg=cfg, pluginManager=plugins, productStore=None) return h
def getCommand(self, argv, cfg): """ Initializes plugins so that all commands are available, then returns the correct command based on argv. @param argv: Argument vector as provided by C{sys.argv} @param cfg: An C{RbuildConfiguration} object @return: C{commandClass} instance selected by C{argv} """ self.plugins = pluginloader.getPlugins(argv, cfg.pluginDirs) self.handle = handle.RbuildHandle(cfg, self.plugins) self.handle.ui.pushContext('rBuild %s: %s', self.version, ' '.join(argv)) self.plugins.registerCommands(self, self.handle) self.plugins.registerFacade(self.handle) self.plugins.initialize() return mainhandler.MainHandler.getCommand(self, argv, cfg)
def getHandle(dirName=None, prodDefLabel=None): """ Initializes an rBuild handle object, with a product definition as defined by the C{dirName} parameter (which provides a C{dirstore.CheckoutProductStore} product store) or the C{prodDefLabel} parameter (which provides a more limited C{abstract.ProductStore} product store that is insufficient for many plugin operations). If no parameter is specified, a C{dirstore.CheckoutProductStore} product store is provided based on the current directory. @param dirName: (None) directory for product store @param prodDefLabel: (None) label for product definition. @return: C{handle} instance """ cfg = handle.RbuildHandle.configClass(readConfigFiles=True) if prodDefLabel: productStore = None else: # note that if dirName is None, this defaults to current directory productStore = dirstore.CheckoutProductStore(baseDirectory=dirName) plugins = pluginloader.getPlugins([], cfg.pluginDirs) h = handle.RbuildHandle(cfg=cfg, pluginManager=plugins, productStore=productStore) if prodDefLabel: productStore = abstract.ProductStore() product = productStore.getProduct() client = h.facade.conary._getConaryClient() stream, _ = product._getStreamFromRepository(client, prodDefLabel) stream.seek(0) product.parseStream(stream) return h
def getHandle(dirName=None, prodDefLabel=None): """ Initializes an rBuild handle object, with a product definition as defined by the C{dirName} parameter (which provides a C{dirstore.CheckoutProductStore} product store) or the C{prodDefLabel} parameter (which provides a more limited C{abstract.ProductStore} product store that is insufficient for many plugin operations). If no parameter is specified, a C{dirstore.CheckoutProductStore} product store is provided based on the current directory. @param dirName: (None) directory for product store @param prodDefLabel: (None) label for product definition. @return: C{handle} instance """ cfg = handle.RbuildHandle.configClass(readConfigFiles=True) if prodDefLabel: productStore=None else: # note that if dirName is None, this defaults to current directory productStore = dirstore.CheckoutProductStore(baseDirectory=dirName) plugins = pluginloader.getPlugins([], cfg.pluginDirs) h = handle.RbuildHandle(cfg=cfg, pluginManager=plugins, productStore=productStore) if prodDefLabel: productStore = abstract.ProductStore() product = productStore.getProduct() client = h.facade.conary._getConaryClient() stream, _ = product._getStreamFromRepository(client, prodDefLabel) stream.seek(0) product.parseStream(stream) return h
def enablePlugins(self): from rbuild.internal import pluginloader pluginloader.getPlugins([], self.rbuildCfg.pluginDirs)
def __init__(self, cfg=None, pluginManager=None, productStore=None, userInterface=None, logRoot=None): super(RbuildHandle, self).__init__() self.product = None if cfg is None: cfg = self.configClass(readConfigFiles=True) if pluginManager is None: pluginManager = pluginloader.getPlugins([], cfg.pluginDirs) # Unknown sections are initially stashed aside by the config object # After the plugins are loaded we try to process their data pluginManager.addPluginConfigurationClasses(cfg) cfg.setIgnoreErrors(False) cfg.processPluginSections() pluginManager.setPluginConfigurations(cfg) self._cfg = cfg self._pluginManager = pluginManager for plugin in pluginManager.plugins: pluginName = plugin.__class__.__name__ self[pluginName] = plugin plugin.setHandle(self) # Provide access to facades self.facade = _PluginProxy(self._getFacades()) # Provide the command manager as if it were a plugin self['Commands'] = CommandManager() if userInterface is not None: self.ui = userInterface else: if logRoot is not False: if not logRoot: logRoot = errors._findCheckoutRoot() if logRoot: logRoot += '/.rbuild' #pylint: disable-msg=C0103 # this name is intentional self.ui = ui.UserInterface(self._cfg, logRoot=logRoot) if productStore is None: # default product store is directory-based # Note: will still be None for some cases, such as rbuild init proddir = dirstore.getDefaultProductDirectory() if proddir is not None: productStore = dirstore.CheckoutProductStore(None, proddir) self.productStore = productStore if productStore: self.product = productStore.getProduct() if hasattr(productStore, 'getRbuildConfigPath'): rBuildConfigPath = productStore.getRbuildConfigPath() if rBuildConfigPath is not None: self._cfg.read(rBuildConfigPath, exception=False) elif hasattr(productStore, 'getRbuildConfigData'): RbuildConfigData = productStore.getRbuildConfigData() if RbuildConfigData is not None: self._cfg.readObject('INTERNAL', RbuildConfigData)
# # Copyright (c) SAS Institute Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # 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 os import sys sys.path.insert(0, os.environ['CONARY_PATH']) sys.path.insert(0, os.environ['RMAKE_PATH']) sys.path.insert(0, os.environ['RBUILD_PATH']) sys.path.insert(0, os.environ['PRODUCT_DEFINITION_PATH']) from rbuild.internal import pluginloader pluginDir = os.path.realpath(os.environ['RBUILD_PATH'] + '/plugins') plugins = pluginloader.getPlugins([], [pluginDir]) plugins.loader.install()
def testBasic(self): # do plugins load? pluginMgr = pluginloader.getPlugins([], self.rbuildCfg.pluginDirs,) pluginMgr.getPlugin('build')