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


Python osutils.ensure_dirs函数代码示例

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


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

示例1: test_mode

 def test_mode(self):
     path = pjoin(self.dir, 'mode', 'mode')
     assert osutils.ensure_dirs(path, mode=0o700)
     self.check_dir(path, os.geteuid(), os.getegid(), 0o700)
     # unrestrict it
     osutils.ensure_dirs(path)
     self.check_dir(path, os.geteuid(), os.getegid(), 0o777)
开发者ID:radhermit,项目名称:snakeoil,代码行数:7,代码来源:test_osutils.py

示例2: mk_tree

 def mk_tree(self, path, *args, **kwds):
     eclasses = kwds.pop('eclass_cache', None)
     if eclasses is None:
         epath = pjoin(path, 'eclass')
         ensure_dirs(epath)
         eclasses = eclass_cache.cache(epath)
     return repository._UnconfiguredTree(path, eclasses, *args, **kwds)
开发者ID:neko259,项目名称:pkgcore,代码行数:7,代码来源:test_repository.py

示例3: test_licenses

 def test_licenses(self):
     licenses = ('GPL-2', 'GPL-3+', 'BSD')
     ensure_dirs(pjoin(self.dir, 'licenses'))
     for license in licenses:
         touch(pjoin(self.dir, 'licenses', license))
     repo = self.mk_tree(self.dir)
     self.assertEqual(sorted(repo.licenses), sorted(licenses))
开发者ID:radhermit,项目名称:pkgcore,代码行数:7,代码来源:test_repository.py

示例4: nofetch

    def nofetch(self):
        """Execute the nofetch phase.

        We need the same prerequisites as setup, so reuse that.
        """
        ensure_dirs(self.env["T"], mode=0o770, gid=portage_gid, minimal=True)
        return setup_mixin.setup(self, "nofetch")
开发者ID:radhermit,项目名称:pkgcore,代码行数:7,代码来源:ebd.py

示例5: test_create_unwritable_subdir

 def test_create_unwritable_subdir(self):
     path = pjoin(self.dir, 'restricted', 'restricted')
     # create the subdirs without 020 first
     assert osutils.ensure_dirs(os.path.dirname(path))
     assert osutils.ensure_dirs(path, mode=0o020)
     self.check_dir(path, os.geteuid(), os.getegid(), 0o020)
     # unrestrict it
     osutils.ensure_dirs(path)
     self.check_dir(path, os.geteuid(), os.getegid(), 0o777)
开发者ID:radhermit,项目名称:snakeoil,代码行数:9,代码来源:test_osutils.py

示例6: setUp

    def setUp(self):
        TempDirMixin.setUp(self)
        self.pdir = pjoin(self.dir, 'profiles')
        ensure_dirs(self.pdir)

        # silence missing masters warnings
        ensure_dirs(pjoin(self.dir, 'metadata'))
        with open(pjoin(self.dir, 'metadata', 'layout.conf'), 'w') as f:
            f.write('masters =\n')
开发者ID:radhermit,项目名称:pkgcore,代码行数:9,代码来源:test_repository.py

示例7: trigger

 def trigger(self, engine, cset):
     pkg = engine.new
     filename = "%s_%s%s.deb" % (pkg.package, pkg.version, self.postfix)
     tmp_path = pjoin(engine.tempdir, filename)
     final_path = pjoin(self.basepath, filename)
     ensure_dirs(tmp_path)
     deb.write(tmp_path, final_path, pkg,
         cset=cset,
         platform=self.platform, maintainer=self.maintainer)
开发者ID:den4ix,项目名称:pkgcore,代码行数:9,代码来源:triggers.py

示例8: test_repo_id

 def test_repo_id(self):
     dir1 = pjoin(self.dir, '1')
     os.mkdir(dir1, 0755)
     repo = self.mk_tree(dir1)
     self.assertEqual(repo.repo_id, '<unlabeled repository %s>' % (dir1,))
     dir2 = pjoin(self.dir, '2')
     osutils.ensure_dirs(pjoin(dir2, 'profiles'))
     open(pjoin(dir2, 'profiles', 'repo_name'), 'w').write('testrepo\n')
     repo = self.mk_tree(dir2)
     self.assertEqual('testrepo', repo.repo_id)
开发者ID:veelai,项目名称:pkgcore,代码行数:10,代码来源:test_repository.py

