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


Python common.debug函数代码示例

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


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

示例1: 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

示例2: tag_new_version

    def tag_new_version(project_path, new_version_release):
        """
        Find the line with version number  and change
        it to contain the new version.
        """
        file_name = "Cargo.toml"
        config_file = os.path.join(project_path, file_name)

        if not os.path.exists(config_file):
            debug('Cargo.toml file not found, this is probably not a Rust project')
            return

        debug("Found Cargo.toml file, attempting to update the version.")
        # We probably don't want version-release in config file as
        # release is an RPM concept
        new_version = new_version_release.split('-')[0]
        file_buffer = []

        # Read file line by line and replace version when found
        with open(config_file, 'r') as cfgfile:
            file_buffer = CargoBump.process_cargo_toml(cfgfile, new_version)

        # Write the buffer back into the file
        with open(config_file, 'w') as cfgfile:
            cfgfile.writelines(map(lambda x: x + "\n", file_buffer))

        # Add Cargo.toml into git index
        run_command("git add %s" % file_name)
开发者ID:Conan-Kudo,项目名称:tito,代码行数:28,代码来源:cargobump.py

示例3: load_config

    def load_config(self, package_name, build_dir, tag):
        self.config = ConfigLoader(package_name, build_dir, tag).load()

        if self.config.has_option(BUILDCONFIG_SECTION,
                "offline"):
            self.options.offline = True

        # TODO: Not ideal:
        if self.options.debug:
            os.environ['DEBUG'] = "true"

        # Check if config defines a custom lib dir, if so we add it
        # to the python path allowing users to specify custom builders/taggers
        # in their config:
        if self.config.has_option(BUILDCONFIG_SECTION,
                "lib_dir"):
            lib_dir = self.config.get(BUILDCONFIG_SECTION,
                    "lib_dir")
            if lib_dir[0] != '/':
                # Looks like a relative path, assume from the git root:
                lib_dir = os.path.join(find_git_root(), lib_dir)

            if os.path.exists(lib_dir):
                sys.path.append(lib_dir)
                debug("Added lib dir to PYTHONPATH: %s" % lib_dir)
            else:
                warn_out("lib_dir specified but does not exist: %s" % lib_dir)
开发者ID:Conan-Kudo,项目名称:tito,代码行数:27,代码来源:cli.py

示例4: _update_setup_py

    def _update_setup_py(self, new_version):
        """
        If this project has a setup.py, attempt to update it's version.
        """
        setup_file = os.path.join(self.full_project_dir, "setup.py")
        if not os.path.exists(setup_file):
            return

        debug("Found setup.py, attempting to update version.")

        # We probably don't want version-release in setup.py as release is
        # an rpm concept. Hopefully this assumption on
        py_new_version = new_version.split('-')[0]

        f = open(setup_file, 'r')
        buf = StringIO.StringIO()
        for line in f.readlines():
            buf.write(replace_version(line, py_new_version))
        f.close()

        # Write out the new setup.py file contents:
        f = open(setup_file, 'w')
        f.write(buf.getvalue())
        f.close()
        buf.close()

        run_command("git add %s" % setup_file)
开发者ID:aronparsons,项目名称:tito,代码行数:27,代码来源:tagger.py

示例5: _git_sync_files

    def _git_sync_files(self, project_checkout):
        """
        Copy files from our git into each git build branch and add them.

        A list of safe files is used to protect critical files both from
        being overwritten by a git file of the same name, as well as being
        deleted after.
        """

        # Build the list of all files we will copy:
        debug("Searching for files to copy to build system git:")
        files_to_copy = self._list_files_to_copy()

        os.chdir(project_checkout)

        new, copied, old =  \
                self._sync_files(files_to_copy, project_checkout)

        os.chdir(project_checkout)

        # Git add everything:
        for add_file in (new + copied):
            run_command("git add %s" % add_file)

        # Cleanup obsolete files:
        for cleanup_file in old:
            # Can't delete via full path, must not chdir:
            run_command("git rm %s" % cleanup_file)
开发者ID:Conan-Kudo,项目名称:tito,代码行数:28,代码来源:distgit.py

示例6: 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

示例7: _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)
        os.write(fd, "Update %s to %s\n" % (self.obs_package_name,
            self.builder.build_version))
        # Write out Resolves line for all bugzillas we see in commit diff:
        for line in extract_bzs(diff_output):
            os.write(fd, line + "\n")

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

        os.lseek(fd, 0, 0)
        commit_file = os.fdopen(fd)
        for line in commit_file.readlines():
            print line
        commit_file.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:amitsaha,项目名称:tito,代码行数:35,代码来源:obs.py

