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

Python common.error_out函数代码示例

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

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



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

示例1: _bump_version

    def _bump_version(self, release=False, zstream=False):
        """
        Bump up the package version in the spec file.

        Set release to True to bump the package release instead.

        Checks for the keep version option and if found, won't actually
        bump the version or release.
        """
        old_version = get_latest_tagged_version(self.project_name)
        if old_version == None:
            old_version = "untagged"
        # TODO: Do this here instead of calling out to an external Perl script:
        if not self.keep_version:
            bump_type = "bump-version"
            if release:
                bump_type = "bump-release"
            elif zstream:
                bump_type = "bump-zstream"

            script_path = get_script_path("bump-version.pl")
            cmd = "%s %s --specfile %s" % \
                    (script_path, bump_type, self.spec_file)
            run_command(cmd)

        new_version = self._get_spec_version_and_release()
        if new_version.strip() == "":
            msg = "Error getting bumped package version, try: \n"
            msg = msg + "  'rpm -q --specfile %s'" % self.spec_file
            error_out(msg)
        print("Tagging new version of %s: %s -> %s" % (self.project_name,
            old_version, new_version))
        return new_version
开发者ID:shadowbrain,项目名称:tito,代码行数:33,代码来源:tagger.py


示例2: _bump_version

    def _bump_version(self, release=False, zstream=False):
        """
        Bump up the package version in the spec file.

        Set release to True to bump the package release instead.

        Checks for the keep version option and if found, won't actually
        bump the version or release.
        """
        old_version = get_latest_tagged_version(self.project_name)
        if old_version is None:
            old_version = "untagged"
        if not self.keep_version:
            version_regex = re.compile("^(version:\s*)(.+)$", re.IGNORECASE)
            release_regex = re.compile("^(release:\s*)(.+)$", re.IGNORECASE)

            in_f = open(self.spec_file, 'r')
            out_f = open(self.spec_file + ".new", 'w')

            for line in in_f.readlines():
                version_match = re.match(version_regex, line)
                release_match = re.match(release_regex, line)

                if version_match and not zstream and not release:
                    current_version = version_match.group(2)
                    if hasattr(self, '_use_version'):
                        updated_content = self._use_version
                    else:
                        updated_content = increase_version(current_version)

                    line = "".join([version_match.group(1), updated_content, "\n"])

                elif release_match:
                    current_release = release_match.group(2)
                    if hasattr(self, '_use_release'):
                        updated_content = self._use_release
                    elif release:
                        updated_content = increase_version(current_release)
                    elif zstream:
                        updated_content = increase_zstream(current_release)
                    else:
                        updated_content = reset_release(current_release)

                    line = "".join([release_match.group(1), updated_content, "\n"])

                out_f.write(line)

            in_f.close()
            out_f.close()
            shutil.move(self.spec_file + ".new", self.spec_file)

        new_version = get_spec_version_and_release(self.full_project_dir,
                self.spec_file_name)
        if new_version.strip() == "":
            msg = "Error getting bumped package version, try: \n"
            msg = msg + "  'rpm -q --specfile %s'" % self.spec_file
            error_out(msg)
        info_out("Tagging new version of %s: %s -> %s" % (self.project_name,
            old_version, new_version))
        return new_version
开发者ID:Conan-Kudo,项目名称:tito,代码行数:60,代码来源:main.py


示例3: patch_upstream

    def patch_upstream(self):
        """ Create one patch per each release """
        ch_dir = self.git_root
        if self.relative_project_dir != "/":
            ch_dir = os.path.join(self.git_root,
                    self.relative_project_dir)
        os.chdir(ch_dir)
        debug("Running /usr/bin/generate-patches.pl -d %s %s %s-1 %s %s"
               % (self.rpmbuild_gitcopy, self.project_name, self.upstream_version, self.build_version, self.git_commit_id))
        output = run_command("/usr/bin/generate-patches.pl -d %s %s %s-1 %s %s"
               % (self.rpmbuild_gitcopy, self.project_name, self.upstream_version, self.build_version, self.git_commit_id))
        self.patch_files = output.split("\n")
        for p_file in self.patch_files:
            (status, output) = getstatusoutput(
                "grep 'Binary files .* differ' %s/%s " % (self.rpmbuild_gitcopy, p_file))
            if status == 0 and output != "":
                error_out("You are doomed. Diff contains binary files. You can not use this builder")

            run_command("cp %s/%s %s" % (self.rpmbuild_gitcopy, p_file, self.rpmbuild_sourcedir))

        (patch_number, patch_insert_index, patch_apply_index, lines) = self._patch_upstream()

        for patch in self.patch_files:
            lines.insert(patch_insert_index, "Patch%s: %s\n" % (patch_number, patch))
            lines.insert(patch_apply_index, "%%patch%s -p1\n" % (patch_number))
            patch_number += 1
            patch_insert_index += 1
            patch_apply_index += 2
        self._write_spec(lines)
开发者ID:CiscoSystems,项目名称:tito,代码行数:29,代码来源:distributionbuilder.py


示例4: _get_build_version

    def _get_build_version(self):
        """
        Figure out the git tag and version-release we're building.
        """
        # Determine which package version we should build:
        build_version = None
        if self.build_tag:
            build_version = self.build_tag[len(self.project_name + "-"):]
        else:
            build_version = get_latest_tagged_version(self.project_name)
            if build_version is None:
                if not self.test:
                    error_out(["Unable to lookup latest package info.",
                            "Perhaps you need to tag first?"])
                warn_out("unable to lookup latest package "
                    "tag, building untagged test project")
                build_version = get_spec_version_and_release(self.start_dir,
                    find_spec_like_file(self.start_dir))
            self.build_tag = "%s-%s" % (self.project_name, build_version)

        self.spec_version = build_version.split('-')[-2]
        self.spec_release = build_version.split('-')[-1]
        if not self.test:
            check_tag_exists(self.build_tag, offline=self.offline)
        return build_version
开发者ID:maxamillion,项目名称:tito,代码行数:25,代码来源:main.py


示例5: _build

    def _build(self, branch):
        """ Submit a Fedora build from current directory. """
        target_param = ""
        scratch_param = ""
        build_target = self._get_build_target_for_branch(branch)
        if build_target:
            target_param = "--target %s" % build_target
        if self.scratch:
            scratch_param = "--scratch"

        build_cmd = "%s build --nowait %s %s" % (self.cli_tool, scratch_param, target_param)

        if self.dry_run:
            self.print_dry_run_warning(build_cmd)
            return

        info_out("Submitting build: %s" % build_cmd)
        (status, output) = getstatusoutput(build_cmd)
        if status > 0:
            if "already been built" in output:
                warn_out("Build has been submitted previously, continuing...")
            else:
                error_out([
                    "Unable to submit build."
                    "  Status code: %s\n" % status,
                    "  Output: %s\n" % output,
                ])

        # Print the task ID and URL:
        for line in extract_task_info(output):
            print(line)
开发者ID:Conan-Kudo,项目名称:tito,代码行数:31,代码来源:distgit.py


示例6: main

    def main(self):
        BaseCliModule.main(self)

        if self.global_config.has_option(GLOBALCONFIG_SECTION,
                "block_tagging"):
            debug("block_tagging defined in tito.props")
            error_out("Tagging has been disabled in this git branch.")

        build_dir = os.path.normpath(os.path.abspath(self.options.output_dir))
        package_name = get_project_name(tag=None)

        self.pkg_config = self._read_project_config(package_name, build_dir,
                None, None)

        tagger_class = None
        if self.pkg_config.has_option("buildconfig", "tagger"):
            tagger_class = get_class_by_name(self.pkg_config.get("buildconfig",
                "tagger"))
        else:
            tagger_class = get_class_by_name(self.global_config.get(
                GLOBALCONFIG_SECTION, DEFAULT_TAGGER))
        debug("Using tagger class: %s" % tagger_class)

        tagger = tagger_class(global_config=self.global_config,
                keep_version=self.options.keep_version)
        tagger.run(self.options)
开发者ID:jsabo,项目名称:tito,代码行数:26,代码来源:cli.py


示例7: _read_global_config

    def _read_global_config(self):
        """
        Read global build.py configuration from the rel-eng dir of the git
        repository we're being run from.
        """
        rel_eng_dir = os.path.join(find_git_root(), "rel-eng")
        filename = os.path.join(rel_eng_dir, GLOBAL_BUILD_PROPS_FILENAME)
        if not os.path.exists(filename):
            # HACK: Try the old filename location, pre-tito rename:
            oldfilename = os.path.join(rel_eng_dir, "global.build.py.props")
            if not os.path.exists(oldfilename):
                error_out("Unable to locate branch configuration: %s"
                    "\nPlease run 'tito init'" % filename)
        config = ConfigParser.ConfigParser()
        config.read(filename)

        # Verify the config contains what we need from it:
        required_global_config = [
                (GLOBALCONFIG_SECTION, DEFAULT_BUILDER),
                (GLOBALCONFIG_SECTION, DEFAULT_TAGGER),
        ]
        for section, option in required_global_config:
            if not config.has_section(section) or not \
                config.has_option(section, option):
                    error_out("%s missing required config: %s %s" % (
                        filename, section, option))

        return config
开发者ID:jsabo,项目名称:tito,代码行数:28,代码来源:cli.py


示例8: main

    def main(self, argv):
        BaseCliModule.main(self, argv)

        build_dir = os.path.normpath(os.path.abspath(self.options.output_dir))
        package_name = get_project_name(tag=None)

        self.load_config(package_name, build_dir, None)
        if self.config.has_option(BUILDCONFIG_SECTION,
                "block_tagging"):
            debug("block_tagging defined in tito.props")
            error_out("Tagging has been disabled in this git branch.")

        tagger_class = get_class_by_name(self.config.get(
            BUILDCONFIG_SECTION, DEFAULT_TAGGER))
        debug("Using tagger class: %s" % tagger_class)

        tagger = tagger_class(config=self.config,
                user_config=self.user_config,
                keep_version=self.options.keep_version,
                offline=self.options.offline)

        try:
            return tagger.run(self.options)
        except TitoException:
            e = sys.exc_info()[1]
            error_out(e.message)
开发者ID:Conan-Kudo,项目名称:tito,代码行数:26,代码来源:cli.py


示例9: _setup_sources

    def _setup_sources(self):
        super(GitAnnexBuilder, self)._setup_sources()

        old_cwd = os.getcwd()
        os.chdir(os.path.join(old_cwd, self.relative_project_dir))

        # NOTE: 'which' may not be installed... (docker containers)
        (status, output) = getstatusoutput("which git-annex")
        if status != 0:
            msg = "Please run '%s install git-annex' as root." % package_manager()
            error_out('%s' % msg)

        run_command("git-annex lock")
        annexed_files = run_command("git-annex find --include='*'").splitlines()
        run_command("git-annex get")
        run_command("git-annex unlock")
        debug("  Annex files: %s" % annexed_files)

        for annex in annexed_files:
            debug("Copying unlocked file %s" % annex)
            os.remove(os.path.join(self.rpmbuild_gitcopy, annex))
            shutil.copy(annex, self.rpmbuild_gitcopy)

        self._lock()
        os.chdir(old_cwd)
开发者ID:maxamillion,项目名称:tito,代码行数:25,代码来源:main.py


示例10: _validate_options

    def _validate_options(self):

        if self.options.all and self.options.all_starting_with:
            error_out("Cannot combine --all and --all-starting-with.")

        if (self.options.all or self.options.all_starting_with) and \
                len(self.args) > 1:
            error_out("Cannot use explicit release targets with "
                    "--all or --all-starting-with.")