示例9: test_repo_id

 def test_repo_id(self):
     dir1 = pjoin(self.dir, '1')
     os.mkdir(dir1, 0o755)
     repo = self.mk_tree(dir1)
     self.assertEqual(repo.repo_id, f'<unlabeled repo: {dir1!r}>')
     dir2 = pjoin(self.dir, '2')
     ensure_dirs(pjoin(dir2, 'profiles'))
     with open(pjoin(dir2, 'profiles', 'repo_name'), 'w') as f:
         f.write('testrepo\n')
     repo = self.mk_tree(dir2)
     self.assertEqual('testrepo', repo.repo_id)
开发者ID:radhermit,项目名称:pkgcore,代码行数:11,代码来源:test_repository.py

示例10: test_mkdir_failing

    def test_mkdir_failing(self):
        # fail if os.mkdir fails
        with mock.patch('snakeoil.osutils.os.mkdir') as mkdir:
            mkdir.side_effect = OSError(30, 'Read-only file system')
            path = pjoin(self.dir, 'dir')
            assert not osutils.ensure_dirs(path, mode=0o700)

            # force temp perms
            assert not osutils.ensure_dirs(path, mode=0o400)
            mkdir.side_effect = OSError(17, 'File exists')
            assert not osutils.ensure_dirs(path, mode=0o700)
开发者ID:radhermit,项目名称:snakeoil,代码行数:11,代码来源:test_osutils.py

示例11: test_categories_packages

    def test_categories_packages(self):
        ensure_dirs(pjoin(self.dir, 'cat', 'pkg'))
        ensure_dirs(pjoin(self.dir, 'empty', 'empty'))
        ensure_dirs(pjoin(self.dir, 'scripts', 'pkg'))
        ensure_dirs(pjoin(self.dir, 'notcat', 'CVS'))
        touch(pjoin(self.dir, 'cat', 'pkg', 'pkg-3.ebuild'))
        repo = self.mk_tree(self.dir)
        self.assertEqual(
            {'cat': (), 'notcat': (), 'empty': ()}, dict(repo.categories))
        self.assertEqual(
            {'cat': ('pkg',), 'empty': ('empty',), 'notcat': ()},
            dict(repo.packages))
        self.assertEqual(
            {('cat', 'pkg'): ('3',), ('empty', 'empty'): ()},
            dict(repo.versions))

        for x in ("1-scm", "scm", "1-try", "1_beta-scm", "1_beta-try"):
            for rev in ("", "-r1"):
                fp = pjoin(self.dir, 'cat', 'pkg', 'pkg-%s%s.ebuild' %
                    (x, rev))
                open(fp, 'w').close()
                repo = self.mk_tree(self.dir)
                self.assertRaises(ebuild_errors.InvalidCPV,
                    repo.match, atom('cat/pkg'))
                repo = self.mk_tree(self.dir, ignore_paludis_versioning=True)
                self.assertEqual(sorted(x.cpvstr for x in
                    repo.itermatch(atom('cat/pkg'))), ['cat/pkg-3'])
                os.unlink(fp)
开发者ID:neko259,项目名称:pkgcore,代码行数:28,代码来源:test_repository.py

示例12: _cmd_implementation_sanity_check

 def _cmd_implementation_sanity_check(self, domain):
     pkg = self.pkg
     eapi = pkg.eapi_obj
     if eapi.options.has_required_use:
         use = pkg.use
         for node in pkg.required_use:
             if not node.match(use):
                 print(textwrap.dedent(
                     """
                     REQUIRED_USE requirement wasn't met
                     Failed to match: {}
                     from: {}
                     for USE: {}
                     pkg: {}
                     """.format(node, pkg.required_use, " ".join(use), pkg.cpvstr)
                 ))
                 return False
     if 'pretend' not in pkg.mandatory_phases:
         return True
     commands = None
     if not pkg.built:
         commands = {"request_inherit": partial(inherit_handler, self._eclass_cache)}
     env = expected_ebuild_env(pkg)
     tmpdir = normpath(domain._get_tempspace())
     builddir = pjoin(tmpdir, env["CATEGORY"], env["PF"])
     pkg_tmpdir = normpath(pjoin(builddir, "temp"))
     ensure_dirs(pkg_tmpdir, mode=0770, gid=portage_gid, minimal=True)
     env["ROOT"] = domain.root
     env["T"] = pkg_tmpdir
     try:
         logger.debug("running ebuild pkg_pretend sanity check for %s", pkg.cpvstr)
         start = time.time()
         ret = run_generic_phase(pkg, "pretend", env, userpriv=True, sandbox=True,
                                 fakeroot=False, extra_handlers=commands)
         logger.debug("pkg_pretend sanity check for %s took %2.2f seconds",
             pkg.cpvstr, time.time() - start)
         return ret
     except format.GenericBuildError as e:
         logger.error("pkg_pretend sanity check for %s failed with exception %r"
             % (pkg.cpvstr, e))
         return False
     finally:
         shutil.rmtree(builddir)
         # try to wipe the cat dir; if not empty, ignore it
         try:
             os.rmdir(os.path.dirname(builddir))
         except EnvironmentError as e:
             if e.errno != errno.ENOTEMPTY:
                 raise
