当前位置: 首页>>代码示例>>Python>>正文


Python Collection.Collection类代码示例

本文整理汇总了Python中Bcfg2.Server.Plugins.Packages.Collection.Collection的典型用法代码示例。如果您正苦于以下问题:Python Collection类的具体用法?Python Collection怎么用?Python Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, metadata, sources, basepath, debug=False):
        Collection.__init__(self, metadata, sources, basepath, debug=debug)
        self.keypath = os.path.join(self.basepath, "keys")

        if len(sources):
            config = sources[0].config
            self.use_yum = has_yum and config.getboolean("yum",
                                                         "use_yum_libraries",
                                                         default=False)
        else:
            self.use_yum = False

        if self.use_yum:
            self.cachefile = os.path.join(self.cachepath,
                                         "cache-%s" % self.cachekey)
            if not os.path.exists(self.cachefile):
                os.mkdir(self.cachefile)

            self.configdir = os.path.join(self.basepath, "yum")
            if not os.path.exists(self.configdir):
                os.mkdir(self.configdir)
            self.cfgfile = os.path.join(self.configdir,
                                        "%s-yum.conf" % self.cachekey)
            self.write_config()

            self.helper = self.config.get("yum", "helper",
                                          default="/usr/sbin/bcfg2-yum-helper")
        if has_pulp:
            _setup_pulp(self.config)
开发者ID:espro,项目名称:bcfg2,代码行数:29,代码来源:Yum.py

示例2: __init__

    def __init__(self, metadata, sources, cachepath, basepath, debug=False):
        Collection.__init__(self, metadata, sources, cachepath, basepath, debug=debug)
        self.keypath = os.path.join(self.cachepath, "keys")

        self._helper = None
        if self.use_yum:
            #: Define a unique cache file for this collection to use
            #: for cached yum metadata
            self.cachefile = os.path.join(self.cachepath, "cache-%s" % self.cachekey)
            if not os.path.exists(self.cachefile):
                os.mkdir(self.cachefile)

            #: The path to the server-side config file used when
            #: resolving packages with the Python yum libraries
            self.cfgfile = os.path.join(self.cachefile, "yum.conf")
            self.write_config()
            self.cmd = Executor()
        else:
            self.cachefile = None
            self.cmd = None

        if HAS_PULP and self.has_pulp_sources:
            _setup_pulp()
            if self.pulp_cert_set is None:
                certdir = os.path.join(self.basepath, "pulp", os.path.basename(PulpCertificateSet.certpath))
                try:
                    os.makedirs(certdir)
                except OSError:
                    err = sys.exc_info()[1]
                    if err.errno == errno.EEXIST:
                        pass
                    else:
                        self.logger.error("Could not create Pulp consumer " "cert directory at %s: %s" % (certdir, err))
                self.pulp_cert_set = PulpCertificateSet(certdir)
开发者ID:shellox,项目名称:bcfg2,代码行数:34,代码来源:Yum.py

示例3: __init__

    def __init__(self, metadata, sources, basepath):
        Collection.__init__(self, metadata, sources, basepath)
        self.keypath = os.path.join(self.basepath, "keys")

        if len(sources):
            config = sources[0].config
            self.use_yum = has_yum
            try:
                self.use_yum &= config.getboolean("yum", "use_yum_libraries")
            except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
                self.use_yum = False
        else:
            self.use_yum = False

        if self.use_yum:
            self.cachefile = os.path.join(self.cachepath,
                                         "cache-%s" % self.cachekey)
            if not os.path.exists(self.cachefile):
                os.mkdir(self.cachefile)
                
            self.configdir = os.path.join(self.basepath, "yum")
            if not os.path.exists(self.configdir):
                os.mkdir(self.configdir)
            self.cfgfile = os.path.join(self.configdir,
                                        "%s-yum.conf" % self.cachekey)
            self.write_config()

            try:
                self.helper = self.config.get("yum", "helper")
            except ConfigParser.NoOptionError:
                self.helper = "/usr/sbin/bcfg2-yum-helper"
            
        if has_pulp:
            _setup_pulp(self.config)
开发者ID:drsm79,项目名称:bcfg2,代码行数:34,代码来源:Yum.py

