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


Python StackedConfig.default_backends方法代码示例

本文整理汇总了Python中dulwich.config.StackedConfig.default_backends方法的典型用法代码示例。如果您正苦于以下问题:Python StackedConfig.default_backends方法的具体用法?Python StackedConfig.default_backends怎么用?Python StackedConfig.default_backends使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dulwich.config.StackedConfig的用法示例。


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

示例1: _configure

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
    def _configure(self):
        """ Parse configuration from git config """
        sc = StackedConfig(StackedConfig.default_backends())
        self.config = {}

        # Get top level directory of project
        proc = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'],
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        self.config['top_dir'] = proc.communicate()[0]

        if proc.returncode != 0:
            exit_code = 20
            log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
            sys.exit(exit_code)

        self.config['deploy_file'] = self.config['top_dir'] + '/.git'

        try:
            self.config['hook_dir'] = sc.get('deploy', 'hook-dir')
        except KeyError:
            exit_code = 21
            log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
            sys.exit(exit_code)

        try:
            self.config['repo_name'] = sc.get('deploy', 'tag-prefix')
        except KeyError:
            exit_code = 22
            log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
            sys.exit(exit_code)
        self.config['sync_dir'] = '{0}/sync'.format(self.config['hook_dir'])
开发者ID:rfaulkner,项目名称:Sartoris,代码行数:34,代码来源:sartoris.py

示例2: create

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
    def create(self, title="tessera title goes here"):
        """ create a new tessera with title {title}.

            @returns Tessera object of the new Tessera
        """
        uuid = uuid1()
        tessera_path = os.path.join(Tessera._tesserae, str(uuid))
        tessera_file = "%s/tessera" % tessera_path
        os.mkdir(tessera_path)
        fin = open(os.path.join(Tessera._tesserae, "template"), "r")
        fout = open(tessera_file, "w")
        for line in fin.readlines():
            if line == "@[email protected]\n":
                line = "# %s\n" % title
            fout.write(line)
        fin.close()
        fout.close()

        tessera_info = "%s/info" % tessera_path
        fout = open(tessera_info, "w")
        c = StackedConfig(StackedConfig.default_backends())
        fout.write("author: %s\n"%c.get("user", "name"))
        fout.write("email: %s\n"%c.get("user", "email"))
        fout.write("updated: %d\n"%int(time()))
        fout.close()

        return Tessera(tessera_path, self._config)
开发者ID:neolynx,项目名称:git-tessera,代码行数:29,代码来源:gittessera.py

示例3: get_config_stack

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
    def get_config_stack(self):
        """Return a config stack for this repository.

        This stack accesses the configuration for both this repository
        itself (.git/config) and the global configuration, which usually
        lives in ~/.gitconfig.

        :return: `Config` instance for this repository
        """
        from dulwich.config import StackedConfig
        backends = [self.get_config()] + StackedConfig.default_backends()
        return StackedConfig(backends, writable=backends[0])
开发者ID:akbargumbira,项目名称:qgis_resources_sharing,代码行数:14,代码来源:repo.py

示例4: configure

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
def configure(**kwargs):
    """ Parse configuration from git config """
    sc = StackedConfig(StackedConfig.default_backends())
    config = {}

    # Get top level directory of project
    proc = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    config['top_dir'] = proc.communicate()[0].strip()

    if proc.returncode != 0:
        exit_code = 20
        log.error("{0} :: {1}".format(__name__, exit_codes[exit_code]))
        sys.exit(exit_code)

    config['deploy_file'] = config['top_dir'] + '/.git/.deploy'

    # Define the key names, git config names, and error codes
    config_elements = {
        'hook_dir': ('deploy', 'hook-dir', 21),
        'path': ('deploy', 'path', 23),
        'user': ('deploy', 'user', 24),
        'target': ('deploy', 'target', 25),
        'repo_name': ('deploy', 'tag-prefix', 22),
        'remote': ('deploy', 'remote', 26),
        'branch': ('deploy', 'branch', 27),
        'client_path': ('deploy', 'client-path', 19),
        'user.name': ('user', 'name', 28),
        'user.email': ('user', 'email', 29),
        'deploy.key_path': ('deploy', 'key-path', 37),
        'deploy.test_repo': ('deploy', 'test-repo-path', 38),
    }

    # Assign the values of each git config element
    for key, value in config_elements.iteritems():
        try:
            # Override with kwargs if the attribute exists
            if key in kwargs:
                config[key] = kwargs[key]
            else:
                config[key] = sc.get(value[0], value[1])
        except KeyError:
            exit_code = value[2]
            log.error("{0} :: {1}".format(__name__, exit_codes[exit_code]))
            sys.exit(exit_code)

    config['sync_dir'] = '{0}/sync'.format(config['hook_dir'])

    return config