开发者ID:floppym,项目名称:pkgcore,代码行数:49,代码来源:ebd.py

示例13: test_gid

 def test_gid(self):
     # abuse the portage group as secondary group
     try:
         portage_gid = grp.getgrnam('portage').gr_gid
     except KeyError:
         pytest.skip('the portage group does not exist')
     if portage_gid not in os.getgroups():
         pytest.skip('you are not in the portage group')
     path = pjoin(self.dir, 'group', 'group')
     assert osutils.ensure_dirs(path, gid=portage_gid)
     self.check_dir(path, os.geteuid(), portage_gid, 0o777)
     assert osutils.ensure_dirs(path)
     self.check_dir(path, os.geteuid(), portage_gid, 0o777)
     assert osutils.ensure_dirs(path, gid=os.getegid())
     self.check_dir(path, os.geteuid(), os.getegid(), 0o777)
开发者ID:radhermit,项目名称:snakeoil,代码行数:15,代码来源:test_osutils.py

示例14: setup_distfiles

    def setup_distfiles(self):
        if not self.verified_files and self.allow_fetching:
            ops = self.domain.pkg_operations(self.pkg,
                observer=self.observer)
            if not ops.fetch():
                raise format.BuildError("failed fetching required distfiles")
            self.verified_files = ops._fetch_op.verified_files

        if self.verified_files:
            try:
                if os.path.exists(self.env["DISTDIR"]):
                    if (os.path.isdir(self.env["DISTDIR"])
                        and not os.path.islink(self.env["DISTDIR"])):
                        shutil.rmtree(self.env["DISTDIR"])
                    else:
                        os.unlink(self.env["DISTDIR"])

            except EnvironmentError as oe:
                raise_from(format.FailedDirectory(
                    self.env["DISTDIR"],
                    "failed removing existing file/dir/link at: exception %s"
                    % oe))

            if not ensure_dirs(self.env["DISTDIR"], mode=0770,
                               gid=portage_gid):
                raise format.FailedDirectory(
开发者ID:chutz,项目名称:pkgcore,代码行数:26,代码来源:ebd.py

示例15: add_data

    def add_data(self):
        if self.observer is None:
            end = start = lambda x:None
        else:
            start = self.observer.phase_start
            end = self.observer.phase_end
        pkg = self.new_pkg
        final_path = discern_loc(self.repo.base, pkg, self.repo.extension)
        tmp_path = pjoin(os.path.dirname(final_path),
            ".tmp.%i.%s" % (os.getpid(), os.path.basename(final_path)))

        self.tmp_path, self.final_path = tmp_path, final_path

        if not ensure_dirs(os.path.dirname(tmp_path), mode=0755):
            raise repo_interfaces.Failure("failed creating directory %r" %
                os.path.dirname(tmp_path))
        try:
            start("generating tarball: %s" % tmp_path)
            tar.write_set(pkg.contents, tmp_path, compressor='bzip2',
                parallelize=True)
            end("tarball created", True)
            start("writing Xpak")
            # ok... got a tarball.  now add xpak.
            xpak.Xpak.write_xpak(tmp_path, generate_attr_dict(pkg))
            end("wrote Xpak", True)
            # ok... we tagged the xpak on.
            os.chmod(tmp_path, 0644)
        except Exception as e:
            try:
                unlink_if_exists(tmp_path)
            except EnvironmentError as e:
                logger.warning("failed removing %r: %r" % (tmp_path, e))
            raise
        return True
开发者ID:chutz,项目名称:pkgcore,代码行数:34,代码来源:repo_ops.py


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