def testGetDefaultProductDirectory(self): self._prepProductStore() productDirectory = dirstore.getDefaultProductDirectory('foo/stable') # relative path self.assertEquals(productDirectory, 'foo') os.chdir('foo/stable') # starts with os.getcwd() so will be absolute path productDirectory = dirstore.getDefaultProductDirectory() self.assertEquals(productDirectory, self.workDir + '/foo') self.assertRaises(errors.MissingProductStoreError, dirstore.getDefaultProductDirectory, 'directoryDoesNotExist') os.chdir('/') self.assertRaises(errors.MissingProductStoreError, dirstore.getDefaultProductDirectory, error=True)
def testGetDefaultProductDirectory(self): self._prepProductStore() productDirectory = dirstore.getDefaultProductDirectory('foo/stable') # relative path self.assertEquals(productDirectory, 'foo') os.chdir('foo/stable') # starts with os.getcwd() so will be absolute path productDirectory = dirstore.getDefaultProductDirectory() self.assertEquals(productDirectory, self.workDir + '/foo') self.assertRaises(errors.MissingProductStoreError, dirstore.getDefaultProductDirectory, 'directoryDoesNotExist') os.chdir('/') self.assertRaises(errors.MissingProductStoreError, dirstore.getDefaultProductDirectory, error=True)
def runCommand(self, handle, argSet, args): args = args[2:] allArg = argSet.pop('all', False) conciseArg = argSet.pop('concise', False) verboseArg = argSet.pop('verbose', False) # --verbose overrides --concise; can't be both if verboseArg: verbosity = VERBOSE elif conciseArg: verbosity = CONCISE else: verbosity = DEFAULT repositoryArg = argSet.pop('repository', False) localArg = argSet.pop('local', False) if not localArg and not repositoryArg: # neither == both localArg = repositoryArg = True cwd = os.getcwd() dirList = args if allArg: dirList = [ dirstore.getDefaultProductDirectory(dirName=cwd, error=True) ] elif not args: dirList = [cwd] # productArg = True => print product-definition status # default not to print if in a checkout, otherwise do productArg = not handle.facade.conary.isConaryCheckoutDirectory(cwd) # --product overrides --no-product productArg = not argSet.pop('no-product', not productArg) productArg = argSet.pop('product', productArg) for thisDir in dirList: handle.Status.printDirectoryStatus(thisDir, verbosity=verbosity, product=productArg, local=localArg, repository=repositoryArg)
def runCommand(self, handle, argSet, args): args = args[2:] allArg = argSet.pop('all', False) conciseArg = argSet.pop('concise', False) verboseArg = argSet.pop('verbose', False) # --verbose overrides --concise; can't be both if verboseArg: verbosity = VERBOSE elif conciseArg: verbosity = CONCISE else: verbosity = DEFAULT repositoryArg = argSet.pop('repository', False) localArg = argSet.pop('local', False) if not localArg and not repositoryArg: # neither == both localArg = repositoryArg = True cwd = os.getcwd() dirList = args if allArg: dirList = [dirstore.getDefaultProductDirectory( dirName=cwd, error=True)] elif not args: dirList = [cwd] # productArg = True => print product-definition status # default not to print if in a checkout, otherwise do productArg = not handle.facade.conary.isConaryCheckoutDirectory(cwd) # --product overrides --no-product productArg = not argSet.pop('no-product', not productArg) productArg = argSet.pop('product', productArg) for thisDir in dirList: handle.Status.printDirectoryStatus(thisDir, verbosity=verbosity, product=productArg, local=localArg, repository=repositoryArg)
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)
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)