def __init__(self, pkgroots, options=None, eupsenv=None, installFlavor=None, distribClasses=None, override=None, allowEmptyPkgroot=False, verbosity=None, log=sys.stderr): """ @param pkgroots the base URLs for the distribution repositories. This can either be a list or a pipe-delimited ("|") string. @param options a dictionary of named options that are used to fine- tune the behavior of the repositories. These are passed onto the constructors for the underlying Reposistory classes. @param eupsenv an instance of a Eups class containing the Eups environment to assume @param installFlavor the desired flavor any install requests @param distribClasses a dictionary by name of the Distrib classes to support. This will augmented by those specified by a server. @param override a dictionary of server configuration parameters that should override the configuration received from each server. @param allowEmptyPkgroot we are creating a distribution, so it's OK for pkgroot to be empty @param verbosity if > 0, print status messages; the higher the number, the more messages that are printed (default is the value of eupsenv.verbose). @param log the destination for status messages (default: sys.stderr) """ if isinstance(pkgroots, str): pkgroots = map(lambda p: p.strip(), pkgroots.split("|")) if not allowEmptyPkgroot and len(pkgroots) == 0: raise EupsException("No package servers to query; set -r or $EUPS_PKGROOT") # the Eups environment self.eups = eupsenv if not self.eups: self.eups = Eups() self.verbose = verbosity if self.verbose is None: self.verbose = self.eups.verbose self.log = log if self.log is None: self.log = sys.stdout if not distribClasses: distribClasses = {} # the list of repository base URLs self.pkgroots = [] # a lookup of Repository instances by its base URL self.repos = {} # the preferred installation flavor self.flavor = installFlavor if not self.flavor: self.flavor = self.eups.flavor df = DistribFactory(self.eups) for name in distribClasses.keys(): # note: this will override the server's recommendation # if we want change this, use: # if not df.supportsName(name): # df.register(distribClasses[name], name) # df.register(distribClasses[name], name) for pkgroot in pkgroots: # if pkgroot == None: # ds = None # else: # ds = ServerConf.makeServer(pkgroot, eupsenv=eupsenv, # override=override, # verbosity=self.eups.verbose) # try: dist = Repository(self.eups, pkgroot, options=options, flavor=installFlavor, distFactory=df, verbosity=self.eups.verbose) self.pkgroots += [pkgroot] self.repos[pkgroot] = dist except ImportError, e: msg = "Unable to use server %s: \"%s\"" % (pkgroot, e) if self.eups.force: print >> self.log, msg + "; continuing" else: raise RuntimeError(msg + ". Remove server from PKGROOT or use force")
def __init__(self, eupsenv, pkgroot, flavor=None, options=None, distFactory=None, verbosity=0, log=sys.stderr): """ create a Repository for a given server base URL (pkgroot) @param eupsenv the Eups controller instance to use @param pkgroot the base URL for the package server to pull packages from or deploy packages to. @param flavor the platform flavor of interest. #--CUT When installing packages, this value is ignored and the version set in the Eups controller is assumed to be the target platform. For all other actions (creating server packages, listing available packages), this value will be assumed. #-- If None or "generic", then a generic platform is assumed. @param options a dictionary of options to pass to Distrib instances used to install and create packages @param distFactory a DistFactory instance to use. If not provided a default one is created. @param verbosity if > 0, print status messages; the higher the number, the more messages that are printed (default=0). @param log the destination for status messages (default: sys.stderr) """ self.eups = eupsenv if not flavor: flavor = self.eups.flavor self.flavor = flavor self.distFactory = None if distFactory: self.distFactory = distFactory.clone() self.options = options self.verbose = verbosity if not isinstance(self.verbose, int): self.verbose = 0 self.log = log self.distServer = None if self.options is None: self.options = {} if not isinstance(self.options, dict): raise RuntimeError("Non-dictionary passed to options parameter: " + repr(self.options)) self.pkgroot = pkgroot if pkgroot: override = None if self.options.has_key('serverconf'): override = options['serverconf'] self.distServer = ServerConf.makeServer(pkgroot, eupsenv=eupsenv, override=override, verbosity=self.verbose, log=self.log) if self.distFactory is None: self.distFactory = DistribFactory(self.eups, self.distServer) elif not self.distServer: self.distFactory.resetDistribServer(self.distServer) # a cache of the supported tag names self._supportedTags = None # a cache of supported packages self._pkgList = None # True if servers should always be queried when looking for a # repository to get a package from. If False, an internal cache # of available products will be used. self._alwaysQueryServer = False if self.options.has_key("alwaysQueryServer"): if isinstance(self.options["alwaysQueryServer"], str): self.options["alwaysQueryServer"] = \ self.options["alwaysQueryServer"].upper() if "TRUE".startswith(self.options["alwaysQueryServer"]): self.options["alwaysQueryServer"] = True else: self.options["alwaysQueryServer"] = False if self.options["alwaysQueryServer"]: self._alwaysQueryServer = True if self.distServer is not None and self.distServer.NOCACHE: self._alwaysQueryServer = True