• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.execute_command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: available_tags

    def available_tags(self):
        base = self._base_from_svn()
        tags_name = self._tags_name
        if tags_name is None:
            # Suggest to create a tags dir with the default plural /tags name.
            print("tags dir does not exist at %s" % base + 'tags')
            if utils.ask("Shall I create it"):
                cmd = 'svn mkdir %stags -m "Creating tags directory."' % (base)
                logger.info("Running %r", cmd)
                print(execute_command(cmd))
                tags_name = self._tags_name
                assert tags_name == 'tags'
            else:
                sys.exit(0)

        tag_info = execute_command('svn list %s%s' % (base, tags_name))
        network_errors = [
            'Could not resolve hostname',
            'E670008',
            'Repository moved',
            'Unable to connect',
        ]
        found_errors = [1 for network_error in network_errors
                        if network_error in tag_info]
        if found_errors:
            logger.error('Network problem: %s', tag_info)
            sys.exit(1)
        tags = [line.replace('/', '').strip()
                for line in tag_info.split('\n')]
        tags = [tag for tag in tags if tag]  # filter empty ones
        logger.debug("Available tags: %r", tags)
        return tags
开发者ID:blampe,项目名称:zest.releaser,代码行数:32,代码来源:svn.py


示例2: get_setup_py_name

 def get_setup_py_name(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted name, like
         # UserWarnings.
         utils.execute_command(utils.setup_py('egg_info'))
         return utils.execute_command(utils.setup_py('--name')).strip()
开发者ID:awello,项目名称:zest.releaser,代码行数:7,代码来源:vcs.py


示例3: _tags_name

    def _tags_name(self):
        """Return name for tags dir

        Normally the plural /tags, but some projects have the singular /tag.

        """
        default_plural = 'tags'
        fallback_singular = 'tag'
        # svn 1.7 introduced a slightly different message and a warning code.
        failure_messages = ["non-existent in that revision",
                            "W160013",
                            ]
        base = self._base_from_svn()
        tag_info = execute_command('svn list %s%s' % (base, default_plural))
        # Look for one of the failure messages:
        found = [1 for mess in failure_messages if mess in tag_info]
        if not found:
            return default_plural
        logger.debug("tags dir does not exist at %s%s", base, default_plural)

        tag_info = execute_command('svn list %s%s' % (base, fallback_singular))
        # Look for one of the failure messages:
        found = [1 for mess in failure_messages if mess in tag_info]
        if not found:
            return fallback_singular
        logger.debug("tags dir does not exist at %s%s, either", base,
                     fallback_singular)
        return None
开发者ID:blampe,项目名称:zest.releaser,代码行数:28,代码来源:svn.py


示例4: _upload_distributions

    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.error(
                "You must have a properly configured %s file in "
                "your home dir to upload to a Python package index.",
                pypi.DIST_CONFIG_FILE)
            if utils.ask("Do you want to continue without uploading?",
                         default=False):
                return
            sys.exit(1)

        # Run extra entry point
        self._run_hooks('before_upload')

        # Get list of all files to upload.
        files_in_dist = sorted([
            os.path.join('dist', filename) for filename in os.listdir('dist')]
        )

        # Get servers/repositories.
        servers = self.pypiconfig.distutils_servers()

        register = self.pypiconfig.register_package()
        for server in servers:
            default = True
            exact = False
            if server == 'pypi' and not package_in_pypi(package):
                logger.info("This package does NOT exist yet on PyPI.")
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            question = "Upload"
            if register:
                question = "Register and upload"
            if utils.ask("%s to %s" % (question, server),
                         default=default, exact=exact):
                if register:
                    logger.info("Registering...")
                    # We only need the first file, it has all the needed info
                    self._retry_twine('register', server, files_in_dist[:1])
                self._retry_twine('upload', server, files_in_dist)
开发者ID:zestsoftware,项目名称:zest.releaser,代码行数:56,代码来源:release.py


示例5: fillchangelog

def fillchangelog(context):
    default_location = None
    setup_cfg = pypi.SetupConfig()
    config = setup_cfg.config
    if config and config.has_option('zest.releaser', 'history_file'):
        default_location = config.get('zest.releaser', 'history_file')

    vcs = zest.releaser.choose.version_control()
    history_file = vcs.history_file(location=default_location)
    if history_file:

        try:
            found = zest.releaser.utils.get_last_tag(vcs)
            log_command = vcs.cmd_log_since_tag(found)
        except SystemExit:
            log_command = get_all_commits_command(vcs)

        if log_command:
            data = execute_command(log_command)
            pretty_data = prettyfy_logs(data, vcs)

            print('These are all the commits since the last tag:')
            print('')
            print('\n'.join(pretty_data))

            if zest.releaser.utils.ask('Do you want to add those commits to the CHANGES file?', True):
                new_history_lines = []
                history_lines, history_encoding = read_text_file(history_file)
                history_lines = history_lines.split('\n')
                for line in history_lines:
                    current_position = history_lines.index(line)
                    new_history_lines.append(line)
                    if line.lower().find('unreleased') != -1:
                        # current_position + 1 == ----------------
                        # current_position + 2 ==   blank
                        # current_position + 3 == - Nothing changed yet.
                        # current_position + 4 ==   blank
                        new_history_lines.append(history_lines[current_position + 1])
                        new_history_lines.append(history_lines[current_position + 2])
                        new_history_lines.extend(pretty_data)
                        new_history_lines.extend(history_lines[current_position + 4:])
                        break

                contents = '\n'.join(new_history_lines)
                write_text_file(history_file, contents)
                msg = 'Update changelog'
                commit_cmd = vcs.cmd_commit(msg)
                commit = execute_command(commit_cmd)
                print(commit)
    else:
        print('History file not found. Skipping.')
开发者ID:codesyntax,项目名称:cs.zestreleaser.changelog,代码行数:51,代码来源:__init__.py


示例6: is_clean_checkout

 def is_clean_checkout(self):
     """Is this a clean checkout?
     """
     head = execute_command('git symbolic-ref --quiet HEAD')
     # This returns something like 'refs/heads/maurits-warn-on-tag'
     # or nothing.  Nothing would be bad as that indicates a
     # detached head: likely a tag checkout
     if not head:
         # Greetings from Nearly Headless Nick.
         return False
     if execute_command('git status --short --untracked-files=no'):
         # Uncommitted changes in files that are tracked.
         return False
     return True
开发者ID:blampe,项目名称:zest.releaser,代码行数:14,代码来源:git.py


示例7: prepare_checkout_dir

 def prepare_checkout_dir(self, prefix):
     # Watch out: some git versions can't clone into an existing
     # directory, even when it is empty.
     temp = tempfile.mkdtemp(prefix=prefix)
     cwd = os.getcwd()
     os.chdir(temp)
     cmd = 'git clone %s %s' % (self.workingdir, 'gitclone')
     logger.debug(execute_command(cmd))
     clonedir = os.path.join(temp, 'gitclone')
     os.chdir(clonedir)
     cmd = 'git submodule update --init --recursive'
     logger.debug(execute_command(cmd))
     os.chdir(cwd)
     return clonedir
开发者ID:blampe,项目名称:zest.releaser,代码行数:14,代码来源:git.py


示例8: prepare_checkout_dir

 def prepare_checkout_dir(self, prefix):
     # Watch out: some git versions can't clone into an existing
     # directory, even when it is empty.
     temp = tempfile.mkdtemp(prefix=prefix)
     cwd = os.getcwd()
     os.chdir(temp)
     cmd = ['git', 'clone', '--depth', '1', self.reporoot, 'gitclone']
     logger.debug(execute_command(cmd))
     clonedir = os.path.join(temp, 'gitclone')
     os.chdir(clonedir)
     cmd = ['git', 'submodule', 'update', '--init', '--recursive']
     logger.debug(execute_command(cmd))
     os.chdir(cwd)
     return clonedir
开发者ID:zestsoftware,项目名称:zest.releaser,代码行数:14,代码来源:git.py


示例9: available_tags

 def available_tags(self):
     tag_info = execute_command('hg tags')
     tags = [line[:line.find(' ')] for line in tag_info.split('\n')]
     tags = [tag for tag in tags if tag]
     tags.remove('tip')  # Not functional for us
     logger.debug("Available tags: %r", tags)
     return tags
开发者ID:blampe,项目名称:zest.releaser,代码行数:7,代码来源:hg.py


示例10: checkout_from_tag

 def checkout_from_tag(self, version):
     package = self.name
     prefix = '%s-%s-' % (package, version)
     tagdir = self.prepare_checkout_dir(prefix)
     os.chdir(tagdir)
     cmd = self.cmd_checkout_from_tag(version, tagdir)
     print(utils.execute_command(cmd))
开发者ID:awello,项目名称:zest.releaser,代码行数:7,代码来源:vcs.py


示例11: get_setup_py_version

 def get_setup_py_version(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted version, like
         # UserWarnings.
         utils.execute_command(utils.setup_py('egg_info'))
         version = utils.execute_command(
             utils.setup_py('--version')).splitlines()[0]
         if 'Traceback' in version:
             # Likely cause is for example forgetting to 'import
             # os' when using 'os' in setup.py.
             logger.critical('The setup.py of this package has an error:')
             print(version)
             logger.critical('No version found.')
             sys.exit(1)
         return utils.strip_version(version)
开发者ID:awello,项目名称:zest.releaser,代码行数:16,代码来源:vcs.py


示例12: is_clean_checkout

 def is_clean_checkout(self):
     """Is this a clean checkout?
     """
     # The --quiet option ignores untracked (unknown and ignored)
     # files, which seems reasonable.
     if execute_command('hg status --quiet'):
         # Local changes.
         return False
     return True
开发者ID:blampe,项目名称:zest.releaser,代码行数:9,代码来源:hg.py


示例13: checkout_from_tag

 def checkout_from_tag(self, version):
     package = self.name
     prefix = '%s-%s-' % (package, version)
     # Not all hg versions can do a checkout in an existing or even
     # just in the current directory.
     tagdir = tempfile.mktemp(prefix=prefix)
     cmd = self.cmd_checkout_from_tag(version, tagdir)
     print(execute_command(cmd))
     os.chdir(tagdir)
开发者ID:blampe,项目名称:zest.releaser,代码行数:9,代码来源:hg.py


示例14: _diff_and_commit

 def _diff_and_commit(self):
     diff_cmd = self.vcs.cmd_diff()
     diff = execute_command(diff_cmd)
     if sys.version.startswith('2.6.2'):
         # python2.6.2 bug... http://bugs.python.org/issue5170 This is the
         # spot it can surface as we show a part of the changelog which can
         # contain every kind of character.  The rest is mostly ascii.
         print("Diff results:")
         print(diff)
     else:
         # Common case
         logger.info("The '%s':\n\n%s\n", diff_cmd, diff)
     if utils.ask("OK to commit this"):
         msg = self.data['commit_msg'] % self.data
         msg = self.update_commit_message(msg)
         commit_cmd = self.vcs.cmd_commit(msg)
         commit = execute_command(commit_cmd)
         logger.info(commit)
开发者ID:awello,项目名称:zest.releaser,代码行数:18,代码来源:prerelease.py


示例15: _svn_info

 def _svn_info(self):
     """Return svn url"""
     our_info = execute_command('svn info')
     if not hasattr(self, '_cached_url'):
         url = [line for line in our_info.split('\n')
                if line.startswith('URL')][0]
         # In English, you have 'URL:', in French 'URL :'
         self._cached_url = url.split(':', 1)[1].strip()
     return self._cached_url
开发者ID:blampe,项目名称:zest.releaser,代码行数:9,代码来源:svn.py


示例16: _info_if_tag_already_exists

 def _info_if_tag_already_exists(self):
     if self.data['tag_already_exists']:
         # Safety feature.
         version = self.data['version']
         tag = self.data['tag']
         q = ("There is already a tag %s, show "
              "if there are differences?" % version)
         if utils.ask(q):
             diff_command = self.vcs.cmd_diff_last_commit_against_tag(tag)
             print(utils.format_command(diff_command))
             print(execute_command(diff_command))
开发者ID:zestsoftware,项目名称:zest.releaser,代码行数:11,代码来源:release.py


示例17: _check_if_tag_already_exists

 def _check_if_tag_already_exists(self):
     """Check if tag already exists and show the difference if so"""
     version = self.data["version"]
     if self.vcs.tag_exists(version):
         self.data["tag_already_exists"] = True
         q = "There is already a tag %s, show " "if there are differences?" % version
         if utils.ask(q):
             diff_command = self.vcs.cmd_diff_last_commit_against_tag(version)
             print(diff_command)
             print(execute_command(diff_command))
     else:
         self.data["tag_already_exists"] = False
开发者ID:zestsoftware,项目名称:zest.releaser,代码行数:12,代码来源:release.py


示例18: translations

def translations(data):
    if data["name"] != "django-countries":
        return

    if not ask("Pull translations from transifex and compile", default=True):
        return

    _handlers = logger.handlers
    logger.handlers = []
    try:
        cmd_pull(argv=["-a", "--minimum-perc=60"], path_to_tx=find_dot_tx())
    finally:
        logger.handlers = _handlers

    _cwd = os.getcwd()
    os.chdir(os.path.dirname(django_countries.__file__))
    try:
        call_command("compilemessages")
        execute_command(["git", "add", "locale"])
    finally:
        os.chdir(_cwd)
开发者ID:SmileyChris,项目名称:django-countries,代码行数:21,代码来源:release.py


示例19: add_files_to_release

def add_files_to_release(data):
    """zest.releaser entry point for adding files to the release."""
    if data.get('name') != 'ploneintranet':
        # This entry point should only do something when releasing the
        # ploneintranet package.
        return
    # cd to the directory that has the fresh tag checkout and use the
    # Makefile to fetch the release bundles.
    logger.info('Making fetchrelease call in tag checkout.')
    res = execute_command('cd {0} && make fetchrelease'.format(data['tagdir']))
    print(res)
    logger.info('fetchrelease done.')
开发者ID:smcmahon,项目名称:ploneintranet,代码行数:12,代码来源:release.py


示例20: _push

    def _push(self):
        """ Offer to push changes, if needed.
        """
        push_cmds = self.vcs.push_commands()
        if not push_cmds:
            return
        if ask("OK to push commits to the server?"):
            if has_extension(self.vcs, 'gitflow'):
                # Push both develop and master branches. First push master,
                # then develop, because that is the branch we want to end on.
                for branch in [
                        self.vcs.gitflow_get_branch("master"),
                        self.vcs.gitflow_get_branch("develop")]:
                    if branch != self.vcs.current_branch():
                        self.vcs.gitflow_switch_to_branch(branch)

                    for push_cmd in push_cmds:
                        output = execute_command(push_cmd)
                        logger.info(output)
            else:
                for push_cmd in push_cmds:
                    output = execute_command(push_cmd)
                    logger.info(output)
开发者ID:virtualsciences,项目名称:egg.releaser,代码行数:23,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.system函数代码示例发布时间:2022-05-26
下一篇:
Python utils.ask函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap