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

Python misc.create_symlink函数代码示例

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

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



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

示例1: _publish_distribution_treeinfo

    def _publish_distribution_treeinfo(self, distribution_unit):
        """
        For a given AssociatedUnit for a distribution.  Create the links for the treeinfo file
        back to the treeinfo in the content.

        :param distribution_unit: The unit for the distribution from which the list
                                  of files to be published should be pulled from.
        :type distribution_unit: pulp_rpm.plugins.db.models.Distribution
        """
        distribution_unit_storage_path = distribution_unit._storage_path
        src_treeinfo_path = None
        treeinfo_file_name = None
        for treeinfo in constants.TREE_INFO_LIST:
            test_treeinfo_path = os.path.join(distribution_unit_storage_path, treeinfo)
            if os.path.exists(test_treeinfo_path):
                # we found the treeinfo file
                src_treeinfo_path = test_treeinfo_path
                treeinfo_file_name = treeinfo
                break
        if src_treeinfo_path is not None:
            # create a symlink from content location to repo location.
            symlink_treeinfo_path = os.path.join(self.get_working_dir(), treeinfo_file_name)
            logger.debug("creating treeinfo symlink from %s to %s" % (src_treeinfo_path,
                                                                      symlink_treeinfo_path))
            plugin_misc.create_symlink(src_treeinfo_path, symlink_treeinfo_path)
开发者ID:Mahendra-Shivaswamy-Devops,项目名称:pulp_rpm,代码行数:25,代码来源:publish.py


示例2: _publish_distribution_files

    def _publish_distribution_files(self, distribution_unit):
        """
        For a given AssociatedUnit for a distribution.  Create all the links back to the
        content units that are referenced within the 'files' metadata section of the unit.

        :param distribution_unit: The unit for the distribution from which the list
                                  of files to be published should be pulled from.
        :type distribution_unit: pulp_rpm.plugins.db.models.Distribution
        """
        if not distribution_unit.files:
            msg = "No distribution files found for unit %s" % distribution_unit
            logger.warning(msg)
            return

        distro_files = distribution_unit.files
        total_files = len(distro_files)
        logger.debug("Found %s distribution files to symlink" % total_files)

        source_path_dir = distribution_unit._storage_path
        symlink_dir = self.get_working_dir()
        for dfile in distro_files:
            if dfile['relativepath'].startswith('repodata/'):
                continue
            source_path = os.path.join(source_path_dir, dfile['relativepath'])
            symlink_path = os.path.join(symlink_dir, dfile['relativepath'])
            plugin_misc.create_symlink(source_path, symlink_path)
开发者ID:roysjosh,项目名称:pulp_rpm,代码行数:26,代码来源:publish.py


示例3: test_create_symlink

    def test_create_symlink(self):
        source_path = os.path.join(self.working_dir, "source")
        link_path = os.path.join(self.published_dir, "link")
        touch(source_path)

        self.assertFalse(os.path.exists(link_path))
        misc.create_symlink(source_path, link_path)
        self.assertTrue(os.path.exists(link_path))
开发者ID:pcreech,项目名称:pulp,代码行数:8,代码来源:test_misc.py


示例4: process_main

    def process_main(self, item):
        """
        Link the item to the Blob file.

        :param item: The Blob to process
        :type  item: pulp_docker.plugins.models.Blob
        """
        misc.create_symlink(item._storage_path,
                            os.path.join(self.get_blobs_directory(), item.unit_key['digest']))
开发者ID:bbuckingham,项目名称:pulp_docker,代码行数:9,代码来源:publish_steps.py


示例5: test_create_symlink_no_source

    def test_create_symlink_no_source(self):
        """Assert links are created, even if the source doesn't exist."""
        source_path = os.path.join(self.working_dir, "source")
        link_path = os.path.join(self.published_dir, "link")

        self.assertFalse(os.path.exists(source_path))
        self.assertFalse(os.path.exists(link_path))
        misc.create_symlink(source_path, link_path)
        self.assertTrue(os.path.lexists(link_path))
        self.assertFalse(os.path.exists(source_path))
开发者ID:pcreech,项目名称:pulp,代码行数:10,代码来源:test_misc.py


示例6: test_create_symlink_no_link_parent_with_permissions

    def test_create_symlink_no_link_parent_with_permissions(self, mock_makedirs, mock_symlink):
        source_path = os.path.join(self.working_dir, "source")
        link_path = os.path.join(self.published_dir, "foo/bar/baz/link")

        touch(source_path)
        self.assertFalse(os.path.exists(os.path.dirname(link_path)))

        misc.create_symlink(source_path, link_path, directory_permissions=0700)

        mock_makedirs.assert_called_once_with(os.path.dirname(link_path), mode=0700)
        mock_symlink.assert_called_once_with(source_path, link_path)
开发者ID:pcreech,项目名称:pulp,代码行数:11,代码来源:test_misc.py


示例7: test_create_symlink_no_link_parent

    def test_create_symlink_no_link_parent(self, mock_makedirs, mock_symlink):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'foo/bar/baz/link')

        touch(source_path)
        self.assertFalse(os.path.exists(os.path.dirname(link_path)))

        misc.create_symlink(source_path, link_path)

        mock_makedirs.assert_called_once_with(os.path.dirname(link_path), mode=0770)
        mock_symlink.assert_called_once_with(source_path, link_path)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:11,代码来源:test_misc.py


示例8: process_main

    def process_main(self, item):
        """
        Create the manifest tag links.

        :param item: The tag to process
        :type  item: pulp_docker.plugins.models.Tag
        """
        manifest = models.Manifest.objects.get(digest=item.manifest_digest)
        misc.create_symlink(
            manifest._storage_path,
            os.path.join(self.parent.publish_manifests_step.get_manifests_directory(), item.name))
        self._tag_names.add(item.name)
开发者ID:shubham90,项目名称:pulp_docker,代码行数:12,代码来源:publish_steps.py


示例9: test_create_symlink_link_exists_and_is_correct

    def test_create_symlink_link_exists_and_is_correct(self):
        new_source_path = os.path.join(self.working_dir, "new_source")
        link_path = os.path.join(self.published_dir, "link")

        touch(new_source_path)

        os.symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)

        misc.create_symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)
开发者ID:pcreech,项目名称:pulp,代码行数:13,代码来源:test_misc.py


示例10: process_main

    def process_main(self, item):
        """
        Link the unit to the image content directory and the package_dir

        :param item: The Image to process
        :type  item: pulp_docker.common.models.Image
        """
        self.redirect_context.add_unit_metadata(item)
        target_base = os.path.join(self.get_web_directory(), item.unit_key['image_id'])
        files = ['ancestry', 'json', 'layer']
        for file_name in files:
            misc.create_symlink(os.path.join(item.storage_path, file_name),
                                os.path.join(target_base, file_name))
开发者ID:daviddavis,项目名称:pulp_docker,代码行数:13,代码来源:v1_publish_steps.py


示例11: process_main

    def process_main(self, item=None):

        """
        Link the unit to the image content directory and the package_dir

        :param item: The unit to process
        :type item: pulp_docker.plugins.db.models.DockerImage
        """
        self.redirect_context.add_unit_metadata(item)
        target_base = os.path.join(self.get_web_directory(), item.image_id)
        files = ['ancestry', 'json', 'layer']
        for file_name in files:
            plugin_utils.create_symlink(os.path.join(item.storage_path, file_name),
                                        os.path.join(target_base, file_name))
开发者ID:jeremycline,项目名称:pulp_docker,代码行数:14,代码来源:publish_steps.py


示例12: test_create_symlink_link_exists

    def test_create_symlink_link_exists(self):
        old_source_path = os.path.join(self.working_dir, "old_source")
        new_source_path = os.path.join(self.working_dir, "new_source")
        link_path = os.path.join(self.published_dir, "link")

        touch(old_source_path)
        touch(new_source_path)

        os.symlink(old_source_path, link_path)

        self.assertEqual(os.readlink(link_path), old_source_path)

        link_path_with_slash = link_path + "/"

        misc.create_symlink(new_source_path, link_path_with_slash)

        self.assertEqual(os.readlink(link_path), new_source_path)
开发者ID:pcreech,项目名称:pulp,代码行数:17,代码来源:test_misc.py


示例13: _create_symlink

    def _create_symlink(source_path, link_path):
        """
        Create a symlink from the link path to the source path.

        If the link_path points to a directory that does not exist the directory
        will be created first.

        If we are overriding a current symlink with a new target - a debug message will be logged

        If a file already exists at the location specified by link_path an exception will be raised

        :param source_path: path of the source to link to
        :type  source_path: str
        :param link_path: path of the link
        :type  link_path: str
        """
        misc.create_symlink(source_path, link_path)
开发者ID:jeremycline,项目名称:pulp,代码行数:17,代码来源:publish_step.py


示例14: process_main

    def process_main(self, item=None):
        """
        Link the unit to the content directory and the package_dir

        :param item: The item to process or none if this get_iterator is not defined
        :type item: pulp_rpm.plugins.db.models.RPM or pulp_rpm.plugins.db.models.SRPM
        """
        unit = item
        source_path = unit._storage_path
        destination_path = os.path.join(self.get_working_dir(), unit.filename)
        plugin_misc.create_symlink(source_path, destination_path)
        for package_dir in self.dist_step.package_dirs:
            destination_path = os.path.join(package_dir, unit.filename)
            plugin_misc.create_symlink(source_path, destination_path)

        for context in (self.file_lists_context, self.other_context, self.primary_context):
            context.add_unit_metadata(unit)
开发者ID:Mahendra-Shivaswamy-Devops,项目名称:pulp_rpm,代码行数:17,代码来源:publish.py


示例15: _publish_distribution_files

    def _publish_distribution_files(self, distribution_unit):
        """
        For a given AssociatedUnit for a distribution.  Create all the links back to the
        content units that are referenced within the 'files' metadata section of the unit.

        :param distribution_unit: The unit for the distribution from which the list
                                  of files to be published should be pulled from.
        :type distribution_unit: pulp_rpm.plugins.db.models.Distribution
        """
        if not distribution_unit.files:
            msg = "No distribution files found for unit %s" % distribution_unit
            logger.warning(msg)
            return

        # The files from `treeinfo` and `PULP_DISTRIBUTION.xml` are mashed into the
        # files list on the unit. This is a hacky work-around to unmash them, filter
        # out anything that is in the main repodata directory (which is potentially not
        # safe, but was happening before I got here and we don't have time to fix this
        # properly right now), and generate a new `PULP_DISTRIBUTION.xml` that doesn't
        # reference files that don't exist in this publish.
        pulp_distribution_file = False
        distro_files = [f['relativepath'] for f in distribution_unit.files]
        if constants.DISTRIBUTION_XML in distro_files:
            distro_files.remove(constants.DISTRIBUTION_XML)
            pulp_distribution_file = True
        distro_files = filter(lambda f: not f.startswith('repodata/'), distro_files)
        total_files = len(distro_files)
        logger.debug("Found %s distribution files to symlink" % total_files)

        source_path_dir = distribution_unit._storage_path
        symlink_dir = self.get_working_dir()
        for dfile in distro_files:
            source_path = os.path.join(source_path_dir, dfile)
            symlink_path = os.path.join(symlink_dir, dfile)
            plugin_misc.create_symlink(source_path, symlink_path)

        # Not all repositories have this file so this is only done if the upstream repo
        # had the file.
        if pulp_distribution_file:
            xml_file_path = os.path.join(source_path_dir, constants.DISTRIBUTION_XML)
            self._write_pulp_distribution_file(distro_files, xml_file_path)
开发者ID:Mahendra-Shivaswamy-Devops,项目名称:pulp_rpm,代码行数:41,代码来源:publish.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python misc.mkdir函数代码示例发布时间:2022-05-25
下一篇:
Python metadata_writer.MetadataFileContext类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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