开发者ID:Conan-Kudo,项目名称:tito,代码行数:9,代码来源:cli.py


示例11: _check_build_dirs_access

 def _check_build_dirs_access(self, build_dirs):
     """
     Ensure the build directories are writable.
     """
     msgs = []
     for d in build_dirs:
         if not os.access(d, os.W_OK):
             msgs.append("%s is not writable." % d)
     if msgs:
         error_out(msgs)
开发者ID:maxamillion,项目名称:tito,代码行数:10,代码来源:main.py


示例12: _check_required_config

 def _check_required_config(self, config):
     # Verify the config contains what we need from it:
     required_global_config = [
         (BUILDCONFIG_SECTION, DEFAULT_BUILDER),
         (BUILDCONFIG_SECTION, DEFAULT_TAGGER),
     ]
     for section, option in required_global_config:
         if not config.has_section(section) or not \
             config.has_option(section, option):
                 error_out("tito.props missing required config: %s %s" % (
                     section, option))
开发者ID:Conan-Kudo,项目名称:tito,代码行数:11,代码来源:cli.py


示例13: _check_releaser_config

 def _check_releaser_config(self):
     """
     Verify this release target has all the config options it needs.
     """
     for opt in self.GLOBAL_REQUIRED_CONFIG:
         if not self.releaser_config.has_option(self.target, opt):
             error_out("Release target '%s' missing required option '%s'" %
                 (self.target, opt))
     for opt in self.REQUIRED_CONFIG:
         if not self.releaser_config.has_option(self.target, opt):
             error_out("Release target '%s' missing required option '%s'" %
                 (self.target, opt))
开发者ID:awood,项目名称:tito,代码行数:12,代码来源:main.py


示例14: _check_releaser_config

 def _check_releaser_config(self):
     """
     Verify this release target has all the config options it needs.
     """
     if self.releaser_config.has_option(self.target, "remote_location"):
         self.remote_location = self.releaser_config.get(self.target, "remote_location")
     elif 'COPR_REMOTE_LOCATION' in self.user_config:
         self.remote_location = self.user_config['COPR_REMOTE_LOCATION']
     else:
         error_out(["No remote location for Copr SRPMs found.",
             "Either define 'remote_location' in the releaser configuration "
             "or 'COPR_REMOTE_LOCATION' in ~/.titorc"])
     KojiReleaser._check_releaser_config(self)
开发者ID:Allda,项目名称:tito,代码行数:13,代码来源:copr.py


示例15: _confirm_commit_msg

    def _confirm_commit_msg(self, diff_output):
        """
        Generates a commit message in a temporary file, gives the user a
        chance to edit it, and returns the filename to the caller.
        """

        fd, name = tempfile.mkstemp()
        debug("Storing commit message in temp file: %s" % name)
        write(fd, "Update %s to %s\n" % (self.project_name,
            self.builder.build_version))
        # Write out Resolves line for all bugzillas we see in commit diff:
        # TODO: move to DistGitBuilder only?
        try:
            (required_bz_flags, placeholder_bz) = self._get_bz_flags()
            extractor = BugzillaExtractor(diff_output,
                required_flags=required_bz_flags,
                placeholder_bz=placeholder_bz)
            for line in extractor.extract():
                write(fd, line + "\n")
        except MissingBugzillaCredsException:
            error_out([
                "Releaser specifies required flags but you have not configured",
                "a ~/.bugzillarc with your bugzilla credentials.",
                "Example:",
                "",
                "[bugzilla.redhat.com]",
                "user = [email protected]",
                "password = mypassword"])

        print("")
        print("##### Commit message: #####")
        print("")

        os.lseek(fd, 0, 0)
        f = os.fdopen(fd)
        for line in f.readlines():
            print(line)
        f.close()

        print("")
        print("###############################")
        print("")
        if self._ask_yes_no("Would you like to edit this commit message? [y/n] ", False):
            debug("Opening editor for user to edit commit message in: %s" % name)
            editor = 'vi'
            if "EDITOR" in os.environ:
                editor = os.environ["EDITOR"]
            subprocess.call(editor.split() + [name])

        return name