示例4: __init__

 def __init__(self, metadata, sources, cachepath, basepath, debug=False):
     # we define an __init__ that just calls the parent __init__,
     # so that we can set the docstring on __init__ to something
     # different from the parent __init__ -- namely, the parent
     # __init__ docstring, minus everything after ``.. -----``,
     # which we use to delineate the actual docs from the
     # .. autoattribute hacks we have to do to get private
     # attributes included in sphinx 1.0 """
     Collection.__init__(self, metadata, sources, cachepath, basepath, debug=debug)
开发者ID:AlexanderS,项目名称:bcfg2,代码行数:9,代码来源:Apt.py

示例5: __init__

    def __init__(self, metadata, sources, basepath, debug=False):
        Collection.__init__(self, metadata, sources, basepath, debug=debug)
        self.keypath = os.path.join(self.basepath, "keys")

        if self.use_yum:
            self.cachefile = os.path.join(self.cachepath, "cache-%s" % self.cachekey)
            if not os.path.exists(self.cachefile):
                os.mkdir(self.cachefile)

            self.cfgfile = os.path.join(self.cachefile, "yum.conf")
            self.write_config()
        if has_pulp and self.has_pulp_sources:
            _setup_pulp(self.setup)

        self._helper = None
开发者ID:stpierre,项目名称:bcfg2,代码行数:15,代码来源:Yum.py

示例6: get_deps

 def get_deps(self, package):
     if not self.use_yum:
         return Collection.get_deps(self, package)
     else:
         # this should really never get called; it's just provided
         # for API completeness
         return self.call_helper("get_deps", package)
开发者ID:ab,项目名称:bcfg2,代码行数:7,代码来源:Yum.py

示例7: is_virtual_package

 def is_virtual_package(self, package):
     if not self.use_yum:
         return Collection.is_virtual_package(self, package)
     else:
         # this should really never get called; it's just provided
         # for API completeness
         return self.call_helper("is_virtual_package", package)
开发者ID:ab,项目名称:bcfg2,代码行数:7,代码来源:Yum.py

示例8: setup_data

    def setup_data(self, force_update=False):
        if not self.use_yum:
            return Collection.setup_data(self, force_update)

        for cfile in glob.glob(os.path.join(self.configdir, "*-yum.conf")):
            os.unlink(cfile)
            self._yb = None
        
        self.pkgs_cache.clear()
        self.deps_cache.clear()
        self.vpkgs_cache.clear()
        self.group_cache.clear()
        self.pkgset_cache.clear()
        
        if force_update:
            for mdtype in ["Headers", "Packages", "Sqlite", "Metadata",
                           "ExpireCache"]:
                # for reasons that are entirely obvious, all of the
                # yum API clean* methods return a tuple of 0 (zero,
                # always zero) and a list containing a single message
                # about how many files were deleted.  so useful.
                # thanks, yum.
                self.logger.info("Packages: %s" %
                                 getattr(self.yumbase,
                                         "clean%s" % mdtype)()[1][0])
开发者ID:mikemccllstr,项目名称:bcfg2,代码行数:25,代码来源:Yum.py

示例9: get_provides

 def get_provides(self, required, all=False, silent=False):
     if not self.use_yum:
         return Collection.get_provides(self, package)
     else:
         # this should really never get called; it's just provided
         # for API completeness
         return self.call_helper("get_provides", package)
开发者ID:ab,项目名称:bcfg2,代码行数:7,代码来源:Yum.py

示例10: get_provides

    def get_provides(self, required, all=False, silent=False):
        if not self.use_yum:
            return Collection.get_provides(self, package)

        if not isinstance(required, tuple):
            required = (required, None, (None, None, None))

        try:
            return self.vpkgs_cache[required]
        except KeyError:
            pass
        
        try:
            prov = \
                self.yumbase.whatProvides(*required).returnNewestByNameArch()
        except yum.Errors.NoMoreMirrorsRepoError:
            err = sys.exc_info()[1]
            self.logger.error("Packages: Temporary failure loading metadata "
                              "for '%s': %s" %
                              (self.get_package_name(required),
                               err))
            self.vpkgs_cache[required] = None
            return []

        if prov and not all:
            prov = self._filter_provides(required, prov)
        elif not prov and not silent:
            self.logger.error("Packages: No package provides %s" %
                              self.get_package_name(required))
        self.vpkgs_cache[required] = prov
        return self.vpkgs_cache[required]