开发者ID:davinirjr,项目名称:git-deploy,代码行数:52,代码来源:config.py

示例5: sync

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
 def sync(self, no_deps=False, force=False):
     """
         * add a sync tag
         * write a .deploy file with the tag information
         * call a sync hook with the prefix (repo) and tag info
     """
     # TODO: do git calls in dulwich, rather than shelling out
     # TODO: get all configuration via a function, and get it during main
     if "lock" not in os.listdir(".git/deploy"):
         exit_code = 20
         log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
         return exit_code
     sc = StackedConfig(StackedConfig.default_backends())
     try:
         hook_dir = sc.get("deploy", "hook-dir")
     except KeyError:
         exit_code = 21
         log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
         return exit_code
     try:
         repo_name = sc.get("deploy", "tag-prefix")
     except KeyError:
         exit_code = 22
         log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
         return exit_code
     sync_dir = "{0}/sync".format(hook_dir)
     sync_script = "{0}/{1}.sync".format(sync_dir, repo_name)
     _tag = "{0}-sync-{1}".format(repo_name, datetime.now().strftime(DATE_TIME_TAG_FORMAT))
     proc = subprocess.Popen(["/usr/bin/git tag", "-a", _tag])
     if proc.returncode != 0:
         exit_code = 23
         log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
         return exit_code
     # TODO: use a pluggable sync system rather than shelling out
     if os.path.exists(sync_script):
         proc = subprocess.Popen(
             [
                 sync_script,
                 '--repo="{0}"'.format(repo_name),
                 '--tag="{0}"'.format(_tag),
                 '--force="{0}"'.format(force),
             ]
         )
         log.info(proc.stdout.read())
         if proc.returncode != 0:
             exit_code = 24
             log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
             return exit_code
开发者ID:wikimedia,项目名称:operations-debs-sartoris,代码行数:50,代码来源:sartoris.py

示例6: create

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
    def create(cls, basepath, title):
        t_id = str(generate_uniq_id())
        t_path = os.path.join(basepath, t_id)
        t_file = os.path.join(t_path, Tessera.TESSERA_FILENAME)
        t_info = os.path.join(t_path, Tessera.INFO_FILENAME)

        os.makedirs(t_path)

        with open(Tessera.NEW_TESSERA_TEMPLATE, "r") as fin:
            with open(t_file, "w+") as fout:
                for l in fin.readlines():
                    if l == "@[email protected]\n":
                        l = "# %s\n" % title
                    fout.write(l)

        with open(t_info, "w+") as f:
            c = StackedConfig(StackedConfig.default_backends())
            f.write("author: %s\n" % c.get("user", "name"))
            f.write("email: %s\n" % c.get("user", "email"))
            f.write("updated: %s\n" % datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))

        t = Tessera(t_id, t_path)
        return t
开发者ID:timofurrer,项目名称:git-tessera,代码行数:25,代码来源:tessera.py

示例7: test_default_backends

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
 def test_default_backends(self):
     self.makeSafeEnv()
     StackedConfig.default_backends()
开发者ID:kankri,项目名称:dulwich,代码行数:5,代码来源:test_config.py

示例8: test_default_backends

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
 def test_default_backends(self):
     StackedConfig.default_backends()
开发者ID:stevegt,项目名称:dulwich,代码行数:4,代码来源:test_config.py

示例9: test_default_backends

# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default_backends [as 别名]
 def test_default_backends(self):
     self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
     os.environ["HOME"] = "/nonexistant"
     StackedConfig.default_backends()
开发者ID:codingtony,项目名称:dulwich,代码行数:6,代码来源:test_config.py


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