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


Python PathHelper.find_first_file方法代码示例

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


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

示例1: _do_build_srpm

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
    def _do_build_srpm(cls, spec, workdir, results_dir):
        """
        Build SRPM using rpmbuild.

        :param spec: abs path to SPEC file inside the rpmbuild/SPECS in workdir.
        :param workdir: abs path to working directory with rpmbuild directory
                        structure, which will be used as HOME dir.
        :param results_dir: abs path to dir where the log should be placed.
        :return: If build process ends successfully returns abs path
                 to built SRPM, otherwise 'None'.
        """
        logger.info("Building SRPM")
        spec_loc, spec_name = os.path.split(spec)
        output = os.path.join(results_dir, "build.log")

        cmd = ['rpmbuild', '-bs', spec_name]
        ret = ProcessHelper.run_subprocess_cwd_env(cmd,
                                                   cwd=spec_loc,
                                                   env={'HOME': workdir},
                                                   output=output)

        if ret != 0:
            return None
        else:
            return PathHelper.find_first_file(workdir, '*.src.rpm')
开发者ID:jhornice,项目名称:rebase-helper,代码行数:27,代码来源:build_helper.py

示例2: _get_spec_file

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
 def _get_spec_file(self):
     """
     Function gets the spec file from the execution_dir directory
     """
     self.spec_file_path = PathHelper.find_first_file(self.execution_dir, '*.spec', 0)
     if not self.spec_file_path:
         raise RebaseHelperError("Could not find any SPEC file in the current directory '%s'", self.execution_dir)
开发者ID:hhorak,项目名称:rebase-helper,代码行数:9,代码来源:application.py

示例3: build

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
    def build(cls, spec, sources, patches, results_dir, root=None, arch=None, **kwargs):
        """
        Builds the SRPM and RPM using mock

        :param spec: absolute path to a SPEC file
        :param sources: list with absolute paths to SOURCES
        :param patches: list with absolute paths to PATCHES
        :param results_dir: absolute path to directory where results will be stored
        :param root: mock root used for building
        :param arch: architecture to build the RPM for
        :return: dict with:
                 'srpm' -> absolute path to SRPM
                 'rpm' -> list with absolute paths to RPMs
                 'logs' -> list with absolute paths to logs
        """
        # build SRPM
        srpm, cls.logs = cls._build_srpm(spec, sources, patches, results_dir)

        # build RPMs
        rpm_results_dir = os.path.join(results_dir, "RPM")
        with MockTemporaryEnvironment(sources, patches, spec, rpm_results_dir) as tmp_env:
            env = tmp_env.env()
            tmp_results_dir = env.get(MockTemporaryEnvironment.TEMPDIR_RESULTS)
            rpms = cls._build_rpm(srpm, tmp_results_dir)
            # remove SRPM - side product of building RPM
            tmp_srpm = PathHelper.find_first_file(tmp_results_dir, "*.src.rpm")
            if tmp_srpm is not None:
                os.unlink(tmp_srpm)

        if rpms is None:
            # We need to be inform what directory to analyze and what spec file failed
            cls.logs.extend([l for l in PathHelper.find_all_files(rpm_results_dir, '*.log')])
            raise BinaryPackageBuildError("Building RPMs failed!", rpm_results_dir, spec)
        else:
            logger.info("Building RPMs finished successfully")

        rpms = [os.path.join(rpm_results_dir, os.path.basename(f)) for f in rpms]
        logger.debug("Successfully built RPMs: '%s'", str(rpms))

        # gather logs
        cls.logs.extend([l for l in PathHelper.find_all_files(rpm_results_dir, '*.log')])
        logger.debug("logs: '%s'", str(cls.logs))

        return {'srpm': srpm,
                'rpm': rpms,
                'logs': cls.logs}
开发者ID:jhornice,项目名称:rebase-helper,代码行数:48,代码来源:build_helper.py

示例4: _build_srpm

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
    def _build_srpm(cls, spec, sources, results_dir, root=None, arch=None):
        """Build SRPM using mock."""
        logger.info("Building SRPM")
        output = os.path.join(results_dir, "mock_output.log")

        cmd = [cls.CMD, '--buildsrpm', '--spec', spec, '--sources', sources,
               '--resultdir', results_dir]
        if root is not None:
            cmd.extend(['--root', root])
        if arch is not None:
            cmd.extend(['--arch', arch])

        ret = ProcessHelper.run_subprocess(cmd, output=output)
        if ret != 0:
            return None
        else:
            return PathHelper.find_first_file(results_dir, '*.src.rpm')
开发者ID:praiskup,项目名称:rebase-helper,代码行数:19,代码来源:build_helper.py

示例5: test_find_without_recursion

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
 def test_find_without_recursion(self):
     assert PathHelper.find_first_file(os.path.curdir, "*.spec") == os.path.abspath(self.files[-1])
开发者ID:rebase-helper,项目名称:rebase-helper,代码行数:4,代码来源:test_utils.py

示例6: test_find_with_recursion

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
 def test_find_with_recursion(self):
     assert PathHelper.find_first_file(os.path.curdir, "*.spec", 0) is None
     assert PathHelper.find_first_file(os.path.curdir, "*.spec", 1) is None
     assert PathHelper.find_first_file(os.path.curdir, "*.spec", 2) is None
     assert PathHelper.find_first_file(os.path.curdir, "*.spec", 3) is None
     assert PathHelper.find_first_file(os.path.curdir, "*.spec", 4) == os.path.abspath(self.files[-1])
开发者ID:rebase-helper,项目名称:rebase-helper,代码行数:8,代码来源:test_utils.py

示例7: test_find_pythoon

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
 def test_find_pythoon(self):
     assert PathHelper.find_first_file("dir1", "pythooon") == os.path.abspath(self.files[4])
     assert PathHelper.find_first_file(os.path.curdir, "py*n") == os.path.abspath(self.files[4])
     assert PathHelper.find_first_file("dir1/bar", "pythooon") is None
开发者ID:rebase-helper,项目名称:rebase-helper,代码行数:6,代码来源:test_utils.py

示例8: test_find_ffile

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
 def test_find_ffile(self):
     assert PathHelper.find_first_file("dir1", "*le") == os.path.abspath(self.files[9])
     assert PathHelper.find_first_file("dir1", "ff*") == os.path.abspath(self.files[8])
     assert PathHelper.find_first_file("dir1/foo", "ff*") is None
开发者ID:rebase-helper,项目名称:rebase-helper,代码行数:6,代码来源:test_utils.py

示例9: test_find_file

# 需要导入模块: from rebasehelper.utils import PathHelper [as 别名]
# 或者: from rebasehelper.utils.PathHelper import find_first_file [as 别名]
 def test_find_file(self):
     assert PathHelper.find_first_file("dir1", "file") == os.path.abspath(self.files[9])
     assert PathHelper.find_first_file(os.path.curdir, "file") == os.path.abspath(self.files[0])
     assert PathHelper.find_first_file("dir1/baz", "file") is None
开发者ID:rebase-helper,项目名称:rebase-helper,代码行数:6,代码来源:test_utils.py


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