开发者ID:mikemccllstr,项目名称:bcfg2,代码行数:31,代码来源:Yum.py

示例11: setup_data

    def setup_data(self, force_update=False):
        """ Do any collection-level data setup tasks. This is called
        when sources are loaded or reloaded by
        :class:`Bcfg2.Server.Plugins.Packages.Packages`.

        If the builtin yum parsers are in use, this defers to
        :func:`Bcfg2.Server.Plugins.Packages.Collection.Collection.setup_data`.
        If using the yum Python libraries, this cleans up cached yum
        metadata, regenerates the server-side yum config (in order to
        catch any new sources that have been added to this server),
        and then cleans up cached yum metadata again, in case the new
        config has any preexisting cache.

        :param force_update: Ignore all local cache and setup data
                             from its original upstream sources (i.e.,
                             the package repositories)
        :type force_update: bool
        """
        if not self.use_yum:
            return Collection.setup_data(self, force_update)

        if force_update:
            # we call this twice: one to clean up data from the old
            # config, and once to clean up data from the new config
            self.call_helper("clean")

        os.unlink(self.cfgfile)
        self.write_config()

        if force_update:
            self.call_helper("clean")
开发者ID:zenazn,项目名称:bcfg2,代码行数:31,代码来源:Yum.py

示例12: is_virtual_package

 def is_virtual_package(self, package):
     if self.use_yum:
         try:
             return bool(self.vpkgs_cache[package])
         except KeyError:
             return bool(self.get_provides(package, silent=True))
     else:
         return Collection.is_virtual_package(self, package)
开发者ID:mikemccllstr,项目名称:bcfg2,代码行数:8,代码来源:Yum.py

示例13: is_package

 def is_package(self, package):
     if not self.use_yum:
         return Collection.is_package(self, package)
     elif isinstance(package, tuple):
         if package[1] is None and package[2] == (None, None, None):
             package = package[0]
         else:
             return None
     else:
         # this should really never get called; it's just provided
         # for API completeness
         return self.call_helper("is_package", package)
开发者ID:ab,项目名称:bcfg2,代码行数:12,代码来源:Yum.py

示例14: __init__

    def __init__(self, metadata, sources, basepath):
        Collection.__init__(self, metadata, sources, basepath)
        self.keypath = os.path.join(self.basepath, "keys")

        if len(sources):
            config = sources[0].config
            self.use_yum = has_yum
            try:
                self.use_yum &= config.getboolean("yum", "use_yum_libraries")
            except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
                self.use_yum = False
        else:
            self.use_yum = False

        if self.use_yum:
            self._yb = None
            self.cachefile = os.path.join(self.cachepath,
                                         "cache-%s" % self.cachekey)
            if not os.path.exists(self.cachefile):
                os.mkdir(self.cachefile)
                
            self.configdir = os.path.join(self.basepath, "yum")
            if not os.path.exists(self.configdir):
                os.mkdir(self.configdir)
            self.cfgfile = os.path.join(self.configdir,
                                        "%s-yum.conf" % self.cachekey)
            if self.config.has_option("yum", "metadata_expire"):
                cache_expire = self.config.getint("yum", "metadata_expire")
            else:
                cache_expire = 21600
            
            self.pkgs_cache = Cache(expiration=cache_expire)
            self.deps_cache = Cache(expiration=cache_expire)
            self.vpkgs_cache = Cache(expiration=cache_expire)
            self.group_cache = Cache(expiration=cache_expire)
            self.pkgset_cache = Cache(expiration=cache_expire)

        if has_pulp:
            _setup_pulp(self.config)
开发者ID:mikemccllstr,项目名称:bcfg2,代码行数:39,代码来源:Yum.py

示例15: setup_data

    def setup_data(self, force_update=False):
        if not self.use_yum:
            return Collection.setup_data(self, force_update)

        if force_update:
            # we call this twice: one to clean up data from the old
            # config, and once to clean up data from the new config
            self.call_helper("clean")

        os.unlink(self.cfgfile)
        self.write_config()

        if force_update:
            self.call_helper("clean")
开发者ID:ab,项目名称:bcfg2,代码行数:14,代码来源:Yum.py


注:本文中的Bcfg2.Server.Plugins.Packages.Collection.Collection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。