示例8: _fetch_local

    def _fetch_local(self):
        source_dir = os.path.expanduser(self.builder.args['source_dir'][0])

        old_dir = os.getcwd()
        os.chdir(source_dir)

        gemspecs = glob.glob("./*.gemspec")
        if gemspecs and not gemspecs[0] == "./smart_proxy.gemspec":
          subprocess.call(["gem", "build", gemspecs[0]])
          sources = glob.glob("./*.gem")
        else:
          subprocess.call(["/bin/bash", "-l", "-c", "rake pkg:generate_source"])
          sources = glob.glob("./pkg/*")

        fetchdir = os.path.join(self.builder.rpmbuild_sourcedir, 'archive')
        if not os.path.exists(fetchdir):
          os.mkdir(fetchdir)

        for srcfile in sources:
          debug("Copying %s from local source dir" % srcfile)
          shutil.move(srcfile, os.path.join(fetchdir, os.path.basename(srcfile)))

        gitrev = "local"
        gitsha = subprocess.check_output(["git", "rev-parse", "HEAD"])
        if gitsha:
          gitrev = "git%s" % gitsha[0:7]

        os.chdir(old_dir)

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

示例9: 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

示例10: _create_builder

    def _create_builder(self, package_name, build_tag, build_version, options,
            pkg_config, build_dir):
        """
        Create (but don't run) the builder class. Builder object may be
        used by other objects without actually having run() called.
        """

        builder_class = None
        if pkg_config.has_option("buildconfig", "builder"):
            builder_class = get_class_by_name(pkg_config.get("buildconfig",
                "builder"))
        else:
            builder_class = get_class_by_name(self.global_config.get(
                GLOBALCONFIG_SECTION, DEFAULT_BUILDER))
        debug("Using builder class: %s" % builder_class)

        # Instantiate the builder:
        builder = builder_class(
                name=package_name,
                version=build_version,
                tag=build_tag,
                build_dir=build_dir,
                pkg_config=pkg_config,
                global_config=self.global_config,
                user_config=self.user_config,
                dist=options.dist,
                test=options.test,
                offline=options.offline,
                auto_install=options.auto_install)
        return builder
开发者ID:jsabo,项目名称:tito,代码行数:30,代码来源:cli.py

示例11: _update_setup_py_in_dir

    def _update_setup_py_in_dir(self, new_version, package_dir=None):
        """
        If this subdir has a setup.py, attempt to update it's version.
        (This is a very minor tweak to the original _update_setup_py method from VersionTagger
        """

        if package_dir is not None:
            full_package_dir = os.path.join(self.full_project_dir, package_dir)
        else:
            full_package_dir = self.full_project_dir

        setup_file = os.path.join(full_package_dir, "setup.py")
        if not os.path.exists(setup_file):
            return

        debug("Found setup.py in {}, attempting to update version.".format(package_dir))

        # We probably don't want version-release in setup.py as release is
        # an rpm concept. Hopefully this assumption on
        py_new_version = new_version.split('-')[0]

        f = open(setup_file, 'r')
        buf = six.StringIO()
        for line in f.readlines():
            buf.write(replace_version(line, py_new_version))
        f.close()

        # Write out the new setup.py file contents:
        f = open(setup_file, 'w')
        f.write(buf.getvalue())
        f.close()
        buf.close()

        run_command("git add %s" % setup_file)
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:34,代码来源:rhsmtagger.py

示例12: main

    def main(self, argv):
        (self.options, args) = self.parser.parse_args(argv)

        self._validate_options()

        if len(argv) < 1:
            print(self.parser.error("Must supply an argument. "
                "Try -h for help."))

        self.global_config = self._read_global_config()
        if self.global_config.has_option(GLOBALCONFIG_SECTION,
                "offline"):
            self.options.offline = True

        if self.options.debug:
            os.environ['DEBUG'] = "true"

        # Check if global config defines a custom lib dir:
        if self.global_config.has_option(GLOBALCONFIG_SECTION,
                "lib_dir"):
            lib_dir = self.global_config.get(GLOBALCONFIG_SECTION, 
                    "lib_dir")
            if lib_dir[0] != '/':
                # Looks like a relative path, assume from the git root:
                lib_dir = os.path.join(find_git_root(), lib_dir)

            if os.path.exists(lib_dir):
                sys.path.append(lib_dir)
                debug("Added lib dir to PYTHONPATH: %s" % lib_dir)
            else:
                print("WARNING: lib_dir specified but does not exist: %s" %
                        lib_dir)
开发者ID:xsuchy,项目名称:tito,代码行数:32,代码来源:cli.py

示例13: _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

示例14: process_packages

 def process_packages(self, temp_dir):
     self.prune_other_versions(temp_dir)
     print("Refreshing yum repodata...")
     if self.releaser_config.has_option(self.target, 'createrepo_command'):
         self.createrepo_command = self.releaser_config.get(self.target, 'createrepo_command')
     os.chdir(temp_dir)
     output = run_command(self.createrepo_command)
     debug(output)
开发者ID:awood,项目名称:tito,代码行数:8,代码来源:main.py

示例15: cleanup

 def cleanup(self):
     """
     Remove all temporary files and directories.
     """
     if not self.no_cleanup:
         debug("Cleaning up %s" % self.rpmbuild_dir)
         shutil.rmtree(self.rpmbuild_dir)
     else:
         warn_out("Leaving rpmbuild files in: %s" % self.rpmbuild_dir)
开发者ID:maxamillion,项目名称:tito,代码行数:9,代码来源:main.py


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