开发者ID:Conan-Kudo,项目名称:tito,代码行数:50,代码来源:distgit.py


示例16: _validate_options

    def _validate_options(self):
        if self.options.srpm and self.options.rpm:
            error_out("Cannot combine --srpm and --rpm")
        if self.options.test and self.options.tag:
            error_out("Cannot build test version of specific tag.")
        if (self.options.srpm or self.options.rpm) and self.options.release:
            error_out("Cannot combine --srpm/--rpm with --release.")

        if self.options.release and (self.options.cvs_release or
                self.options.koji_release):
            error_out([
                "Cannot combine --cvs-release/--koji-release with --release.",
                "(--release includes both)"])
        if self.options.release and self.options.test:
            error_out("Cannot combine --release with --test.")
开发者ID:jsabo,项目名称:tito,代码行数:15,代码来源:cli.py


示例17: _bump_version

 def _bump_version(self):
     """
     Bump the version unless VERSION_AND_RELEASE specified
     in the environment.  When specified, both the version and
     release are forced as specified.
     VERSION_AND_RELEASE must be VR part of NEVRA
       Eg: 2.0.1-0.1.alpha
     """
     version = os.environ.get(VERSION_AND_RELEASE)
     if version:
         parts = version.rsplit('-', 1)
         if len(parts) != 2:
             error_out('"%s" not valid' % version)
         self.__update_spec(*parts)
         return version
     else:
         return VersionTagger._bump_version(self)
开发者ID:ATIX-AG,项目名称:pulp_rpm,代码行数:17,代码来源:pulptagger.py


示例18: _sync_mead_scm

    def _sync_mead_scm(self):
        cmd = "git push %s %s" % (self.push_url, self.builder.build_tag)

        if self.dry_run:
            self.print_dry_run_warning(cmd)
            return

        with chdir(self.git_root):
            info_out("Syncing local repo with %s" % self.push_url)
            try:
                run_command(cmd)
            except RunCommandException as e:
                if "rejected" in e.output:
                    if self._ask_yes_no("The remote rejected a push.  Force push? [y/n] ", False):
                        run_command("git push --force %s %s" % (self.mead_scm, self.builder.build_tag))
                    else:
                        error_out("Could not sync with %s" % self.mead_scm)
                raise
开发者ID:Conan-Kudo,项目名称:tito,代码行数:18,代码来源:distgit.py


示例19: _get_version

    def _get_version(self):
        """
        Get the version from the builder.
        Sources are configured at this point.
        """
        # Assuming source0 is a tar.gz we can extract a version from:
        base_name = os.path.basename(self.sources[0])
        debug("Extracting version from: %s" % base_name)

        # Example filename: tito-0.4.18.tar.gz:
        simple_version_re = re.compile(".*-(.*).(tar.gz|tgz|zip|tar.bz2|gem)")
        match = re.search(simple_version_re, base_name)
        if match:
            version = match.group(1)
        else:
            error_out("Unable to determine version from file: %s" % base_name)

        return version
开发者ID:ares,项目名称:katello-packaging,代码行数:18,代码来源:custom.py


示例20: _check_build_dirs_access

 def _check_build_dirs_access(self):
     """
     Ensure the build directories are writable.
     """
     if not os.access(self.rpmbuild_basedir, os.W_OK):
         error_out("%s is not writable." % self.rpmbuild_basedir)
     if not os.access(self.rpmbuild_dir, os.W_OK):
         error_out("%s is not writable." % self.rpmbuild_dir)
     if not os.access(self.rpmbuild_sourcedir, os.W_OK):
         error_out("%s is not writable." % self.rpmbuild_sourcedir)
     if not os.access(self.rpmbuild_builddir, os.W_OK):
         error_out("%s is not writable." % self.rpmbuild_builddir)
开发者ID:CiscoSystems,项目名称:tito,代码行数:12,代码来源:main.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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